|
|
@@ -28,6 +28,9 @@ if __name__ == '__main__': |
|
|
|
attempt_download(opt.weights) |
|
|
|
model = torch.load(opt.weights, map_location=torch.device('cpu'))['model'].float() |
|
|
|
model.eval() |
|
|
|
model.fuse() |
|
|
|
|
|
|
|
# Update model |
|
|
|
model.model[-1].export = True # set Detect() layer export=True |
|
|
|
y = model(img) # dry run |
|
|
|
|
|
|
@@ -47,7 +50,6 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
print('\nStarting ONNX export with onnx %s...' % onnx.__version__) |
|
|
|
f = opt.weights.replace('.pt', '.onnx') # filename |
|
|
|
model.fuse() # only for ONNX |
|
|
|
torch.onnx.export(model, img, f, verbose=False, opset_version=12, input_names=['images'], |
|
|
|
output_names=['classes', 'boxes'] if y is None else ['output']) |
|
|
|
|