Ning-Ding / Implementation-CVPR2015-CNN-for-ReID

Implementation for CVPR 2015 Paper: "An Improved Deep Learning Architecture for Person Re-Identification".
MIT License
147 stars 71 forks source link

load model error. #27

Open hah687980 opened 7 years ago

hah687980 commented 7 years ago

I try to save model after every iteration,and when i reload the model ,it report error:ValueError: Missing layer: input_2.
model = load_model('model35.h5') File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 233, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 307, in model_from_config return layer_module.deserialize(config, custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 54, in deserialize printable_module_name='layer') File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object list(custom_objects.items()))) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2450, in from_config process_layer(layer_data) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2437, in process_layer raise ValueError('Missing layer: ' + inbound_layer_name) ValueError: Missing layer: input_2

Similarly,when i add json_string = model.to_json() open('my_model_architecture.json','w').write(json_string)in main, model = generate_model() model = compile_model(model) json_string = model.to_json() open('model.json','w').write(json_string)

and when i try to reload the model from keras.models import model_from_json

json_file = open('model.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 "", line 1, in File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 339, in model_from_json return layer_module.deserialize(config, custom_objects=custom_objects) File "/usr/local/lib/python3.5/dist-packages/keras/layers/init.py", line 54, in deserialize printable_module_name='layer') File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object list(custom_objects.items()))) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2450, in from_config process_layer(layer_data) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2437, in process_layer raise ValueError('Missing layer: ' + inbound_layer_name) ValueError: Missing layer: input_2

How to solve this problem? How the program can stop and continue next time?

Ning-Ding commented 7 years ago

Try with the Python 2.7 for the error mentioned. If you could wait a few days, I will solve the second problem to stop and continue next time. I'm planning to update the whole code from Keras to TensorFlow and change the structure of the code. Also, a LICENSE and CONTRIBUTING.md will be published to make the code open source. To fix the Python version problem, I'll try my best to make the program can be use by both Python 2 and Python 3. Thank you for your issue.