From: Ting Fu <ting.fu-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] lavfi/dnn: Fix OpenVINO missing model file corrupt issue.
Date: Thu, 4 Aug 2022 17:31:01 +0800
Message-ID: <20220804093101.30059-1-ting.fu@intel.com> (raw)
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(-)
diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index b494f26f55..47e3fc8280 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -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;
}
--
2.17.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2022-08-04 9:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 9:31 Ting Fu [this message]
2022-08-04 10:39 ` Anton Khirnov
2022-08-05 3:34 ` Fu, Ting
2022-08-06 12:57 ` Anton Khirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220804093101.30059-1-ting.fu@intel.com \
--to=ting.fu-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git