MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
507 stars 41 forks source link

NonMaxSuppression not implemented yet #23

Closed Tsao666 closed 1 year ago

Tsao666 commented 1 year ago

Hi,

I'm trying to convert YoloV7-tiny.onnx to keras by using cli command below python converter.py --weights "yolov7-tiny.onnx" --formats "keras"

but raise exception:

Traceback (most recent call last):
  File "converter.py", line 73, in <module>
    run()
  File "converter.py", line 57, in run
    onnx_converter(
  File "converter.py", line 19, in onnx_converter
    keras_model = keras_builder(model_proto, input_node_names, output_node_names, native_groupconv)
  File "/outerDisk1/onnx2tflite/utils/builder.py", line 101, in keras_builder
    raise KeyError(f"{op_name} not implemented yet")
KeyError: 'NonMaxSuppression not implemented yet'

anyone know how to fix it?

MPolaris commented 1 year ago

NonMaxSuppression is a dynamic operator, and maybe not suitable for tflite. You should not add "--include-nms" in export yolov7 onnx, remove it and try again.

Tsao666 commented 1 year ago

I export onnx by this command: python export.py --weights weights/yolov7-tiny.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 320 320 --max-wh 320

but still not work. any suggestion?

MPolaris commented 1 year ago

I'm run this command, and successed.

python export.py --weights ./yolov7-tiny.pt --grid --simplify

My yolov7 version is latest, maybe you should check cafefully. The convert command:

python converter.py --weights "./models/yolov7-tiny.onnx" --formats "keras"
Tsao666 commented 1 year ago

I found that NMS operator would added when parameter --end2end was set, remove it will be ok, thanks!