提交 c9d0119c 编写于 作者: Y yejianwu

support http:// and https:// in model_file_path

上级 0e66eb1c
......@@ -7,7 +7,7 @@ embed_model_data: 1
vlog_level: 0
models:
preview_net:
model_file_path: path/to/model64.pb
model_file_path: path/to/model64.pb # also support http:// and https://
input_node: input_node
output_node: output_node
input_shape: 1,64,64,3
......
......@@ -7,10 +7,12 @@
# --mode=all
import argparse
import base64
import os
import shutil
import subprocess
import sys
import urllib
import yaml
from ConfigParser import ConfigParser
......@@ -206,8 +208,8 @@ def main(unused_args):
for key in model_config:
os.environ[key.upper()] = str(model_config[key])
model_output_dir = FLAGS.output_dir + "/" + target_abi + "/" + os.path.splitext(
model_config["model_file_path"])[0]
model_output_dir = FLAGS.output_dir + "/" + target_abi + "/" + model_name + "/" + base64.b16encode(
model_config["model_file_path"])
model_output_dirs.append(model_output_dir)
if FLAGS.mode == "build" or FLAGS.mode == "all":
......@@ -216,6 +218,12 @@ def main(unused_args):
os.makedirs(model_output_dir)
clear_env()
# Support http:// and https://
if model_config["model_file_path"].startswith(
"http://") or model_config["model_file_path"].startswith("https://"):
os.environ["MODEL_FILE_PATH"] = model_output_dir + "/model.pb"
urllib.urlretrieve(model_config["model_file_path"], os.environ["MODEL_FILE_PATH"])
if FLAGS.mode == "build" or FLAGS.mode == "run" or FLAGS.mode == "validate" or FLAGS.mode == "all":
generate_random_input(model_output_dir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册