Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.

C++ inference non-image data

Broderick__Colin1
697 Views

I'm trying to run inference on the NCS2 on non-image data, shape 200x6. I'm stuck on how to make an input blob. The example code is all image or audio based so it's not obvious to me how to form more generic data into a blob.

It starts life as an array of arrays (or vector of vectors) of floats. I can potentially convert to other forms first if it makes the conversion to a blob workable.

I know the NCS2 can do it because I have it working in Python, but of course most of the detail is hidden there so it's not much help. Can anyone advise on how I might convert a standard CPP array to an input blob which can be passed into an inference request?

I'm happy to supply more information, but trying to keep it general for now.

Thanks.

0 Kudos
11 Replies
Peh_Intel
Moderator
679 Views

Hi Colin,


Greetings to you.

You’re right, the example code does not have array based. That would upset me too.

 

Anyway, you can create blob using the InferenceEngine::Blob or InferenceEngine::TBlob classes.

 

An implementation step-by-step guide is provided in the Integration Steps. Point No. 6 (Prepare Input) provides some options to prepare input, which may help you.

 

In addition, I would like to share a video on example implementation of Inference-Engine main function calls.

Inference-Engine API Sample Code

 

Regards,

Peh


Broderick__Colin1
674 Views

Thanks for the tips.

The video still assumes you're working with images and it isn't clear how I'd do anything without cv. The integration steps documentation says this:

/** Iterate over all input blobs **/
for (auto & item : input_info) {
auto input_name = item.first;
/** Get input blob **/
auto input = infer_request.GetBlob(input_name);
/** Fill input tensor with planes. First b channel, then g and r channels **/
// ...
}
 
So completely skips the part I'm stuck on, which is how to fill the input tensor.
 
I'm also not clear how I'd use a TBlob since there is no infer_request.SetBlob function to handle it, as far as I can tell.
 
So all in all I'm still stuck :(.
 
I have been able to get inference done on an 'empty' blob so this is really the only part left to solve.
Broderick__Colin1
671 Views

Actually I think I'll probably struggle with reading the output blob as well when it comes to it. The output should just be three numbers so would be nice if I could index into it directly, but doesn't look like that's going to be possible based on what's going on in the examples.

Peh_Intel
Moderator
635 Views

Hi Colin,

Greetings to you.

We don’t have a specific example for array as an input. I am so sorry for that.

For non-image workloads, I would suggest you have a look at supported models such as GNMT, BERT, TDNN, ESPNet, and the following demos and sample :


Regards,

Peh


Broderick__Colin1
633 Views

Thank you.

I am intending to look more closely at the speech recognition example as it seems closest to what I need.

Is there any possibility of creating an array- or vector-based example? It seems like it would be a good thing to include as it's a common point that we can all reach no matter what kind of data we're working with.

Peh_Intel
Moderator
614 Views

Hi Colin,

 

Greetings to you. I’m glad to hear that you’ve found the example that close to what you need. The full implementation of this coding can be found in this directory:

<path_to_openvino>\inference_engine\samples\cpp\speech_sample

 

You may also find from this link:

https://github.com/openvinotoolkit/openvino/blob/master/inference-engine/samples/speech_sample/main....

 

I hope this example will help you to achieve what you need.

 

Regards,

Yu Chern

 

Peh_Intel
Moderator
556 Views

Hi Colin,

 

This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.

 


Regards,

Yu Chern


Broderick__Colin1
536 Views

Unfortunately I don't think you have provided a solution. This example uses the same techniques as the others and gives not clue at all how I might make use of arbitrary data stored in other forms.

Broderick__Colin1
532 Views

I have found CopyVectorToBlob() here: https://docs.openvinotoolkit.org/2021.2/ie_plugin_api/group__ie__dev__api__memory.html

but the documentation is not clear on how to use it. It does not appear to exist in the InferenceEngine namespace. Can you help?

Peh_Intel
Moderator
483 Views

Hi Colin,


Greetings to you.


First of all, I would like to apologize for misusing the word “solution”. Next, we do not have any example on how to use array or vector-based data into the blob currently.


Therefore, we would like to clearly know and understand your end goal that you intend to achieve. Furthermore, we would like to request your model, input file, expected output and any other necessary files for us to assist you further.


You may email your files privately to us if you do not want to share in public.



Regards,

Peh


Peh_Intel
Moderator
435 Views

Hi Colin,

 

Thank you for your question. If you need any additional information from Intel, please submit a new question as this thread is no longer being monitored.

 

 

Regards,

Peh


Reply