experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 784 forks source link

You are trying to load a weight file containing 2 layers into a model with 44 layers #413

Open lenhatdong opened 5 years ago

lenhatdong commented 5 years ago

I would like to train on my own data with 2 classifications, and i have this error. Can you help, please?

ValueError Traceback (most recent call last)

in 9 labels = config['model']['labels'], 10 max_box_per_image = config['model']['max_box_per_image'], ---> 11 anchors = config['model']['anchors']) 12 13 ############################### ~/YOLO/YOLO_py/frontend.py in __init__(self, backend, input_size, labels, max_box_per_image, anchors) 46 self.feature_extractor = MobileNetFeature(self.input_size) 47 elif backend == 'Full Yolo': ---> 48 self.feature_extractor = FullYoloFeature(self.input_size) 49 elif backend == 'Tiny Yolo': 50 self.feature_extractor = TinyYoloFeature(self.input_size) ~/YOLO/YOLO_py/backend.py in __init__(self, input_size) 165 166 self.feature_extractor = Model(input_image, x) --> 167 self.feature_extractor.load_weights(FULL_YOLO_BACKEND_PATH) 168 169 def normalize(self, image): ~/.local/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape) 1178 else: 1179 saving.load_weights_from_hdf5_group( -> 1180 f, self.layers, reshape=reshape) 1181 1182 def _updated_config(self): ~/.local/lib/python3.6/site-packages/keras/engine/saving.py in load_weights_from_hdf5_group(f, layers, reshape) 899 'containing ' + str(len(layer_names)) + 900 ' layers into a model with ' + --> 901 str(len(filtered_layers)) + ' layers.') 902 903 # We batch weight value assignments in a single backend call ValueError: You are trying to load a weight file containing 2 layers into a model with 44 layers.
Nagakiran1 commented 5 years ago

Similar error , i too faced.

Please change the pretrained weights with default Null string, for the sake first training. Next after that you can use trained model for predictions :-)

"pretrained_weights": "", # specify the path of the pretrained weights, but it's fine to start from scratch