Skip to content

ONNX support #38

Open
Open
@SakshamSinha

Description

This repository is a great work. Thank you for your work.

I was wondering if you can add ONNX support to your model. Currently, your model gives following error while exporting to ONNX. I am using resnet50-SSD with VOC dataset format.

Change made to demo.py at line 148 are-
dummy_input = torch.randn(1, 3, 300, 300)
output_names = ["outputs"]
torch.onnx.export(net, dummy_input, "resnet50ssd.onnx", verbose=True, output_names=output_names)

Command used to run demo.py-
python demo.py --cfg ./configs/ssd_res50_voc.yaml --weights ./weights/ssd_res50_epoch_50_300.pth --images ./images --save_folder ./output

Error-
Traceback (most recent call last):
File "demo.py", line 174, in
main()
File "demo.py", line 140, in main
torch.onnx.export(net, dummy_input, "resnet50ssd.onnx", verbose=True, output_names=output_names)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/onnx/init.py", line 132, in export
strip_doc_string, dynamic_axes)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/onnx/utils.py", line 64, in export
example_outputs=example_outputs, strip_doc_string=strip_doc_string, dynamic_axes=dynamic_axes)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/onnx/utils.py", line 329, in _export
_retain_param_name, do_constant_folding)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/onnx/utils.py", line 213, in _model_to_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/onnx/utils.py", line 171, in _trace_and_get_graph_from_model
trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/jit/init.py", line 256, in get_trace_graph
return LegacyTracedModule(f, _force_outplace, return_inputs)(*args, **kwargs)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/testuser/venvs/refpy368shared/lib/python3.6/site-packages/torch/jit/init.py", line 325, in forward
torch._C._tracer_exit(tuple(out_vars))
RuntimeError: output of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions