In tensorflow sub-plugin, support DT_STRING type.
Added testcase with speech command model, which classifies wav input to keyword.
This model has input type DT_STRING.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
}
if (inputTensorMeta.info[i].type != getTensorTypeFromTF (dtype)) {
- GST_ERROR ("Input Tensor is not valid: the type of input tensor is different\n");
- return -3;
+ /* consider the input data as bytes if tensor type is string */
+ if (dtype == DT_STRING) {
+ GST_WARNING ("Input type is string, ignore type comparision.");
+ } else {
+ GST_ERROR ("Input Tensor is not valid: the type of input tensor is different\n");
+ return -3;
+ }
}
gchar **str_dims;
Tensor in (input_tensor_info[i].type, input_tensor_info[i].shape);
/* copy data */
- std::copy_n ((char *) input[i].data, input[i].size,
- const_cast<char *>(in.tensor_data().data()));
+ if (input_tensor_info[i].type == DT_STRING) {
+ in.scalar<string>()() = string ((char *) input[i].data, input[i].size);
+ } else {
+ std::copy_n ((char *) input[i].data, input[i].size,
+ const_cast<char *>(in.tensor_data().data()));
+ }
input_feeds.push_back ({inputTensorMeta.info[i].name, in});
}
}
for (int i = 0; i < outputTensorMeta.num_tensors; ++i) {
+ /**
+ * @todo support DT_STRING output tensor
+ */
output[i].data = const_cast<char *>(outputs[i].tensor_data().data());
outputTensorMap.insert (std::make_pair (output[i].data, outputs[i]));
}
report
fi
-# Test constant passthrough custom filter (1, 2)
+# Test with mnist model
PATH_TO_PLUGIN="../../build"
PATH_TO_MODEL="../test_models/models/mnist.pb"
PATH_TO_DATA="data/9.raw"
-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.log " 1 0 0 $PERFORMANCE
-python checkLabel.py tensorfilter.out.log ${PATH_TO_DATA}
+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
+# Test with speech command model (.wav file, answer is 'yes', this model has a input type DT_STRING.)
+PATH_TO_MODEL="../test_models/models/conv_actions_frozen.pb"
+PATH_TO_DATA="data/2.wav"
+
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_DATA} blocksize=-1 ! application/octet-stream ! tensor_converter input-dim=1:16022 input-type=int16 ! tensor_filter framework=tensorflow model=${PATH_TO_MODEL} input=1:16022 inputtype=int16 inputname=wav_data output=12 outputtype=float32 outputname=labels_softmax ! filesink location=tensorfilter.out.2.log " 2 0 0 $PERFORMANCE
+python checkLabel.py tensorfilter.out.2.log ${PATH_TO_DATA}
+testResult $? 2 "Golden test comparison" 0 1
+
report