提交 8b739bdc 编写于 作者: L liuqi

Fix converte vgg caffe model bug.

上级 b1ce72f9
import argparse import argparse
import sys import sys
import os
import os.path
import numpy as np import numpy as np
import re import re
from scipy import spatial
# Validation Flow: # Validation Flow:
# 1. Generate input data # 1. Generate input data
......
...@@ -10,7 +10,7 @@ if [ ${DSP_MODE} ]; then ...@@ -10,7 +10,7 @@ if [ ${DSP_MODE} ]; then
DSP_MODE_FLAG="--dsp_mode=${DSP_MODE}" DSP_MODE_FLAG="--dsp_mode=${DSP_MODE}"
fi fi
bazel-bin/lib/python/tools/converter --platform=${PLATFORM} \ PYTHONUNBUFFERED=1 bazel-bin/lib/python/tools/converter --platform=${PLATFORM} \
--model_file=${MODEL_FILE_PATH} \ --model_file=${MODEL_FILE_PATH} \
--weight_file=${WEIGHT_FILE_PATH} \ --weight_file=${WEIGHT_FILE_PATH} \
--model_checksum=${MODEL_SHA256_CHECKSUM} \ --model_checksum=${MODEL_SHA256_CHECKSUM} \
......
...@@ -17,6 +17,29 @@ import yaml ...@@ -17,6 +17,29 @@ import yaml
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
def run_command_real_time(command):
print("Run command: {}".format(command))
process = subprocess.Popen(
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
std_err = process.stderr.readline()
if std_err == '' and process.poll() is not None:
break
if std_err:
print std_err.strip()
while True:
std_out = process.stdout.readline()
if std_out == '' and process.poll() is not None:
break
if std_out:
print std_out.strip()
ret_code = process.poll()
if ret_code != 0:
raise Exception("Exit not 0 from bash with code: {}, command: {}".format(
ret_code, command))
def run_command(command): def run_command(command):
print("Run command: {}".format(command)) print("Run command: {}".format(command))
result = subprocess.Popen( result = subprocess.Popen(
...@@ -71,7 +94,7 @@ def generate_random_input(model_output_dir): ...@@ -71,7 +94,7 @@ def generate_random_input(model_output_dir):
def generate_model_code(): def generate_model_code():
command = "bash tools/generate_model_code.sh" command = "bash tools/generate_model_code.sh"
run_command(command) run_command_real_time(command)
def build_mace_run(production_mode, model_output_dir, hexagon_mode): def build_mace_run(production_mode, model_output_dir, hexagon_mode):
......
...@@ -24,7 +24,7 @@ if [ "$GENERATE_DATA_OR_NOT" = 1 ]; then ...@@ -24,7 +24,7 @@ if [ "$GENERATE_DATA_OR_NOT" = 1 ]; then
FORMATTED_NAME=$(sed s/[^[:alnum:]]/_/g <<< ${NAME}) FORMATTED_NAME=$(sed s/[^[:alnum:]]/_/g <<< ${NAME})
rm -rf ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME}_${FORMATTED_NAME} rm -rf ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME}_${FORMATTED_NAME}
done done
python tools/generate_data.py --input_node=${INPUT_NODES} \ python -u tools/generate_data.py --input_node=${INPUT_NODES} \
--input_file=${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \ --input_file=${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \
--input_shape="${INPUT_SHAPES}" || exit 1 --input_shape="${INPUT_SHAPES}" || exit 1
exit 0 exit 0
...@@ -38,7 +38,7 @@ if [ "$PLATFORM" == "tensorflow" ];then ...@@ -38,7 +38,7 @@ if [ "$PLATFORM" == "tensorflow" ];then
adb pull ${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME}_${FORMATTED_NAME} ${MODEL_OUTPUT_DIR} > /dev/null adb pull ${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME}_${FORMATTED_NAME} ${MODEL_OUTPUT_DIR} > /dev/null
done done
fi fi
python tools/validate.py --platform=tensorflow \ python -u tools/validate.py --platform=tensorflow \
--model_file ${MODEL_FILE_PATH} \ --model_file ${MODEL_FILE_PATH} \
--input_file ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \ --input_file ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \
--mace_out_file ${MODEL_OUTPUT_DIR}/${OUTPUT_FILE_NAME} \ --mace_out_file ${MODEL_OUTPUT_DIR}/${OUTPUT_FILE_NAME} \
...@@ -90,7 +90,8 @@ elif [ "$PLATFORM" == "caffe" ];then ...@@ -90,7 +90,8 @@ elif [ "$PLATFORM" == "caffe" ];then
docker cp tools/validate.py ${CONTAINER_NAME}:/mace docker cp tools/validate.py ${CONTAINER_NAME}:/mace
docker cp ${MODEL_FILE_PATH} ${CONTAINER_NAME}:/mace docker cp ${MODEL_FILE_PATH} ${CONTAINER_NAME}:/mace
docker cp ${WEIGHT_FILE_PATH} ${CONTAINER_NAME}:/mace docker cp ${WEIGHT_FILE_PATH} ${CONTAINER_NAME}:/mace
docker exec -it ${CONTAINER_NAME} python /mace/validate.py --platform=caffe \ docker exec -it ${CONTAINER_NAME} python -u /mace/validate.py \
--platform=caffe \
--model_file /mace/${MODEL_FILE_NAME} \ --model_file /mace/${MODEL_FILE_NAME} \
--weight_file /mace/${WEIGHT_FILE_NAME} \ --weight_file /mace/${WEIGHT_FILE_NAME} \
--input_file /mace/${INPUT_FILE_NAME} \ --input_file /mace/${INPUT_FILE_NAME} \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册