无法运行tf.contrib.u模型.load_keras_model(),使用Google Bucket访问

2024-09-27 21:32:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试用以下代码运行python代码线路:-你知道吗

model_dir = 'gs://my-bucket-001/project-folder002/keras_export/model-folder003'
model = tf.contrib.saved_model.load_keras_model(model_dir)

如果我将Google bucket文件夹下载到本地,并将本地路径替换为model_dir,那么代码就可以工作了(即只需在Powershell中运行>;python temp.py,而不会出错)。但是如果我使用Google bucket作为model_dir,如上图所示,我得到了UnimplementedError: File system scheme 'gs' not implemented (file: 'gs://my-bucket-001/project-folder002/keras_export/model-folder003\assets\saved_model.json')。你知道吗

一开始,我怀疑这个问题是由于我的Google身份验证造成的,但是我能够在PowerShell终端中运行gsutil cp gs://my-bucket-001/some-test-files-004.txt ./(即,我使用的是windows10),而不会出错。我的googleapi密钥还允许我在Powershell中运行以下简单脚本,而不需要错误:-你知道吗

from google.cloud import storage
storage_client = storage.Client()
buckets = list(storage_client.list_buckets())
print(buckets)

为什么?我怀疑这是由于this discussion导致的与windows10的兼容性问题,但我不确定,因为这次讨论对我的影响有所不同。你知道吗

我怎样才能把这个修好?非常感谢!你知道吗


Tags: 代码projectgsmodelbucketmydirgoogle

热门问题