Hi alex,
I tried to convert a 5-class weight file trained in this fork to tensorflow model with following repo:
https://github.com/mystic123/tensorflow-yolo-v3/
(It takes weight file and name file, read number of classes from the name file)
However, I got an reshape array size error indicating that it only has 4 classes. (it does compile when i delete one class, but the detection result is not correct in TF)
I tried the same process using weight file trained in PJ's fork, and I do not face to same error.
Would you be able to shed some light on this please ? (it could be issue with their conversion code?). Thanks for your response.
I tried the same process using weight file trained in PJ's fork, and I do not face to same error.
Did you convert successfully your own trained model on PJ's repo or default model yolov3.weights ?
Do you use Linux or Windows?
Can you rename your cfg-file to txt-file and drag-n-drop it to your message?
Did you use Adam optimizer during training?
I tried the same process using weight file trained in PJ's fork, and I do not face to same error.
- Did you convert successfully your own trained model on PJ's repo or default model
yolov3.weights?
My own trained model in PJ's repo. The conversion reads 5 classes, and didnt complain about dimension.
- Do you use Linux or Windows?
Linux
- Can you rename your cfg-file to txt-file and drag-n-drop it to your message?
- Did you use Adam optimizer during training?
No. i didn't.
Greetings Alex,
I got the same problem here. The messages are shown below:
D:\MyProjects\tensorflow-yolo-v3>python convert_weights_pb.py --class_names my_model.names --data_format NHWC --weights_file my_model.weights --tiny
WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.
WARNING:tensorflow:From C:\Users\User\AppData\Roaming\Python\Python37\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.
Traceback (most recent call last):
File "convert_weights_pb.py", line 52, in <module>
tf.app.run()
File "C:\Users\User\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "convert_weights_pb.py", line 42, in main
load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file)
File "D:\MyProjects\tensorflow-yolo-v3\utils.py", line 115, in load_weights
(shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 4607 into shape (18,256,1,1)
@arkjiang @cayman1021 Hi,
Try to use the latest version of this repository for training. Before Mar 2, 2019 there was an issue with ADAM. More about this issue: https://github.com/AlexeyAB/darknet/issues/2688
Check that you set classes= in all [yolo]-layers in cfg-files
Check that you obj.names file contains as many lines as classes.
Dunno if I've used Adam optimizer. Probably not.
Yes, there could be a problem with ADAM before. But if you trained your model after Mar 2, 2019 there shouldn't be a problem, this issue is fixed now.
in original repo is removed saving adam-parameters to weights-file at: Commits on 13 Jun 2017
https://github.com/pjreddie/darknet/commit/1467621453e1c6932841a4992e6dffe0d0d8de24#diff-bfbbcdf73459e9ea8fb4afa8455ce74dL858
in my repo is removed saving adam-parameters to weights-file at: Commits on Mar 2, 2019 https://github.com/AlexeyAB/darknet/commit/75f2a3e7cf7f9d54080e9f6327a765e8d25876dc#diff-bfbbcdf73459e9ea8fb4afa8455ce74dR993
Most helpful comment
@arkjiang @cayman1021 Hi,
Try to use the latest version of this repository for training. Before
Mar 2, 2019there was an issue with ADAM. More about this issue: https://github.com/AlexeyAB/darknet/issues/2688Check that you set classes= in all
[yolo]-layers in cfg-filesCheck that you
obj.namesfile contains as many lines as classes.Yes, there could be a problem with ADAM before. But if you trained your model after Mar 2, 2019 there shouldn't be a problem, this issue is fixed now.
in original repo is removed saving adam-parameters to weights-file at:
Commits on 13 Jun 2017https://github.com/pjreddie/darknet/commit/1467621453e1c6932841a4992e6dffe0d0d8de24#diff-bfbbcdf73459e9ea8fb4afa8455ce74dL858in my repo is removed saving adam-parameters to weights-file at:
Commits on Mar 2, 2019https://github.com/AlexeyAB/darknet/commit/75f2a3e7cf7f9d54080e9f6327a765e8d25876dc#diff-bfbbcdf73459e9ea8fb4afa8455ce74dR993