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.
6482 Discussions

Openvino Unable to read network from memory

Singh__Prateek
2,302 Views

Hi,

I'm trying to read network from memory, I tried using both the C API and C++ API but could not read the network from memory.

From ie_c_api.h:

INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_read_network_from_memory(ie_core_t *core, const uint8_t *xml_content, size_t xml_content_size,
const ie_blob_t *weight_blob, ie_network_t **network);

I could not find any documentation for an API or a constructor which could set const ie_blob_t *weight_blob  param's value.

I also tried the C++ API as documented in Using Encrypted Models with OpenVINO™ - OpenVINO™ Toolkit

When I read the xml and bin contents into memory and call ReadNetwork() for the content in buffer I get Unknown Exception. Attaching the code snippet:

std::string xml_str(xml_char.begin(), xml_char.end());//xml_char is also loaded similar to bin_char

FILE * file_bin = fopen(bin_file.c_str(), "rb+");
if (file_bin == NULL) return;
fseek(file_bin, 0, SEEK_END);
long int size_bin = ftell(file_bin);
fclose(file_bin);
// Reading data to array of unsigned chars
file_bin = fopen(bin_file.c_str(), "rb+");
unsigned char * in_bin = (unsigned char *)malloc(size_bin);
int bytes_read_bin = fread(in_bin, sizeof(unsigned char), size_bin, file_bin);
fclose(file_bin);

vector<uint8_t> bin_char;	
for (int itr = 0; itr < size_bin; itr++)
{
    bin_char.push_back(in_bin[itr]);
}
auto weights_bin = make_shared_blob<uint8_t>({ Precision::U8,{ bin_char.size() }, Layout::NCHW }, bin_char.data());

ie.ReadNetwork(xml_str, weights_bin); //Throws Unknown Exception

Is there anything which is undocumented or am I missing something or is it a bug in the ReadNetwork function? I tried this with face-detection-adas-0001 and person-detection-retail-0013 models in all three precisions, these same models are loaded successfully when I read them from file.

0 Kudos
3 Replies
Singh__Prateek
2,287 Views

Edit: The C++ API reads the network successfully (as shown), but the C API issue still exists.

0 Kudos
Iffa_Intel
Moderator
2,266 Views

Greetings,


We would really appreciate it if you could share the complete file that you had modified for us to replicate and investigate further.


Sincerely,

Iffa


0 Kudos
Iffa_Intel
Moderator
2,245 Views

Greetings,

 

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

 

Sincerely,

Iffa

 

0 Kudos
Reply