KeyError:“ class_name”正在加载Keras json文件

时间:2019-06-24 05:28:15

标签: json keras resnet imagenet

我已经下载了json和h5文件以在imagenet上进行预训练的resten50。但是,加载json文件会给我带来keyerror。

我的代码:

json_file = open('models/resnet50/imagenet_class_index_new.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)

我收到以下错误。

> Traceback (most recent call last):
  File "/home/mycom/keras-flask-deploy-webapp/app.py", line 155, in <module>

    loaded_model = model_from_json(loaded_model_json)

  File "/home/mycom/.local/lib/python3.5/site-packages/keras/models.py", line 213, in model_from_json

    return layer_from_config(config, custom_objects=custom_objects)
  File "/home/mycom/.local/lib/python3.5/site-packages/keras/utils/layer_utils.py", line 27, in layer_from_config

    class_name = config['class_name']

KeyError: 'class_name'

可能是什么问题?我恢复为keras == 1.2.2,但问题仍然存在。

0 个答案:

没有答案