Skip to content

Commit e62c01f

Browse files
daquexianZwwWayne
authored andcommitted
Upgrade onnxsim to at least 0.4.0 (#8383)
* Upgrade onnxsim to 0.4.0 * Update pytorch2onnx.py * Update pytorch2onnx.py
1 parent f8bbba2 commit e62c01f

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

tools/deployment/pytorch2onnx.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,17 @@ def pytorch2onnx(model,
101101

102102
model.forward = origin_forward
103103

104-
# get the custom op path
105-
ort_custom_op_path = ''
106-
try:
107-
from mmcv.ops import get_onnxruntime_op_path
108-
ort_custom_op_path = get_onnxruntime_op_path()
109-
except (ImportError, ModuleNotFoundError):
110-
warnings.warn('If input model has custom op from mmcv, \
111-
you may have to build mmcv with ONNXRuntime from source.')
112-
113104
if do_simplify:
114105
import onnxsim
115106

116107
from mmdet import digit_version
117108

118-
min_required_version = '0.3.0'
109+
min_required_version = '0.4.0'
119110
assert digit_version(onnxsim.__version__) >= digit_version(
120111
min_required_version
121-
), f'Requires to install onnx-simplify>={min_required_version}'
112+
), f'Requires to install onnxsim>={min_required_version}'
122113

123-
input_dic = {'input': img_list[0].detach().cpu().numpy()}
124-
model_opt, check_ok = onnxsim.simplify(
125-
output_file,
126-
input_data=input_dic,
127-
custom_lib=ort_custom_op_path,
128-
dynamic_input_shape=dynamic_export)
114+
model_opt, check_ok = onnxsim.simplify(output_file)
129115
if check_ok:
130116
onnx.save(model_opt, output_file)
131117
print(f'Successfully simplified ONNX model: {output_file}')

0 commit comments

Comments
 (0)