From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id DD8FE439AE for ; Thu, 4 Aug 2022 09:47:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C7CA68B8E4; Thu, 4 Aug 2022 12:47:43 +0300 (EEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E324168B7AA for ; Thu, 4 Aug 2022 12:47:35 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659606461; x=1691142461; h=from:to:subject:date:message-id; bh=414uwSUQjhSlMraZ8qWArKLDhn9P2Qgngh9kVhi6IeI=; b=gN19orIrN5alGcIpYsNebVxrkXcoAtPCAi8erjrtiCkHlleetF5iwMfn B6nX0NiAg26YlipE6cIuYjRUn87MDLddP/qsZpJROBfXL4+39i6sdMsgM y8msMtETi1Ef/vjtOD7tCoslh73LcC618THl2hbmpWFpD2q969dLG3aB7 u/3uG5WMNO/jwF83aXtQnPuPDnR60TfbvEhXBPBL1fJTOVLtIedGGH3sf g/KoUMalxpwR7JQyFanJHHrjKEHSHADSnx5ch0TKrdpeboCbw95KzTjop xVpVgsk3i7oraqsVrJqqv6RYMAt3SUDH6Qhkc+yaAdpfG43ziLhA8Gd4P Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10428"; a="272938768" X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="272938768" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2022 02:47:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="662469233" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.83]) by fmsmga008.fm.intel.com with ESMTP; 04 Aug 2022 02:47:32 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Aug 2022 17:31:01 +0800 Message-Id: <20220804093101.30059-1-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] lavfi/dnn: Fix OpenVINO missing model file corrupt issue. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 --- 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 +#include #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".