- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was following this Hello Classification C++ example and rather than reading a raw image, wanted to read an already saved tensor file eg. this file (this is from an example about using wasi-nn and uses this tool to convert image into a tensor file) and perform the inference.
I tried changing the lines 515-60 in this code to the following (basically reading raw bytes of the file and create the Tensor object):
But on running this it just gives a Segmentation Fault at this step
Weirdly, I tried to do a similar thing in Python (as shown below) and it works perfectly.
Any suggestions on how I can go about making it work?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Omkar2,
Thanks for reaching out to us.
I’ve validated Hello Classification Python Sample by loading image file (tensor format) as input data.
Could you please share your C++ inference script with us for replication purposes?
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Wan
Have attached the C++ file, most things are the same as the Hello Classification example but some arguments have been added . Once compiled the usage should be as follows:
`./hello_classification <model_root_path> <model_name> <tensor_file_path> <tensor_height> <tensor_width> <precision> <device>`
eg. `./hello_classification public/mobilenet-v2/FP32 mobilenet-v2 tensor-1x224x224x3-f32.bgr 224 224 f32 CPU`
Please do let me know if any other information will help!
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Omkar2,
Thanks for sharing your information with us.
We encountered the same issue when running your custom Hello Classification C++ sample. We’re investigating this issue and we’ll get back to you at the earliest.
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Omkar2,
Thank you for your patience, we do suggest to change infer_request.set_input_tensor(input_tensor) in Step 7 to infer_request.get_input_tensor() while importing the tensor file.
ov::InferRequest allows you to get input/output tensors by tensor name, index, port, and without any arguments, if a model has only one input or output.
Additional information can be obtained in OpenVINO™ Inference Request. Thank you.
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Wan,
Thanks for getting back. I didn't quite understand how get_input_tensor() helps when we need to give our input tensor.
If you could share the code (main.cpp) that you used to make this work with the tensor file, it would be really helpful.
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Wan,
The get_input_tensor() definitely doesn't work (as it a getter method). The model just uses some default tensor value and produces the output, if you use another tensor file it will produce the same results (see the screenshots below as tested).
Please do let me know if there is any solution to fix the set_input_tensor method.
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Omkar2,
Thanks for your information.
We encountered the same issue as you when using the get_input_tensor() with another image as an input. We're investigating this issue and we'll update you at the earliest.
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Okmar2,
Thanks for your patience.
Segmentation fault is a specific kind of error caused by accessing memory, there is a discussion on segmentation fault can be found in https://stackoverflow.com/questions/2346806/what-is-a-segmentation-fault/2346849#2346849
It is suggested to remove "&" in ov::Tensor input_tensor = ov::Tensor(input_type, input_shape, data);.
The "&" may be one of the reasons caused the segmentation fault error previously.
Thank you.
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Omkar2,
Thanks for your question.
This thread will no longer be monitored since we have provided information.
If you need any additional information from Intel, please submit a new question.
Best regards,
Wan
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page