diff --git a/generate_data.py b/generate_data.py index 24ac6c23e9bc1605f9137dcbd06c0ebbddb4c4bf..8feff8230dc7892d0a5e97d6ef7d7354989f2c9b 100644 --- a/generate_data.py +++ b/generate_data.py @@ -1,10 +1,7 @@ import argparse import sys -import os -import os.path import numpy as np import re -from scipy import spatial # Validation Flow: # 1. Generate input data diff --git a/generate_model_code.sh b/generate_model_code.sh index d893e29f4997547c2c966c3a3a5cc9325352a77c..424f8df6c7e8d7c1a4a5fff7ca0a089b836b7d65 100644 --- a/generate_model_code.sh +++ b/generate_model_code.sh @@ -10,7 +10,7 @@ if [ ${DSP_MODE} ]; then DSP_MODE_FLAG="--dsp_mode=${DSP_MODE}" fi -bazel-bin/lib/python/tools/converter --platform=${PLATFORM} \ +PYTHONUNBUFFERED=1 bazel-bin/lib/python/tools/converter --platform=${PLATFORM} \ --model_file=${MODEL_FILE_PATH} \ --weight_file=${WEIGHT_FILE_PATH} \ --model_checksum=${MODEL_SHA256_CHECKSUM} \ diff --git a/mace_tools.py b/mace_tools.py index 0c0823ea6e16fd9b7e9c96e5c0b43e9b5de5e7cb..2c833f82fdc799c36aae23f02f4e4ed84a0e127d 100644 --- a/mace_tools.py +++ b/mace_tools.py @@ -17,6 +17,29 @@ import yaml 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): print("Run command: {}".format(command)) result = subprocess.Popen( @@ -71,7 +94,7 @@ def generate_random_input(model_output_dir): def generate_model_code(): 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): diff --git a/validate_tools.sh b/validate_tools.sh index 78dfce7550ee7658ac78a3f2c2ee84d029f810ad..6a458676dcaced33e878da197acc545123e0aeb8 100644 --- a/validate_tools.sh +++ b/validate_tools.sh @@ -24,7 +24,7 @@ if [ "$GENERATE_DATA_OR_NOT" = 1 ]; then FORMATTED_NAME=$(sed s/[^[:alnum:]]/_/g <<< ${NAME}) rm -rf ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME}_${FORMATTED_NAME} 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_shape="${INPUT_SHAPES}" || exit 1 exit 0 @@ -38,7 +38,7 @@ if [ "$PLATFORM" == "tensorflow" ];then adb pull ${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME}_${FORMATTED_NAME} ${MODEL_OUTPUT_DIR} > /dev/null done fi - python tools/validate.py --platform=tensorflow \ + python -u tools/validate.py --platform=tensorflow \ --model_file ${MODEL_FILE_PATH} \ --input_file ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \ --mace_out_file ${MODEL_OUTPUT_DIR}/${OUTPUT_FILE_NAME} \ @@ -90,7 +90,8 @@ elif [ "$PLATFORM" == "caffe" ];then docker cp tools/validate.py ${CONTAINER_NAME}:/mace docker cp ${MODEL_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} \ --weight_file /mace/${WEIGHT_FILE_NAME} \ --input_file /mace/${INPUT_FILE_NAME} \