@@ -211,11 +211,7 @@ def main():
211
211
mo_executable = shutil .which ('mo' )
212
212
213
213
if mo_executable :
214
- mo_cmd_prefix = [str (args .python ), '--' , mo_executable ]
215
- mo_package_path , stderr = _common .get_package_path (args .python , 'mo' )
216
- if mo_package_path is None :
217
- sys .exit ('Unable to load Model Optimizer. Errors occurred: {}' .format (stderr ))
218
- mo_dir = mo_package_path .parent
214
+ mo_path = Path (mo_executable )
219
215
else :
220
216
try :
221
217
mo_path = Path (os .environ ['INTEL_OPENVINO_DIR' ]) / 'tools/model_optimizer/mo.py'
@@ -224,9 +220,15 @@ def main():
224
220
+ 'Use --mo or run setupvars.sh/setupvars.bat from the OpenVINO toolkit.' )
225
221
226
222
if mo_path is not None :
227
- # run MO as a script
223
+ mo_path = mo_path . resolve ()
228
224
mo_cmd_prefix = [str (args .python ), '--' , str (mo_path )]
229
- mo_dir = mo_path .parent
225
+ if str (mo_path ).lower ().endswith ('.py' ):
226
+ mo_dir = mo_path .parent
227
+ else :
228
+ mo_package_path , stderr = _common .get_package_path (args .python , 'mo' )
229
+ if mo_package_path is None :
230
+ sys .exit ('Unable to load Model Optimizer. Errors occurred: {}' .format (stderr ))
231
+ mo_dir = mo_package_path .parent
230
232
231
233
output_dir = args .download_dir if args .output_dir is None else args .output_dir
232
234
0 commit comments