我正在尝试使用https://<url>
在线存储的链接()加载.h5模型,但我从TensorFlow收到此错误:
MODEL_PATH = 'http://<url>/<model_name>.h5'
# I have replace the <tags> with actual URL and file name
model = load_model(MODEL_PATH)
tensorflow.python.framework.errors_impl.UnimplementedError: File system scheme 'http' not implemented
到.h5的链接非常好,因此与TensorFlow有关。有人可以帮忙吗
虽然我无法找到一种直接从URL加载模型的方法,但我使用了一个技巧来使用该urllib.request
软件包实现类似的目的。
import urllib.request
urllib.request.urlretrieve(
'http://<url>/model.h5', 'model.h5')
上一行将下载h5模型并将其存储在项目的根目录中。然后,Python可以使用下载的模型:
MODEL_PATH = './model.h5'
注意:上面的代码适用于Python3。如果使用的是Python 2,请使用以下代码:
import urllib
urllib.urlretrieve('http://<url>/model.h5', 'model.h5')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句