Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit bc42c40

Browse files
committed
Update _tools.py
1 parent eaad4fd commit bc42c40

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

tfhub/_tools.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def convert_model(model_name, output_path, opset=13, tag=None, verbose=True):
139139
large_model = ext == ".zip"
140140
if not os.path.exists(output_path):
141141
begin = datetime.datetime.now()
142-
cmdl = ['-m', 'tf2onnx.convert', '--saved-model',
142+
cmdl = ['python', '-m', 'tf2onnx.convert', '--saved-model',
143143
'"%s"' % os.path.abspath(model_name).replace("\\", "/"),
144144
'--output', '"%s"' % os.path.abspath(output_path).replace("\\", "/"),
145145
'--opset', "%d" % opset]
@@ -148,17 +148,20 @@ def convert_model(model_name, output_path, opset=13, tag=None, verbose=True):
148148
if large_model:
149149
cmdl.append('--large_model')
150150
if verbose:
151-
print("cmd: python %s" % " ".join(cmdl))
151+
print("cmd: %s" % " ".join(cmdl))
152+
152153
pproc = subprocess.Popen(
153-
cmdl, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
154-
executable=sys.executable.replace("pythonw", "python"))
155-
stdoutdata, stderrdata = pproc.communicate()
156-
if verbose:
157-
print('--OUT--')
158-
print(stdoutdata.decode('ascii'))
159-
print('--ERR--')
160-
print(stderrdata.decode('ascii'))
161-
print("Duration %r." % (datetime.datetime.now() - begin))
154+
[c.strip('"') for c in cmdl], shell=False,
155+
stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
156+
executable=None)
157+
with pproc:
158+
stdoutdata, stderrdata = pproc.communicate()
159+
if verbose:
160+
print('--OUT--')
161+
print(stdoutdata.decode('ascii'))
162+
print('--ERR--')
163+
print(stderrdata.decode('ascii'))
164+
print("Duration %r." % (datetime.datetime.now() - begin))
162165

163166

164167
def convert_tflite(model_name, output_path, opset=13, verbose=True):

0 commit comments

Comments
 (0)