如何在 运行 在我的本地计算机上以及在 Google 云控制台表单 TensorFlow 模型上访问 GCP 上的 GCS 存储桶?
How to access GCS bucket on the GCP while running on my local machine and also on the Google Cloud console form TensorFlow model?
我正在本地机器上处理 TensorFlow 模型,运行 正常,现在我想在 Google 云平台上部署模型。但是当数据在 Google Cloud Storage 存储桶中时。
所以我的问题如下:
- 如何在本地计算机和 Google 云平台控制台上访问 Google 云存储桶到 运行 我的模型。
- Google Cloud Storage 存储桶的数据在多个文件中,那么如何使用 Python 将多个文件一起导入。
提前致谢。
您可以使用 gsutil 访问 Google Cloud Storage 存储桶,并将文件复制到 vm 的磁盘。
gsutil cp gs://你的桶/*
使用
from google.cloud import storage
# create storage client
storage_client = storage.Client.from_service_account_json('your_credential.json')
# get bucket with name
bucket = storage_client.get_bucket('yourbucket')
# get bucket data as blob
blob = bucket.get_blob('*')
# convert to string
json_data = blob.download_as_string()
参考:
我正在本地机器上处理 TensorFlow 模型,运行 正常,现在我想在 Google 云平台上部署模型。但是当数据在 Google Cloud Storage 存储桶中时。
所以我的问题如下:
- 如何在本地计算机和 Google 云平台控制台上访问 Google 云存储桶到 运行 我的模型。
- Google Cloud Storage 存储桶的数据在多个文件中,那么如何使用 Python 将多个文件一起导入。
提前致谢。
您可以使用 gsutil 访问 Google Cloud Storage 存储桶,并将文件复制到 vm 的磁盘。
gsutil cp gs://你的桶/*
使用
from google.cloud import storage
# create storage client
storage_client = storage.Client.from_service_account_json('your_credential.json')
# get bucket with name
bucket = storage_client.get_bucket('yourbucket')
# get bucket data as blob
blob = bucket.get_blob('*')
# convert to string
json_data = blob.download_as_string()
参考: