@@ -34,6 +34,7 @@
#include "../internal.h"
#include "safe_queue.h"
#include <c_api/ie_c_api.h>
+#include <unistd.h>
#include "dnn_backend_common.h"
typedef struct OVOptions{
@@ -728,7 +729,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_
OVContext *ctx = NULL;
IEStatusCode status;
size_t node_count = 0;
- char *node_name = NULL;
+ char *node_name, *model_binary_file, *extension_chr = NULL;
model = av_mallocz(sizeof(DNNModel));
if (!model){
@@ -758,6 +759,22 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_
if (status != OK)
goto err;
+ //file existance check
+ model_binary_file = (char *)malloc(sizeof(model_filename));
+ strcpy(model_binary_file, model_filename);
+ extension_chr = strstr(model_binary_file, ".xml");
+ if (!extension_chr) {
+ av_log(ctx, AV_LOG_ERROR, "Model file name \"%s\" with incorrect extension.",
+ model_filename);
+ goto err;
+ }
+ strcpy(extension_chr, ".bin");
+ if (access(model_filename, F_OK) || access(model_binary_file, F_OK)) {
+ av_log(ctx, AV_LOG_ERROR, "Model file \"%s\" or \"%s\" does not exist.",
+ model_filename, model_binary_file);
+ goto err;
+ }
+
status = ie_core_read_network(ov_model->core, model_filename, NULL, &ov_model->network);
if (status != OK) {
ie_version_t ver;
@@ -806,6 +823,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, DNNFunctionType func_
return model;
err:
+ free(model_binary_file);
ff_dnn_free_model_ov(&model);
return NULL;
}
DNN OpenVINO backend would not report missing model file if it does not exist. It would corrupt directly with out any error infomation. This commit would check both .xml and .bin file existance before loading model. Signed-off-by: Ting Fu <ting.fu@intel.com> --- libavfilter/dnn/dnn_backend_openvino.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)