dusty-nv / jetson-inference

Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.
https://developer.nvidia.com/embedded/twodaystoademo
MIT License
7.74k stars 2.97k forks source link

errors.OnnxExporterError("Module onnx is not installed!") custom object detection #1618

Closed immnas closed 1 year ago

immnas commented 1 year ago

Hi,

I have used following docker image on JETSON xavier nx docker pull dustynv/jetson-inference:r35.2.1

I have used labelImg for creating my own annotated images data.

First create a label.txt file in the jetson-inference/python/training/detection/ssd directory Place the following sub-directories populated by the labelImage tool outputs in the same directory: Annotations, JPEGImages

Then enter the following command from the ssd directory: python vision/datasets/generate_vocdata.py ./labels.txt

Now you are ready to train with the mb1 pretrained network: python3 train_ssd.py --dataset-type=voc --model-dir=models/my-models-voc --data=./ --pretrained-ssd='models/mobilenet-v1-ssd-mp-0_675.pth' --batch-size=4 --num-epochs=50

Then convert your trained model to onyx (delete the labels.txt file in the ssd directory since the above step creates for you a labels.txt file in the directory specified by --input : python3 onnx_export.py --model-dir=models/my-models-voc

In the last command i am getting following error ====== Diagnostic Run torch.onnx.export version 2.0.0a0+ec3941ad.nv23.02 ======= verbose: False, log level: Level.ERROR ======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/torch/onnx/_internal/onnx_proto_utils.py", line 73, in _add_onnxscript_fn import onnx ModuleNotFoundError: No module named 'onnx'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "onnx_export.py", line 109, in torch.onnx.export(net, dummy_input, args.output, verbose=True, input_names=input_names, output_names=output_names) File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export _export( File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1605, in _export proto = onnx_proto_utils._add_onnxscript_fn( File "/usr/local/lib/python3.8/dist-packages/torch/onnx/_internal/onnx_proto_utils.py", line 75, in _add_onnxscript_fn raise errors.OnnxExporterError("Module onnx is not installed!") from e torch.onnx.errors.OnnxExporterError: Module onnx is not installed!

immnas commented 1 year ago

sorry this issue resolved after pip3 install onnx