From fed3f5d2d58cc675f687bf2ae92f0e0df0b7359d Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Wed, 17 Apr 2019 10:38:18 +0900 Subject: [PATCH] [UNITTEST] Skip the test when there is not tensorflow and lite We need to skip tests using tensorflow and lite if they are not installed. So pkg-config is used to identify their installation. **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- tests/nnstreamer_decoder_image_labeling/runTest.sh | 44 ++++++++++++++++++++ tests/nnstreamer_filter_tensorflow/runTest.sh | 47 ++++++++++++++++++++-- tests/nnstreamer_filter_tensorflow_lite/runTest.sh | 44 ++++++++++++++++++++ 3 files changed, 132 insertions(+), 3 deletions(-) diff --git a/tests/nnstreamer_decoder_image_labeling/runTest.sh b/tests/nnstreamer_decoder_image_labeling/runTest.sh index 7facec2..038cbd4 100644 --- a/tests/nnstreamer_decoder_image_labeling/runTest.sh +++ b/tests/nnstreamer_decoder_image_labeling/runTest.sh @@ -24,6 +24,50 @@ PATH_TO_MODEL="../test_models/models/mobilenet_v1_1.0_224_quant.tflite" PATH_TO_LABEL="../test_models/labels/labels.txt" PATH_TO_IMAGE="img/orange.png" +if [[ -d $PATH_TO_PLUGIN ]]; then + ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter" + if [[ -d ${ini_path} ]]; then + check=$(ls ${ini_path} | grep tensorflow-lite.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow-lite shared lib" + report + exit + fi + else + echo "Cannot find ${ini_path}" + fi +else + ini_file="/etc/nnstreamer.ini" + if [[ -f ${ini_file} ]]; then + path=$(grep "^filters" ${ini_path}) + key=${path%=*} + value=${path##*=} + + if [[ $key != "filters" ]] + then + echo "String Error" + report + exit + fi + + if [[ -d ${value} ]]; then + check=$(ls ${value} | grep tensorflow-lite.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow-lite shared lib" + report + exit + fi + else + echo "Cannot file ${value}" + report + exit + fi + fi + echo "Cannot identify nnstreamer.ini" + report + exit +fi + # Decoding 'orange' tests # Since data type of output tensor is uint8, int8 requires another 'quantization' (such as /2) gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=\"${PATH_TO_IMAGE}\" ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw, format=RGB, framerate=0/1 ! tensor_converter ! tensor_filter framework=\"tensorflow-lite\" model=\"${PATH_TO_MODEL}\" ! \ diff --git a/tests/nnstreamer_filter_tensorflow/runTest.sh b/tests/nnstreamer_filter_tensorflow/runTest.sh index f12aaa8..b7ceb54 100755 --- a/tests/nnstreamer_filter_tensorflow/runTest.sh +++ b/tests/nnstreamer_filter_tensorflow/runTest.sh @@ -17,15 +17,56 @@ fi # This is compatible with SSAT (https://github.com/myungjoo/SSAT) testInit $1 -if [[ -z "${TEST_TENSORFLOW}" ]]; then - report -fi # Test with mnist model PATH_TO_PLUGIN="../../build" PATH_TO_MODEL="../test_models/models/mnist.pb" PATH_TO_DATA="data/9.raw" +if [[ -d $PATH_TO_PLUGIN ]]; then + ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter" + if [[ -d ${ini_path} ]]; then + check=$(ls ${ini_path} | grep tensorflow.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow shared lib" + report + exit + fi + else + echo "Cannot find ${ini_path}" + fi +else + ini_file="/etc/nnstreamer.ini" + if [[ -f ${ini_file} ]]; then + path=$(grep "^filters" ${ini_path}) + key=${path%=*} + value=${path##*=} + + if [[ $key != "filters" ]] + then + echo "String Error" + report + exit + fi + + if [[ -d ${value} ]]; then + check=$(ls ${value} | grep tensorflow.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow shared lib" + report + exit + fi + else + echo "Cannot file ${value}" + report + exit + fi + fi + echo "Cannot identify nnstreamer.ini" + report + exit +fi + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_DATA} ! application/octet-stream ! tensor_converter input-dim=784:1 input-type=uint8 ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5,div:127.5 ! tensor_filter framework=tensorflow model=${PATH_TO_MODEL} input=784:1:1:1 inputtype=float32 inputname=input output=10:1:1:1 outputtype=float32 outputname=softmax ! filesink location=tensorfilter.out.1.log " 1 0 0 $PERFORMANCE python checkLabel.py tensorfilter.out.1.log ${PATH_TO_DATA} testResult $? 1 "Golden test comparison" 0 1 diff --git a/tests/nnstreamer_filter_tensorflow_lite/runTest.sh b/tests/nnstreamer_filter_tensorflow_lite/runTest.sh index 3ae4296..e3ec601 100644 --- a/tests/nnstreamer_filter_tensorflow_lite/runTest.sh +++ b/tests/nnstreamer_filter_tensorflow_lite/runTest.sh @@ -24,6 +24,50 @@ PATH_TO_MODEL="../test_models/models/mobilenet_v1_1.0_224_quant.tflite" PATH_TO_LABEL="../test_models/labels/labels.txt" PATH_TO_IMAGE="img/orange.png" +if [[ -d $PATH_TO_PLUGIN ]]; then + ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter" + if [[ -d ${ini_path} ]]; then + check=$(ls ${ini_path} | grep tensorflow-lite.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow-lite shared lib" + report + exit + fi + else + echo "Cannot find ${ini_path}" + fi +else + ini_file="/etc/nnstreamer.ini" + if [[ -f ${ini_file} ]]; then + path=$(grep "^filters" ${ini_path}) + key=${path%=*} + value=${path##*=} + + if [[ $key != "filters" ]] + then + echo "String Error" + report + exit + fi + + if [[ -d ${value} ]]; then + check=$(ls ${value} | grep tensorflow-lite.so) + if [[ ! $check ]]; then + echo "Cannot find tensorflow-lite shared lib" + report + exit + fi + else + echo "Cannot file ${value}" + report + exit + fi + fi + echo "Cannot identify nnstreamer.ini" + report + exit +fi + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} ! filesink location=tensorfilter.out.log" 1 0 0 $PERFORMANCE python checkLabel.py tensorfilter.out.log ${PATH_TO_LABEL} ${PATH_TO_IMAGE} testResult $? 1 "Golden test comparison" 0 1 -- 2.7.4