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