简体   繁体   中英

How to access images directly from Google Cloud Storage (GCS) when using Keras?

I have developed a model in Keras that works perfectly when reading data stored locally. However, I now want to take advantage of Google Cloud Platform's GPUs for training the model. I have set up the GPU on GCP and am working in a Jupyter notebook. I have moved my images to Google Cloud Storage.

My question is:

How can I access these images (specifically the directories - training, validation, test) directly from Cloud Storage using the Keras' flow_from_directory method of the ImageDataGenerator class?

here's my directory structure in Google Cloud Storage (GCS):

mybucketname/
      class_1/
          img001.jpg
          img002.jpg
          ...
      class_2/
          img001.jpg
          img002.jpg
          ...
      class_3/
          img001.jpg 
          img002.jpg
          ...

虽然我还没有找到直接从 GCS 读取图像数据的方法,但同时我可以通过import os, sys os.system('gsutil cp -r gs://mybucketname/ .')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM