*
* custom:
* Each entries are separated by ','
- * Each entries have property_key=value format.
+ * Each entries have property_key:value format.
* There must be no spaces.
*
* Supported custom properties:
// init input matrices
for (guint i = 0; i < inputInfo.num_tensors; i++) {
// get dimensions of the input matrix from inputInfo
- const uint32_t *dim = inputInfo.info[i].dimension;
+ const uint32_t *dim = gst_tensors_info_get_nth_info (&inputInfo, i)->dimension;
std::vector<int> shape;
while (*dim)
shape.push_back (*dim++);
in = ncnn::Mat (shape[0], shape[1], shape[2], shape[3]);
break;
default:
- throw std::invalid_argument ("Wrong input dimension");
+ throw std::invalid_argument ("ncnn subplugin supports only up to 4 ranks and does not support input tensors of "
+ + std::to_string (shape.size ()) + " dimensions.");
}
input_mats.push_back (in);
}
void
ncnn_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *output)
{
- assert (!empty_model);
+ if (empty_model)
+ throw std::runtime_error (
+ "Model is empty: the ncnn instance is not configured and "
+ "its \"invoke\" method is called. This may be an internal bug of "
+ "nnstreamer or ncnn-subplugin unless if you have directly accessed "
+ "ncnn-subplugin.");
// make extractor instance for each inference
ncnn::Extractor ex = net.create_extractor ();
// write detection-box infos to the output tensor
for (guint i = 0; i < outputInfo.num_tensors; i++) {
ncnn::Mat &out = output_mats.at (i);
- const int label_count = outputInfo.info[i].dimension[0];
+ const int label_count
+ = gst_tensors_info_get_nth_info (&outputInfo, i)->dimension[0];
float *output_data = (float *) output->data;
for (int j = 0; j < out.h; j++) {
float *values = out.row (j);
for (guint i = 0; i < len; i++) {
// split with = to parse single option
- uniq_g_strv option (g_strsplit (options.get ()[i], "=", -1), g_strfreev);
+ uniq_g_strv option (g_strsplit (options.get ()[i], ":", -1), g_strfreev);
// we only have key=value form option
if (g_strv_length (option.get ()) == 2) {
# NNStreamer and plugins path for test
PATH_TO_PLUGIN="../../build"
-
+
+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 ncnn.so)
+ if [[ ! $check ]]; then
+ echo "Cannot find ncnn 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_file})
+ key=${path%=*}
+ value=${path##*=}
+
+ if [[ $key != "filters" ]]; then
+ echo "String Error"
+ report
+ exit
+ fi
+
+ if [[ -d ${value} ]]; then
+ check=$(ls ${value} | grep ncnn.so)
+ if [[ ! $check ]]; then
+ echo "Cannot find ncnn shared lib"
+ report
+ exit
+ fi
+ else
+ echo "Cannot find ${value}"
+ report
+ exit
+ fi
+else
+ echo "Cannot identify nnstreamer.ini"
+ report
+ exit
+ fi
+fi
+
PATH_TO_PARAM="../test_models/models/ncnn_models/squeezenet_v1.1.param"
PATH_TO_BIN="../test_models/models/ncnn_models/squeezenet_v1.1.bin"
PATH_TO_LABEL="../test_models/labels/squeezenet_labels.txt"
gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! videoscale ! video/x-raw,width=227,height=227,format=BGR,framerate=0/1 ! tensor_converter ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5 ! tensor_transform mode=transpose option=1:2:0:3 ! tensor_filter framework=ncnn model=${PATH_TO_PARAM},${PATH_TO_BIN} input=227:227:3 inputtype=float32 output=1000:1 outputtype=float32,float32 ! tensor_decoder mode=image_labeling option1=${PATH_TO_LABEL} ! filesink location=ncnn.out.log" 5 0 1 $PERFORMANCE
# Fail test for invalid argument
-gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! videoscale ! video/x-raw,width=227,height=227,format=BGR,framerate=0/1 ! tensor_converter ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5 ! tensor_transform mode=transpose option=1:2:0:3 ! tensor_filter framework=ncnn model=${PATH_TO_PARAM},${PATH_TO_BIN} custom=use_yolo_decoder=fail input=227:227:3 inputtype=float32 output=1000:1 outputtype=float32 ! tensor_decoder mode=image_labeling option1=${PATH_TO_LABEL} ! filesink location=ncnn.out.log" 6 0 1 $PERFORMANCE
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! videoscale ! video/x-raw,width=227,height=227,format=BGR,framerate=0/1 ! tensor_converter ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5 ! tensor_transform mode=transpose option=1:2:0:3 ! tensor_filter framework=ncnn model=${PATH_TO_PARAM},${PATH_TO_BIN} custom=use_yolo_decoder:fail input=227:227:3 inputtype=float32 output=1000:1 outputtype=float32 ! tensor_decoder mode=image_labeling option1=${PATH_TO_LABEL} ! filesink location=ncnn.out.log" 6 0 1 $PERFORMANCE
# Fail test for invalid argument
gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! videoscale ! video/x-raw,width=227,height=227,format=BGR,framerate=0/1 ! tensor_converter ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5 ! tensor_transform mode=transpose option=1:2:0:3 ! tensor_filter framework=ncnn model=${PATH_TO_PARAM},${PATH_TO_BIN} custom=nakluv_esu=true input=227:227:3 inputtype=float32 output=1000:1 outputtype=float32 ! tensor_decoder mode=image_labeling option1=${PATH_TO_LABEL} ! filesink location=ncnn.out.log" 7 0 1 $PERFORMANCE