Search code examples
google-cloud-platformjupyter-labbucketgoogle-cloud-vertex-ai

Read images from a bucket in GCP for ML


I have created a bucket in GCP containing my images dataset.

The path to it is: xray-competition-bucket/img_align_celeba

How do I read it from GCP to Jupyter Lab in Vertex AI?

My code is:

MAIN_PATH = '/gcs/xray-competition-bucket/img_align_celeba'

image_paths = glob((MAIN_PATH + "/*.jpg"))

and the result is that image_paths is an empty array.

Note: I also tried the path gs://my_bucket/...


Solution

  • You will need to download the GCS file locally using gsutil or the python SDK if you want to use glob. There are also libraries like GCSFS or TensorFlow's GFile which offer a pythonic file-system interface for working with GCS. For example, here is GFile.glob.