// Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include #include #include #include #include #include int main(int argc, char** argv) { // ------------------------------ Parsing and validation of input args // --------------------------------- if (argc != 4) { printf("Usage : ./hello_classification_c " "\n"); return EXIT_FAILURE; } const char* input_model = argv[1]; const char* input_image_path = argv[2]; const char* device_name = argv[3]; ie_core_t* ov_core = NULL; ie_network_t* ov_network = NULL; IEStatusCode status = ie_core_create("", &ov_core); if (status != OK) { // error } FILE* model_xml_desc = fopen(input_model, "r"); char* input_model_bin = (char*) malloc(strlen(input_model)); strncpy(input_model_bin, input_model, strlen(input_model)-3); strncpy(input_model_bin + strlen(input_model)-3, "bin", 3); input_model_bin[strlen(input_model)] = '\0'; printf("input_model_bin=%s\n", input_model_bin); FILE* fp_bin = fopen(input_model_bin, "rb"); fseek(model_xml_desc, 0, SEEK_END); size_t xml_sz = ftell(model_xml_desc); rewind(model_xml_desc); const unsigned char* ov_model_xml_content = (unsigned char *)malloc(xml_sz); fread(ov_model_xml_content, 1, xml_sz, model_xml_desc); fseek(fp_bin, 0, SEEK_END); size_t model_bin_size = ftell(fp_bin); rewind(fp_bin); const char* weights_tensor_dims = (char *)malloc(model_bin_size); fread(weights_tensor_dims, 1, model_bin_size, fp_bin); tensor_desc_t weights_tensor_desc = { ANY, { 1, { weights_tensor_dims } }, U8 }; ie_blob_t* ov_model_weight_blob = NULL; status = ie_blob_make_memory_from_preallocated( &weights_tensor_desc, weights_tensor_dims, model_bin_size, &ov_model_weight_blob); if (status != OK) { // error } status = ie_core_read_network_from_memory( ov_core, ov_model_xml_content, xml_sz, ov_model_weight_blob, &ov_network); if (status != OK) { // Always get "GENERAL_ERROR (-1)" } // --------------------------- Step 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin) // --------------------------- Step 3. Configure input & output // --------------------------- Step 4. Loading model to the device // --------------------------- Step 5. Create infer request // --------------------------- Step 6. Prepare input // --------------------------- Step 7. Do inference // --------------------------- Step 8. Process output }