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

ValueError: cannot reshape array of size 92951 into shape (256,128,3,3) #467

Open jjeongmin0308 opened 1 year ago

jjeongmin0308 commented 1 year ago

!python save_model.py --weights /content/tensorflow-yolov4-tflite/data/yolov4-custom_last.weights --output ./checkpoints/custom-416 --input_size 416 --model yolov4 --framework tflite 2022-09-17 18:04:49.809104: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 2022-09-17 18:04:51.493961: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1 2022-09-17 18:04:51.503223: E tensorflow/stream_executor/cuda/cuda_driver.cc:314] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected 2022-09-17 18:04:51.503344: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (79cfa2660112): /proc/driver/nvidia/version does not exist 2022-09-17 18:04:51.504271: 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 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-09-17 18:04:51.512390: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2199995000 Hz 2022-09-17 18:04:51.512654: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x20e8f40 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2022-09-17 18:04:51.512699: 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 "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 308, in run _run_main(main, args) File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 254, 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 "/content/tensorflow-yolov4-tflite/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 92951 into shape (256,128,3,3)

I made the following efforts to correct this error.

https://github.com/hunglc007/tensorflow-yolov4-tflite/issues/396#issuecomment-927229582

https://github.com/hunglc007/tensorflow-yolov4-tflite/issues/396#issuecomment-927316932

However, the error has not been corrected.

I also checked that there is no empty line at the bottom of the file.

reno41317 commented 1 year ago

I use these code to replace that one,and it worked. However the weight didn't work as I thought. There is no boundingbox in the ouput of image. I don't know how is going on. Hope to help you.

    conv_weights = np.ones(np.product(conv_shape))
    conv_weights = conv_weights.reshape(conv_shape)
    conv_weights = np.transpose(conv_weights, (2, 3, 1, 0))
    #conv_weights = conv_shape.reshape(conv_shape).transpose([2, 3, 1, 0])
t109598032 commented 10 months ago

change core/config.py line 14: __C.YOLO.CLASSES = to path of your custom obj.names