kbardool / Keras-frcnn

Keras Implementation of Faster R-CNN
Apache License 2.0
394 stars 313 forks source link

ValueError: You are trying to load a weight file containing 111 layers into a model with 89 layers. #64

Open thanhhien1166 opened 4 years ago

thanhhien1166 commented 4 years ago

I tried to run test_frcnn.py with pre-trained model_frcnn.hdf5 but I met this error:

Loading weights from ./model_frcnn.hdf5 Traceback (most recent call last): File "/content/BCCD_Dataset/keras-frcnn/test_frcnn.py", line 136, in model_rpn.load_weights("/content/BCCD_Dataset/model_frcnn.hdf5") File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 458, in load_wrapper return load_function(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/keras/engine/network.py", line 1217, in load_weights f, self.layers, reshape=reshape) File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 1171, in load_weights_from_hdf5_group str(len(filtered_layers)) + ' layers.') ValueError: You are trying to load a weight file containing 111 layers into a model with 89 layers.

The question is: Why we save weights of model_all (a model that holds both the RPN and the classifier) then load weights for model_rpn and model_classifier separately? Is this method causing the error?

ramshankerg commented 4 years ago

Yes perhaps, change model_all.save_weights to model.save in the train_frcnn.py . It worked for me