Python 加载联机托管的TensorFlow(.h5)模型
我正在尝试使用在线存储的链接(Python 加载联机托管的TensorFlow(.h5)模型,python,tensorflow,Python,Tensorflow,我正在尝试使用在线存储的链接(https://)加载.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) 与.h5的链接非常好,因此与TensorFlow有关。有人能帮忙吗?虽然我想不出从URL直接
https://
)加载.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)
与.h5的链接非常好,因此与TensorFlow有关。有人能帮忙吗?虽然我想不出从URL直接加载模型的方法,但我使用了一个技巧,使用
urllib.request
包实现了类似的功能
import urllib.request
urllib.request.urlretrieve(
'http://<url>/model.h5', 'model.h5')
注意:以上代码是针对Python 3编写的。如果您使用的是Python 2,请使用以下代码:
import urllib
urllib.urlretrieve('http://<url>/model.h5', 'model.h5')
导入urllib
urllib.urlretrieve('http:///model.h5','model.h5')
MODEL_PATH = './model.h5'
import urllib
urllib.urlretrieve('http://<url>/model.h5', 'model.h5')