Loading pertained weights
Closed this issue · 7 comments
Starting with the mobilenet backend and pertained weights, it errors with:
Loading pre-trained weights in ./backend_weights/mobilenet_backend.h5
Traceback (most recent call last):
File "train.py", line 138, in <module>
_main_(_args)
File "train.py", line 107, in _main_
yolo.load_weights(config['train']['pretrained_weights'])
File "/Users/adammenges/Development/notebooks/boundingBoxSpeedTest/keras_yolo2/keras_yolov2/frontend.py", line 77, in load_weights
self._model.load_weights(weight_path)
File "/usr/local/lib/python3.7/site-packages/keras/engine/network.py", line 1166, in load_weights
f, self.layers, reshape=reshape)
File "/usr/local/lib/python3.7/site-packages/keras/engine/saving.py", line 1030, in load_weights_from_hdf5_group
str(len(filtered_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 54 layers into a model with 2 layers.
Config:
{
"model": {
"backend": "MobileNet",
"input_size_w": 160,
"input_size_h": 160,
"gray_mode": false,
"anchors": [
9.53758,
11.73922,
12.46069,
18.66056,
14.55546,
26.65779,
20.15099,
26.32192,
27.16661,
27.60551
],
"max_box_per_image": 10,
"labels": ["raccoon"]
},
"parser_annotation_type": "xml",
"train": {
"train_csv_file": "",
"train_csv_base_path": "",
"train_image_folder": "/Users/adammenges/Development/notebooks/boundingBoxSpeedTest/raccoon_dataset/images-train/",
"train_annot_folder": "/Users/adammenges/Development/notebooks/boundingBoxSpeedTest/raccoon_dataset/annotations-train/",
"callback": null,
"train_times": 20,
"pretrained_weights": "./backend_weights/mobilenet_backend.h5",
"batch_size": 16,
"learning_rate": 1e-4,
"nb_epochs": 50,
"warmup_epochs": 3,
"workers": 3,
"max_queue_size": 8,
"early_stop": true,
"tensorboard_log_dir": "./logsMobileNet/example",
"object_scale": 5.0,
"no_object_scale": 1.0,
"coord_scale": 1.0,
"class_scale": 1.0,
"saved_weights_name": "./racconMobileNet.h5",
"debug": true
},
"valid": {
"iou_threshold": 0.7,
"score_threshold": 0.5,
"valid_csv_file": "",
"valid_csv_base_path": "",
"valid_image_folder": "/Users/adammenges/Development/notebooks/boundingBoxSpeedTest/raccoon_dataset/images-test",
"valid_annot_folder": "/Users/adammenges/Development/notebooks/boundingBoxSpeedTest/raccoon_dataset/annotations-test",
"valid_times": 1
},
"backup": {
"create_backup": true,
"redirect_model": true,
"backup_path": "../backupMobileNet",
"backup_prefix": "MobileNet_VOC"
}
}
the problem is that you are trying to load the backend weigths into whole model, it is not possible
Apologies, I don't quite understand. The backend_weights there are the pertained weights I downloaded from this repo. I put them in backend_weights
folder after trying them at the root (like the README mentioned), with the same error. Are you saying there's something wrong in my config file?
just put the weights file in your root folder and don't specify any weights in the config file, the pre trained weights for the backend will be loaded automatically
When I do that I see:
⇒ python3 train.py -c config.json
Using TensorFlow backend.
2019-06-18 12:17:43.120868: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
Insert a comment about this training: test3
Redirecting ./racconSqueezeNet.h5 file name to ../backupSqueezeNet/SqueezeNet_VOC_20190618121743/SqueezeNet_VOC_20190618121743.h5.
Redirecting ./logsSqueezeNet/example tensorborad log to ../backupSqueezeNet/SqueezeNet_VOC_20190618121743/logs.
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 190/190 [00:00<00:00, 6296.01it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 7434.07it/s]
Seen labels: {'raccoon': 207}
Given labels: ['raccoon']
Overlap labels: {'raccoon'}
WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Unable to load backend weights. Using a fresh model
Specifically: Unable to load backend weights. Using a fresh model
Does that just mean it's the first training run, so there's no previous model to load, but that the pertained weights have been picked up? I don't see anything in the logs about pertained weights.
In this yolo we have two types of pre treined weights, the first one is the weights for the backend model, suck as Full Yolo, Mobilenet and so on, the second case is the weights for the whole model, where you can set into the config file, the whole model weights overwrite the backend weights when it is loaded.
create a folder called "backend_weights" inside your root directory and put the mobile weights there.
you can see it here.
Ah, sounds good. Thanks!