@@ -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