@@ -112,33 +112,49 @@ def convert(reporter, model, output_dir, args, mo_props, requested_precisions):
112
112
return False
113
113
model_format = 'onnx'
114
114
115
- expanded_mo_args = [
115
+ custom_mo_args = [
116
116
string .Template (arg ).substitute (template_variables )
117
117
for arg in model .mo_args ]
118
+
119
+ expanded_mo_args = []
120
+ input_model = ''
121
+ for arg in custom_mo_args :
122
+ if 'input_model' in arg :
123
+ input_model = arg .split ('=' )[- 1 ]
124
+ if 'output' in arg :
125
+ expanded_mo_args .append (arg )
118
126
119
127
for model_precision in sorted (model_precisions ):
120
128
data_type = model_precision .split ('-' )[0 ]
121
129
layout_string = ',' .join (
122
130
'{}({})' .format (input .name , input .layout ) for input in model .input_info if input .layout
123
131
)
124
- shape_string = ',' .join (str (input .shape ) for input in model .input_info if input .shape )
125
-
126
- if layout_string :
127
- expanded_mo_args .append ('--layout={}' .format (layout_string ))
132
+ shape_string = ',' .join (str (input .shape ).replace (" " , "" ) for input in model .input_info if input .shape )
133
+
134
+ # input_arg = ''
135
+ # for input in model.input_info:
136
+ # if input_arg:
137
+ # input_arg += ','
138
+ # input_arg += f'{input.name}{str(input.shape).replace(" ", "")}'
139
+
140
+ # if layout_string:
141
+ # expanded_mo_args.append('--layout={}'.format(layout_string))
128
142
if shape_string :
129
- expanded_mo_args .append ('--input_shape ={}' .format (shape_string ))
143
+ expanded_mo_args .append ('--input ={}' .format (shape_string ))
130
144
if data_type == "FP16" :
131
145
expanded_mo_args .append ("--compress_to_fp16=True" )
132
146
else :
133
147
expanded_mo_args .append ("--compress_to_fp16=False" )
134
148
135
149
mo_output_dir = output_dir / model .subdirectory / model_precision
136
150
mo_cmd = [* mo_props .cmd_prefix ,
137
- '--framework={}' .format (model_format ),
138
- f'--output_dir={ mo_output_dir } ' ,
139
- '--model_name={}' .format (model .name ),
140
- '--input={}' .format (',' .join (input .name for input in model .input_info )),
141
- * expanded_mo_args , * mo_props .extra_args ]
151
+ input_model ,
152
+ f'--output_model={ str (Path (mo_output_dir , model .name + ".xml" ))} ' ,
153
+ # '--framework={}'.format(model_format),
154
+ # f'--output={mo_output_dir}',
155
+ # '--model_name={}'.format(model.name),
156
+ # f'--input=\"{input_arg}\"',
157
+ * expanded_mo_args ]
142
158
143
159
reporter .print_section_heading ('{}Converting {} to IR ({})' ,
144
160
'(DRY RUN) ' if args .dry_run else '' , model .name , model_precision )
@@ -271,15 +287,15 @@ def converter(argv):
271
287
mo_path = args .mo
272
288
273
289
if mo_path is None :
274
- mo_executable = shutil .which ('mo ' )
290
+ mo_executable = shutil .which ('ovc ' )
275
291
276
292
if mo_executable :
277
293
mo_path = Path (mo_executable )
278
294
else :
279
295
try :
280
- mo_path = Path (os .environ ['INTEL_OPENVINO_DIR' ]) / 'tools/mo/openvino/tools/mo/mo.py'
281
- if not mo_path .exists ():
282
- mo_path = Path (os .environ ['INTEL_OPENVINO_DIR' ]) / 'tools/model_optimizer/mo .py'
296
+ # mo_path = Path(os.environ['INTEL_OPENVINO_DIR']) / 'tools/mo/openvino/tools/mo/mo.py'
297
+ # if not mo_path.exists():
298
+ mo_path = Path (os .environ ['INTEL_OPENVINO_DIR' ]) / 'tools/ovc/ovc .py'
283
299
except KeyError :
284
300
sys .exit ('Unable to locate Model Optimizer. '
285
301
+ 'Use --mo or run setupvars.sh/setupvars.bat from the OpenVINO toolkit.' )
@@ -291,11 +307,11 @@ def converter(argv):
291
307
if str (mo_path ).lower ().endswith ('.py' ):
292
308
mo_dir = mo_path .parent
293
309
else :
294
- mo_package_path , stderr = _common .get_package_path (args .python , 'openvino.tools.mo ' )
310
+ mo_package_path , stderr = _common .get_package_path (args .python , 'openvino.tools.ovc ' )
295
311
mo_dir = mo_package_path
296
312
297
313
if mo_package_path is None :
298
- mo_package_path , stderr = _common .get_package_path (args .python , 'mo ' )
314
+ mo_package_path , stderr = _common .get_package_path (args .python , 'ovc ' )
299
315
if mo_package_path is None :
300
316
sys .exit ('Unable to load Model Optimizer. Errors occurred: {}' .format (stderr ))
301
317
mo_dir = mo_package_path .parent
0 commit comments