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

C++ inference non-image data

Broderick__Colin1
1,774 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
1,756 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


0 Kudos
Broderick__Colin1
1,751 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.
0 Kudos
Broderick__Colin1
1,748 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.

0 Kudos
Peh_Intel
Moderator
1,712 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


0 Kudos
Broderick__Colin1
1,710 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.

0 Kudos
Peh_Intel
Moderator
1,691 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.cpp

 

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

 

Regards,

Yu Chern

 

0 Kudos
Peh_Intel
Moderator
1,633 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


0 Kudos
Broderick__Colin1
1,613 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.

0 Kudos
Broderick__Colin1
1,609 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?

0 Kudos
Peh_Intel
Moderator
1,560 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


0 Kudos
Peh_Intel
Moderator
1,512 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


0 Kudos
Reply