Skip to content

Commit

Permalink
ONNX export in .train() mode fix (ultralytics#3362)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaofWang authored May 27, 2021
1 parent 5fc1438 commit c0d12e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
print(f'{prefix} starting export with onnx {onnx.__version__}...')
f = opt.weights.replace('.pt', '.onnx') # filename
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,
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)

Expand Down

0 comments on commit c0d12e8

Please sign in to comment.