Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output_names argument for ONNX export with dynamic axes #3456

Merged
merged 3 commits into from
Jun 4, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@
torch.onnx.export(model, img, f, verbose=False, opset_version=opt.opset_version, input_names=['images'],
training=torch.onnx.TrainingMode.TRAINING if opt.train else torch.onnx.TrainingMode.EVAL,
do_constant_folding=not opt.train,
output_names=['output0', 'output1', 'output2', 'output3'],
dynamic_axes={'images': {0: 'batch', 2: 'height', 3: 'width'}, # size(1,3,640,640)
'output': {0: 'batch', 2: 'y', 3: 'x'}} if opt.dynamic else None)
'output0': {0: 'batch'}, 'output1': {0: 'batch'},
'output2': {0: 'batch'}, 'output3': {0: 'batch'}} if opt.dynamic else None)

# Checks
model_onnx = onnx.load(f) # load onnx model
Expand Down