WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.06k stars 4.13k forks source link

ONNX export failure: name 'gs' is not defined #1518

Open XY-cpp opened 1 year ago

XY-cpp commented 1 year ago

command

python export.py --weights yolov7-tiny.pt --batch-size=1 --img-size=1 --include-nms

output

Import onnx_graphsurgeon failure: No module named 'onnx_graphsurgeon'
Namespace(batch_size=1, conf_thres=0.25, device='cpu', dynamic=False, dynamic_batch=False, end2end=False, fp16=False, grid=False, img_size=[1, 1], include_nms=True, int8=False, iou_thres=0.45, max_wh=None, simplify=False, topk_all=100, weights='yolov7-tiny.pt')
YOLOR 🚀 v0.1-121-g2fdc7f1 torch 1.11.0+cu113 CPU

Fusing layers... 
Model Summary: 200 layers, 6219709 parameters, 6219709 gradients
WARNING: --img-size 1 must be multiple of max stride 32, updating to 32
WARNING: --img-size 1 must be multiple of max stride 32, updating to 32

Starting TorchScript export with torch 1.11.0+cu113...
TorchScript export success, saved as yolov7-tiny.torchscript.pt

Starting CoreML export with coremltools 4.0...
Tuple detected at graph output. This will be flattened in the converted model.
Converting graph.
Adding op '1' of type const
CoreML export failure: Unsupported numpy type: float32

Starting TorchScript-Lite export with torch 1.11.0+cu113...
TorchScript-Lite export success, saved as yolov7-tiny.torchscript.ptl

Starting ONNX export with onnx 1.12.0...
ONNX export success, saved as yolov7-tiny.onnx
Registering NMS plugin for ONNX...
ONNX export failure: name 'gs' is not defined

Export complete (5.06s). Visualize with https://github.com/lutzroeder/netron.

if I close the --include-nms option, things will go right

jiugary commented 1 year ago

Try install gs

pip install nvidia-pyindex pip install onnx_graphsurgeon

sumitsrivastava069 commented 1 year ago

Not working for me

Egorundel commented 11 months ago

@sumitsrivastava069

pip install onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com

abdulghani91 commented 1 week ago

@jiugary

Thank you. It works fine for me.

ONNX export success, saved as ./My_best.onnx Registering NMS plugin for ONNX... ONNX graph created successfully Created NMS plugin 'EfficientNMS_TRT' with attributes: {'plugin_version': '1', 'background_class': -1, 'max_output_boxes': 100, 'score_threshold': 0.25, 'iou_threshold': 0.45, 'score_activation': False, 'box_coding': 0} Saved ONNX model to ./My_best.onnx