h5模型操作错误OSError:无法打开文件(未找到文件签名)

时间:2020-02-26 02:32:39

标签: python-3.x tensorflow model h5py

我有一个从GitHub克隆的聊天机器人项目。它的h5模型文件为emoji_model.h5,其中包含

version https://git-lfs.github.com/spec/v1 oid sha256:fa1b66494eb29a0ae5c1c28b44c15bb1f8ce8c3e3dae38f21b8aac1f43e26ee2 size 208336040

运行python3 application.py时出现以下错误

Using TensorFlow backend.
Traceback (most recent call last):
  File "application.py", line 78, in <module>
    get_model()
  File "application.py", line 19, in get_model
    model = load_model('emoji_model.h5')
  File "/Users/shamilasallay/Documents/MSC/year2/semester2/MCS3204-Project/examples/Emojify-ML-Flask-App-master/flask/lib/python3.6/site-packages/keras
/engine/saving.py", line 417, in load_model
    f = h5dict(filepath, 'r')
  File "/Users/shamilasallay/Documents/MSC/year2/semester2/MCS3204-Project/examples/Emojify-ML-Flask-App-master/flask/lib/python3.6/site-packages/keras
/utils/io_utils.py", line 186, in __init__
    self.data = h5py.File(path, mode=mode)
  File "/Users/shamilasallay/Documents/MSC/year2/semester2/MCS3204-Project/examples/Emojify-ML-Flask-App-master/flask/lib/python3.6/site-packages/h5py/
_hl/files.py", line 408, in __init__
    swmr=swmr)
  File "/Users/shamilasallay/Documents/MSC/year2/semester2/MCS3204-Project/examples/Emojify-ML-Flask-App-master/flask/lib/python3.6/site-packages/h5py/
_hl/files.py", line 173, 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 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)

我不知道是否应该从某个地方下载h5数据。无法解决此错误,我将无法继续。任何帮助都非常感激

1 个答案:

答案 0 :(得分:0)

emoji_model.h5的网络搜索找到2个提及您的application.py来源和此.h5文件的网站。链接末尾。
我从github站点下载了emoji_model.h5,并尝试使用一些HDF5实用程序(h5dumpHDFView)打开。都失败了。我认为这不是有效的HDF5文件(如果存在,则表明文件已损坏)。

链接:
-EMOJIFY ML Web App
-Related GitHub site