【发布时间】:2018-09-07 14:38:55
【问题描述】:
实现代码时: https://github.com/fizyr/keras-retinanet 下面是 convert_model.py 脚本的代码
# Allow relative imports when being executed as script.
if __name__ == "__main__" and __package__ is None:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
import keras_retinanet.bin # noqa: F401
__package__ = "keras_retinanet.bin"
# Change these to absolute imports if you copy this script outside the keras_retinanet package.
from keras_retinanet.models import load_model
model_path = os.path.join('..', 'snapshots', 'resnet50_coco_best_v2.1.0.h5')
model = load_model(model_path, backbone_name='resnet50')
执行convert_model.py脚本,出现如下错误:
Traceback (most recent call last):
File "convert_model.py", line 33, in <module>
model = load_model(model_path, backbone_name='resnet50')
File "..\..\keras_retinanet\models\__init__.py", line 83, in load_model
model = keras.models.load_model(filepath, custom_objects=backbone(backbone_name).custom_objects)
File "C:\Python\Python36\lib\site-packages\keras\engine\saving.py", line 249, in load_model
f = h5py.File(filepath, mode='r')
File "C:\Python\Python36\lib\site-packages\h5py\_hl\files.py", line 312, in __init__
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "C:\Python\Python36\lib\site-packages\h5py\_hl\files.py", line 142, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = '..\snapshots\resnet50_coco_best_v2.1.0.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
你能帮我解决这个问题吗?
【问题讨论】:
-
您必须向我们展示您的代码。
-
你读错了吗?
-
是的,我做到了。我是这方面的初学者,无法理解它所说的内容。我什至尝试过谷歌搜索,但没有得到所需的答案。
-
如果您只是获取 repo 并运行它而不更改任何内容,那么您将遇到问题,因为您尚未更新路径 - 与模型本身无关。跨度>
-
我已经提到了我从源代码中获取的代码。但我确实更新了代码中的路径,其余的都是一样的。