david8862 / keras-YOLOv3-model-set

end-to-end YOLOv4/v3/v2 object detection pipeline, implemented on tf.keras with different technologies
MIT License
639 stars 220 forks source link

--weights_path is ignored if a default value is available #188

Open alexanderwendt opened 3 years ago

alexanderwendt commented 3 years ago

I execute the yolo.py, where I want to execute the .py from a script in another folder. Therefore, I use an alternative weights path.

PREFIX='/home/intel-nuc/keras-yolov3-model-set/keras-YOLOv3-model-set'

python tools/model_converter/convert.py cfg/yolov3-tiny.cfg weights/yolov3-tiny.weights weights/yolov3-tiny.h5

python $PREFIX/yolo.py \ --model_type=tiny_yolo3_darknet \ --anchors_path $PREFIX/configs/tiny_yolo3_anchors.txt \ --weights_path $PREFIX/weights/yolov3-tiny.h5 \ --classes_path $PREFIX/configs/coco_classes.txt \ --image

For tiny_yolo3_darknet this execution fails because it does not find the weights path "OSError: Unable to open file (unable to open file: name = 'weights/yolov3-tiny.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)"

For some reason, the program seem to ignore my custom weight path and just use the preset one in model.py:160: 'tiny_yolo3_darknet': [custom_tiny_yolo3_body, 20, 'weights/yolov3-tiny.h5'], There seems to not to be any method that overwrites the default value.

Also with yolo3_darknet_spp, I get the same problem. When I hardcode the default value, it works: 'yolo3_darknet_spp': [custom_yolo3_spp_body, 185, '/home/intel-nuc/keras-yolov3-model-set/keras-YOLOv3-model-set/weights/yolov3-spp.h5'],

david8862 commented 3 years ago

@alexanderwendt what you see is auto pretrained imagenet/coco weights loading before your real weights. I've commit a fix for it and it should be ok now.

alexanderwendt commented 3 years ago

Thanks for the fast response and keep up the good job!