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 when i convert tensorflow weight to tflite #263

Open falahgs opened 3 years ago

falahgs commented 3 years ago

Hi Guys i got error when i run this command

Convert to tflite in yolov4 model in colab google drive

thanks for help

!python convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416.tflite

I1111 09:07:48.403536 139914793011072 convert_tflite.py:48] model saved to: ./checkpoints/yolov4-416.tflite I1111 09:07:48.618587 139914793011072 convert_tflite.py:53] tflite model loaded [{'name': 'input_1', 'index': 0, 'shape': array([ 1, 416, 416, 3], dtype=int32), 'shape_signature': array([ -1, 416, 416, 3], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}] [{'name': 'Identity', 'index': 936, 'shape': array([1, 1, 1], dtype=int32), 'shape_signature': array([-1, -1, -1], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}] Traceback (most recent call last): File "convert_tflite.py", line 76, in app.run(main) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run _run_main(main, args) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "convert_tflite.py", line 72, in main demo() File "convert_tflite.py", line 66, in demo output_data = [interpreter.get_tensor(output_details[i]['index']) for i in range(len(output_details))] File "convert_tflite.py", line 66, in output_data = [interpreter.get_tensor(output_details[i]['index']) for i in range(len(output_details))] File "/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/interpreter.py", line 459, in get_tensor return self._interpreter.GetTensor(tensor_index) ValueError: Invalid tensor size.

erhazet commented 3 years ago

I have the same problem. Did you solve the error?

kaunghtetsan275 commented 2 years ago

Did you save your weights in model file first? Have you tried this solution?