hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.23k stars 1.24k forks source link

Error in conversing custom weights of yolov4 #362

Open Akash3194 opened 3 years ago

Akash3194 commented 3 years ago

I am getting error like below while using my own yolov4 weights model, i have already replace .names file with my own in core config file. In my model i have just 1 class. The error i am getting is below.

A service 0x3cf2520 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2021-06-10 15:18:21.048305: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version Traceback (most recent call last): File "save_model.py", line 58, in app.run(main) File "/home/aakash_tyagi/PycharmProjects/tensorflow-yolov4-tflite/venv/lib/python3.6/site-packages/absl/app.py", line 303, in run _run_main(main, args) File "/home/aakash_tyagi/PycharmProjects/tensorflow-yolov4-tflite/venv/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "save_model.py", line 54, in main save_tf() File "save_model.py", line 49, in save_tf utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny) File "/home/aakash_tyagi/PycharmProjects/tensorflow-yolov4-tflite/core/utils.py", line 63, in load_weights conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 4457630 into shape (1024,512,3,3)

faizmisman commented 3 years ago

Hi. Any solution to this issue? I got the same error

hemanthganeshkuricheti commented 3 years ago

Even I m facing the same error. Please let me know if you come across with an answer

sutejoramadhan commented 3 years ago

I've facing same problem, but already solved by change the value of __C.YOLO.CLASSES with custom classes path in core/config.py

khg2478 commented 3 years ago

@sutejoramadhan Hello. I have changed the config.py file with appropriate classes path and anchors but still doesn't work after successful conversion into tflite format. Any suggestions?

haimin777 commented 2 years ago

I fix this issue by checking file obj.names. There was empty line in the bottom of file. It was enterpreted as +1 class. Thats it.