将yolov4权重转换为tflite时,如何解决重塑ValueError的问题? [英] How can I solve reshape ValueError when convert yolov4 weights to tflite?
问题描述
当我尝试将yolov4权重转换为tflite时,发生ValueError.我无法解决此问题,找不到合适的答案.这个权重文件可在PycharmProject .py文件中找到,我可以在对象检测代码中找到它的执行权.但是在转换为tflite的过程中,发生了ValueError.
When I try to convert yolov4 weights to tflite, ValueError has occurred. I can't solve this problem and find an appropriate answer. This weights file is available in the PycharmProject .py file, and I can find it perform in an object detection code. But in the process of converting to tflite, ValueError has occurred.
使用的GitHub链接: tensorflow_yolov4_tflite tensorflow-yolov4
Used GitHub link : tensorflow_yolov4_tflite tensorflow-yolov4
我引用了此StackOverflow问题与解答,但它不起作用.无法将YOLOv4转换为tflite
I referenced this StackOverflow Q&A, but it doesn't work. Unable to convert YOLOv4 to tflite
这是ErrorCode.
This is ErrorCode.
(convert_tflite.py和convert.py(至pb)也不起作用.)
(convert_tflite.py and convert.py (to pb) are also doesn't work.)
C:\ Users \ HANSUHO \ GitClone \ totflite> python save_model.py --weights ./data/clothes_yolov4-custom_final.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4-框架tflite
C:\Users\HANSUHO\GitClone\totflite>python save_model.py --weights ./data/clothes_yolov4-custom_final.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite
2020-09-22 16:29:38.010283: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-09-22 16:29:38.036873: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2020-09-22 16:29:44.344951: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-09-22 16:29:44.360513: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)
2020-09-22 16:29:44.379603: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-S931GV6
2020-09-22 16:29:44.393095: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-S931GV6
2020-09-22 16:29:44.402485: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-09-22 16:29:44.453636: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x26a5376f020 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-09-22 16:29:44.475123: 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 <module>
app.run(main)
File "C:\Users\HANSUHO\AppData\Local\Programs\Python\Python37\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\Users\HANSUHO\AppData\Local\Programs\Python\Python37\lib\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 "C:\Users\HANSUHO\GitClone\totflite\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 4565322 into shape (1024,512,3,3)
推荐答案
check this, it will solve the issue.
基本上,您正在克隆根存储库以运行此文件,同时使core/config.py中的路径保持不变.
Basically, you are cloning the root repo to run this file while having the paths in core/config.py unchanged.
这篇关于将yolov4权重转换为tflite时,如何解决重塑ValueError的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!