yjh0410 / RT-ODLab

YOLO Tutorial
MIT License
156 stars 32 forks source link

'--nms_class_agnostic' must add in export_onnx.py #9

Closed huihui308 closed 1 year ago

huihui308 commented 1 year ago

I found there is a error if it did not add '--nms_class_agnostic' in export_onnx.py.

2023-10-13 10:37:51.043 | INFO     | __main__:main:76 - args value: Namespace(batch_size=1, conf_thresh=0.1, dynamic=True, exp_file=None, experiment_name=None, fuse_conv_bn=False, img_size=640, input='images', model='rtcdet_p', nms_class_agnostic=False, nms_thresh=0.5, no_onnxsim=False, num_classes=2, opset=11, opts=[], output='output', save_dir='../weights/onnx/', topk=100, weight='./../weights/plate/rtcdet_p/rtcdet_p_bs256_best_2023-09-27_06-09-12.pth')
==============================
Model: RTCDET_P ...
==============================
Build RTCDET_P ...
==============================
Neck: sppf
--------------------------------------
Best model infor:
Epoch: 299
mAP: 56.5
--------------------------------------
Finished loading model!
2023-10-13 10:37:51.176 | INFO     | __main__:main:92 - loading checkpoint done.
export_onnx.py:101: FutureWarning: 'torch.onnx._export' is deprecated in version 1.12.0 and will be removed in 2.0. Please use `torch.onnx.export` instead.
  torch.onnx._export(
/home/david/.local/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
============= Diagnostic Run torch.onnx.export version 2.0.1+cu118 =============
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

2023-10-13 10:37:53.798 | INFO     | __main__:main:112 - generated onnx model named ../weights/onnx/11/rtcdet_p.onnx
WARNING: The argument `dynamic_input_shape=True` is not needed any more, onnxsim can now support dynamic input shapes natively, please refer to the latest documentation. An error will be
raised in the future.
WARNING: The argument `input_shapes` is deprecated. Please use `overwrite_input_shapes` and/or `test_input_shapes` instead. An error will be raised in the future.
2023-10-13 10:37:54.552 | INFO     | __main__:main:133 - generated simplified onnx model named ../weights/onnx/11/onnxsim/rtcdet_p.onnx
(paper) david@david-ubuntu20:tools$ 
(paper) david@david-ubuntu20:tools$ 
(paper) david@david-ubuntu20:tools$ 
(paper) david@david-ubuntu20:tools$ python3 export_onnx.py --model=rtcdet_p --num_classes=2 --dynamic --weight=./../weights/plate/rtcdet_p/rtcdet_p_bs256_best_2023-09-27_06-09-12.pth
2023-10-13 10:38:33.812 | INFO     | __main__:main:75 - args value: Namespace(batch_size=1, conf_thresh=0.1, dynamic=True, exp_file=None, experiment_name=None, fuse_conv_bn=False, img_size=640, input='images', model='rtcdet_p', nms_thresh=0.5, no_onnxsim=False, num_classes=2, opset=11, opts=[], output='output', save_dir='../weights/onnx/', topk=100, weight='./../weights/plate/rtcdet_p/rtcdet_p_bs256_best_2023-09-27_06-09-12.pth')
==============================
Model: RTCDET_P ...
==============================
Build RTCDET_P ...
2023-10-13 10:38:33.812 | ERROR    | __main__:<module>:136 - An error has been caught in function '<module>', process 'MainProcess' (158930), thread 'MainThread' (140610050365248):
Traceback (most recent call last):

> File "export_onnx.py", line 136, in <module>
    main()
    └ <function main at 0x7fe17b4addc0>

  File "export_onnx.py", line 82, in main
    model = build_model(args, model_cfg, device, args.num_classes, False, deploy=True)
            │           │     │          │       │    └ 2
            │           │     │          │       └ Namespace(batch_size=1, conf_thresh=0.1, dynamic=True, exp_file=None, experiment_name=None, fuse_conv_bn=False, img_size=640,...
            │           │     │          └ device(type='cpu')
            │           │     └ {'backbone': 'elannet', 'pretrained': True, 'bk_act': 'silu', 'bk_norm': 'BN', 'bk_depthwise': True, 'width': 0.25, 'depth': ...
            │           └ Namespace(batch_size=1, conf_thresh=0.1, dynamic=True, exp_file=None, experiment_name=None, fuse_conv_bn=False, img_size=640,...
            └ <function build_model at 0x7fe19301d790>

  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/tools/../models/detectors/__init__.py", line 56, in build_model
    model, criterion = build_rtcdet(
                       └ <function build_rtcdet at 0x7fe190a9d5e0>

  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/tools/../models/detectors/rtcdet/build.py", line 26, in build_rtcdet
    nms_class_agnostic=args.nms_class_agnostic
                       └ Namespace(batch_size=1, conf_thresh=0.1, dynamic=True, exp_file=None, experiment_name=None, fuse_conv_bn=False, img_size=640,...

AttributeError: 'Namespace' object has no attribute 'nms_class_agnostic'
yjh0410 commented 1 year ago

@huihui308 Thanks for your reminder, I have fixed this bug just now. You could try again~