MNN/tools/script/testResource.py

34 lines
925 B
Python
Raw Permalink Normal View History

2019-04-17 10:49:11 +08:00
#!/usr/bin/python
import sys
import os
from subprocess import Popen, PIPE, STDOUT
2019-04-17 10:49:11 +08:00
root_dir = sys.argv[1]
2023-08-30 19:29:06 +08:00
print('root: ', root_dir)
2019-04-17 10:49:11 +08:00
forwardType = " 0 "
if len(sys.argv) > 2:
forwardType = ' ' + sys.argv[2] + ' '
2023-08-30 19:21:51 +08:00
2019-04-17 10:49:11 +08:00
thredhold = ' 0.001 '
if len(sys.argv) > 3:
thredhold = ' ' + sys.argv[3] + ' '
2020-11-05 16:41:56 +08:00
def run_cmd(args):
process = Popen(args, stdout=PIPE, stderr=PIPE, universal_newlines=True)
stdout, stderr = process.communicate()
return stdout, stderr
2020-11-05 16:41:56 +08:00
2019-04-17 10:49:11 +08:00
for name in os.listdir(root_dir):
if name.startswith("."):
continue
modelName = os.path.join(root_dir, name, 'temp.bin')
inputName = os.path.join(root_dir, name, 'input_0.txt')
outputName = os.path.join(root_dir, name, 'output.txt')
print(modelName)
2019-04-17 10:49:11 +08:00
stdout, stderr = run_cmd(['./testModel.out', modelName, inputName, outputName, forwardType, thredhold])
print(stdout)
if stderr:
print("Error:", stderr)