Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How do I list all the image URIs from a bucket to create a csv for classification automl model?

I have a bucket which has multiple folders with images in them. I want to make a csv for image classification with [ML_USE],GCS_FILE_PATH,[LABEL] format. how do i get the gcs file path for it?

0 1 735
1 REPLY 1

There is no built in way or straight forward way to get a GCS filepath/URI of different objects inside different folders.

Possible work around is:

  1. Use this List Objects (I suggest to use Client Libraries for more flexible usage). On the returned JSON, you may extract the different "your-folder/filename" on the "name" key.
  2. Once you get all the path of folder+filename, you may now concat is to the bucket name.

eg. "my-bucket/"  to concat with "your-folder/filename" will have you "my-bucket/your-folder/filename" through your code. Or if you want to transform it into a URI, you may concat "gs://my-bucket/" to all of your "your-folder/filename".

Then