Skip to content

Commit b5c91b2

Browse files
authored
Merge pull request #2944 from jkamelin/jk/fix_mo_dir
model_tools: fix mo location when entry point passed
2 parents ffdae72 + c547d3e commit b5c91b2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tools/model_tools/src/openvino/model_zoo/omz_converter.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,7 @@ def main():
211211
mo_executable = shutil.which('mo')
212212

213213
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)
219215
else:
220216
try:
221217
mo_path = Path(os.environ['INTEL_OPENVINO_DIR']) / 'tools/model_optimizer/mo.py'
@@ -224,9 +220,15 @@ def main():
224220
+ 'Use --mo or run setupvars.sh/setupvars.bat from the OpenVINO toolkit.')
225221

226222
if mo_path is not None:
227-
# run MO as a script
223+
mo_path = mo_path.resolve()
228224
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
230232

231233
output_dir = args.download_dir if args.output_dir is None else args.output_dir
232234

0 commit comments

Comments
 (0)