Closed glenn-jocher closed 2 years ago
Sorry, forgot to attach my ONNX model earlier. I've attached it here:
Model opens correctly in Netron, it is the official YOLOv5 v6.2 nano model exported to ONNX, not a custom trained model.
Sorry, forgot to attach my ONNX model earlier. I've attached it here:
Model opens correctly in Netron, it is the official YOLOv5 v6.2 nano model exported to ONNX, not a custom trained model.
![]()
Thanks for your issue, I have tested the onnx model and successed.
The success key is you should make need_simplify = True
.
Your error maybe caused by onnx-simplifier, the step of simplify is very import for convertion.
My code is lastest, and requirments' version as follow:
python 3.8
tensorflow 2.8.0
onnx 1.11.0
onnx-simplifier 0.3.8 or 0.4.8
@MPolaris awesome, thanks for the help! Your solution works. Code to reproduce correct export:
!git clone https://github.com/ultralytics/yolov5
!git clone https://github.com/MPolaris/onnx2tflite
%pip install -qr yolov5/requirements.txt # install
!python yolov5/export.py --weights ./yolov5n.pt --include onnx --simplify
%cd onnx2tflite
from converter import onnx_converter
onnx_converter(
onnx_model_path = "../yolov5n.onnx",
need_simplify = True,
output_path = "./",
target_formats = ['tflite'], # or ['keras'], ['keras', 'tflite']
weight_quant = False,
int8_model = False,
int8_mean = None,
int8_std = None,
image_root = None
)
@glenn-jocher I'm glad to help you and please star this repository, thanks for your issue again.
Hi! I'm getting an error in Google Colab on attempting to convert an ONNX model to TFLite using this tool. I've attached the ONNX model causing the bug, and also provided full code to reproduce below. I tried YOLOv5n models exported to ONNX using opset 11, 12 and 13, and saw problems in all of them.
Code to Reproduce
Result
@ayushExel