From patchwork Thu Jun 11 13:00:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 20281 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 107BE44AC21 for ; Thu, 11 Jun 2020 16:03:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E0FBE68B5FF; Thu, 11 Jun 2020 16:03:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C14268A494 for ; Thu, 11 Jun 2020 16:03:48 +0300 (EEST) IronPort-SDR: 1F8nv28whMTEfrL22RTGjMUDyidUjGVoTFeLPD6LYwtQyJhwJgfz6TDyr5jZ8ddVBKzXQp/eS9 kUQSdZFyvJ1w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 06:03:47 -0700 IronPort-SDR: HLNFiPoZUNB8hwKsFQbaT0P/C4nj4U+ihZgil5E0QfbxcsTneMQnape8WCmXBzcKAeNua8sTe2 /DmTtwEcgwqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="419092598" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by orsmga004.jf.intel.com with ESMTP; 11 Jun 2020 06:03:45 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Jun 2020 21:00:36 +0800 Message-Id: <1591880436-24931-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V2 1/2] dnn: add openvino as one of dnn backend X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" OpenVINO is a Deep Learning Deployment Toolkit at https://github.com/openvinotoolkit/openvino, it supports CPU, GPU and heterogeneous plugins to accelerate deep learning inferencing. Please refer to https://github.com/openvinotoolkit/openvino/blob/master/build-instruction.md to build openvino (c library is built at the same time). Please add option -DENABLE_MKL_DNN=ON for cmake to enable CPU path. The header files and libraries are installed to /usr/local/deployment_tools/inference_engine/ with default options on my system. To build FFmpeg with openvion, take my system as an example, run with: $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/deployment_tools/inference_engine/lib/intel64/:/usr/local/deployment_tools/inference_engine/external/tbb/lib/ $ ../ffmpeg/configure --enable-libopenvino --extra-cflags=-I/usr/local/deployment_tools/inference_engine/include/ --extra-ldflags=-L/usr/local/deployment_tools/inference_engine/lib/intel64 $ make Here are the features provided by OpenVINO inference engine: - support more DNN model formats It supports TensorFlow, Caffe, ONNX, MXNet and Kaldi by converting them into OpenVINO format with a python script. And torth model can be first converted into ONNX and then to OpenVINO format. see the script at https://github.com/openvinotoolkit/openvino/tree/master/model-optimizer/mo.py which also does some optimization at model level. - optimize at inference stage It optimizes for X86 CPUs with SSE, AVX etc. It also optimizes based on OpenCL for Intel GPUs. (only Intel GPU supported becuase Intel OpenCL extension is used for optimization) Signed-off-by: Guo, Yejun --- configure | 6 +- libavfilter/dnn/Makefile | 1 + libavfilter/dnn/dnn_backend_openvino.c | 261 +++++++++++++++++++++++++++++++++ libavfilter/dnn/dnn_backend_openvino.h | 38 +++++ libavfilter/dnn/dnn_interface.c | 11 ++ libavfilter/dnn_interface.h | 2 +- 6 files changed, 317 insertions(+), 2 deletions(-) create mode 100644 libavfilter/dnn/dnn_backend_openvino.c create mode 100644 libavfilter/dnn/dnn_backend_openvino.h diff --git a/configure b/configure index 8569a60..46fc2bb 100755 --- a/configure +++ b/configure @@ -253,6 +253,8 @@ External library support: --enable-libopenh264 enable H.264 encoding via OpenH264 [no] --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] --enable-libopenmpt enable decoding tracked files via libopenmpt [no] + --enable-libopenvino enable OpenVINO as a DNN module backend + for DNN based filters like dnn_processing [no] --enable-libopus enable Opus de/encoding via libopus [no] --enable-libpulse enable Pulseaudio input via libpulse [no] --enable-librabbitmq enable RabbitMQ library [no] @@ -1790,6 +1792,7 @@ EXTERNAL_LIBRARY_LIST=" libopenh264 libopenjpeg libopenmpt + libopenvino libopus libpulse librabbitmq @@ -2620,7 +2623,7 @@ cbs_mpeg2_select="cbs" cbs_vp9_select="cbs" dct_select="rdft" dirac_parse_select="golomb" -dnn_suggest="libtensorflow" +dnn_suggest="libtensorflow libopenvino" error_resilience_select="me_cmp" faandct_deps="faan" faandct_select="fdctdsp" @@ -6347,6 +6350,7 @@ enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_ enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version || { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } } enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++" +enabled libopenvino && require libopenvino c_api/ie_c_api.h ie_c_api_version -linference_engine_c_api enabled libopus && { enabled libopus_decoder && { require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile index bb37298..d90137e 100644 --- a/libavfilter/dnn/Makefile +++ b/libavfilter/dnn/Makefile @@ -9,5 +9,6 @@ OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_mat OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_mathunary.o DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o +DNN-OBJS-$(CONFIG_LIBOPENVINO) += dnn/dnn_backend_openvino.o OBJS-$(CONFIG_DNN) += $(DNN-OBJS-yes) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c new file mode 100644 index 0000000..f048bc2 --- /dev/null +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2020 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * DNN OpenVINO backend implementation. + */ + +#include "dnn_backend_openvino.h" +#include "libavformat/avio.h" +#include "libavutil/avassert.h" +#include + +typedef struct OVModel{ + ie_core_t *core; + ie_network_t *network; + ie_executable_network_t *exe_network; + ie_infer_request_t *infer_request; + ie_blob_t *input_blob; + ie_blob_t **output_blobs; + uint32_t nb_output; +} OVModel; + +static DNNDataType precision_to_datatype(precision_e precision) +{ + switch (precision) + { + case FP32: + return DNN_FLOAT; + default: + av_assert0(!"not supported yet."); + return DNN_FLOAT; + } +} + +static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input_name) +{ + OVModel *ov_model = (OVModel *)model; + char *model_input_name = NULL; + IEStatusCode status; + size_t model_input_count = 0; + dimensions_t dims; + precision_e precision; + + status = ie_network_get_inputs_number(ov_model->network, &model_input_count); + if (status != OK) + return DNN_ERROR; + + for (size_t i = 0; i < model_input_count; i++) { + status = ie_network_get_input_name(ov_model->network, i, &model_input_name); + if (status != OK) + return DNN_ERROR; + if (strcmp(model_input_name, input_name) == 0) { + ie_network_name_free(&model_input_name); + status |= ie_network_get_input_dims(ov_model->network, input_name, &dims); + status |= ie_network_get_input_precision(ov_model->network, input_name, &precision); + if (status != OK) + return DNN_ERROR; + + // The order of dims in the openvino is fixed and it is always NCHW for 4-D data. + // while we pass NHWC data from FFmpeg to openvino + status = ie_network_set_input_layout(ov_model->network, input_name, NHWC); + if (status != OK) + return DNN_ERROR; + + input->channels = dims.dims[1]; + input->height = dims.dims[2]; + input->width = dims.dims[3]; + input->dt = precision_to_datatype(precision); + return DNN_SUCCESS; + } + + ie_network_name_free(&model_input_name); + } + + return DNN_ERROR; +} + +static DNNReturnType set_input_output_ov(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output) +{ + OVModel *ov_model = (OVModel *)model; + IEStatusCode status; + dimensions_t dims; + precision_e precision; + ie_blob_buffer_t blob_buffer; + + status = ie_exec_network_create_infer_request(ov_model->exe_network, &ov_model->infer_request); + if (status != OK) + goto err; + + status = ie_infer_request_get_blob(ov_model->infer_request, input_name, &ov_model->input_blob); + if (status != OK) + goto err; + + status |= ie_blob_get_dims(ov_model->input_blob, &dims); + status |= ie_blob_get_precision(ov_model->input_blob, &precision); + if (status != OK) + goto err; + + av_assert0(input->channels == dims.dims[1]); + av_assert0(input->height == dims.dims[2]); + av_assert0(input->width == dims.dims[3]); + av_assert0(input->dt == precision_to_datatype(precision)); + + status = ie_blob_get_buffer(ov_model->input_blob, &blob_buffer); + if (status != OK) + goto err; + input->data = blob_buffer.buffer; + + // outputs + ov_model->nb_output = 0; + av_freep(&ov_model->output_blobs); + ov_model->output_blobs = av_mallocz_array(nb_output, sizeof(*ov_model->output_blobs)); + if (!ov_model->output_blobs) + goto err; + + for (int i = 0; i < nb_output; i++) { + const char *output_name = output_names[i]; + status = ie_infer_request_get_blob(ov_model->infer_request, output_name, &(ov_model->output_blobs[i])); + if (status != OK) + goto err; + ov_model->nb_output++; + } + + return DNN_SUCCESS; + +err: + if (ov_model->output_blobs) { + for (uint32_t i = 0; i < ov_model->nb_output; i++) { + ie_blob_free(&(ov_model->output_blobs[i])); + } + av_freep(&ov_model->output_blobs); + } + if (ov_model->input_blob) + ie_blob_free(&ov_model->input_blob); + if (ov_model->infer_request) + ie_infer_request_free(&ov_model->infer_request); + return DNN_ERROR; +} + +DNNModel *ff_dnn_load_model_ov(const char *model_filename) +{ + DNNModel *model = NULL; + OVModel *ov_model = NULL; + IEStatusCode status; + ie_config_t config = {NULL, NULL, NULL}; + + model = av_malloc(sizeof(DNNModel)); + if (!model){ + return NULL; + } + + ov_model = av_mallocz(sizeof(OVModel)); + if (!ov_model) + goto err; + + status = ie_core_create("", &ov_model->core); + if (status != OK) + goto err; + + status = ie_core_read_network(ov_model->core, model_filename, NULL, &ov_model->network); + if (status != OK) + goto err; + + status = ie_core_load_network(ov_model->core, ov_model->network, "CPU", &config, &ov_model->exe_network); + if (status != OK) + goto err; + + model->model = (void *)ov_model; + model->set_input_output = &set_input_output_ov; + model->get_input = &get_input_ov; + + return model; + +err: + if (model) + av_freep(&model); + if (ov_model) { + if (ov_model->exe_network) + ie_exec_network_free(&ov_model->exe_network); + if (ov_model->network) + ie_network_free(&ov_model->network); + if (ov_model->core) + ie_core_free(&ov_model->core); + av_freep(&ov_model); + } + return NULL; +} + +DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, DNNData *outputs, uint32_t nb_output) +{ + dimensions_t dims; + precision_e precision; + ie_blob_buffer_t blob_buffer; + OVModel *ov_model = (OVModel *)model->model; + uint32_t nb = FFMIN(nb_output, ov_model->nb_output); + IEStatusCode status = ie_infer_request_infer(ov_model->infer_request); + if (status != OK) + return DNN_ERROR; + + for (uint32_t i = 0; i < nb; ++i) { + status = ie_blob_get_buffer(ov_model->output_blobs[i], &blob_buffer); + if (status != OK) + return DNN_ERROR; + + status |= ie_blob_get_dims(ov_model->output_blobs[i], &dims); + status |= ie_blob_get_precision(ov_model->output_blobs[i], &precision); + if (status != OK) + return DNN_ERROR; + + outputs[i].channels = dims.dims[1]; + outputs[i].height = dims.dims[2]; + outputs[i].width = dims.dims[3]; + outputs[i].dt = precision_to_datatype(precision); + outputs[i].data = blob_buffer.buffer; + } + + return DNN_SUCCESS; +} + +void ff_dnn_free_model_ov(DNNModel **model) +{ + if (*model){ + OVModel *ov_model = (OVModel *)(*model)->model; + if (ov_model->output_blobs) { + for (uint32_t i = 0; i < ov_model->nb_output; i++) { + ie_blob_free(&(ov_model->output_blobs[i])); + } + av_freep(&ov_model->output_blobs); + } + if (ov_model->input_blob) + ie_blob_free(&ov_model->input_blob); + if (ov_model->infer_request) + ie_infer_request_free(&ov_model->infer_request); + if (ov_model->exe_network) + ie_exec_network_free(&ov_model->exe_network); + if (ov_model->network) + ie_network_free(&ov_model->network); + if (ov_model->core) + ie_core_free(&ov_model->core); + av_freep(&ov_model); + av_freep(model); + } +} diff --git a/libavfilter/dnn/dnn_backend_openvino.h b/libavfilter/dnn/dnn_backend_openvino.h new file mode 100644 index 0000000..397847a --- /dev/null +++ b/libavfilter/dnn/dnn_backend_openvino.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * DNN inference functions interface for OpenVINO backend. + */ + + +#ifndef AVFILTER_DNN_DNN_BACKEND_OPENVINO_H +#define AVFILTER_DNN_DNN_BACKEND_OPENVINO_H + +#include "../dnn_interface.h" + +DNNModel *ff_dnn_load_model_ov(const char *model_filename); + +DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, DNNData *outputs, uint32_t nb_output); + +void ff_dnn_free_model_ov(DNNModel **model); + +#endif diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c index 62da55f..7973d3e 100644 --- a/libavfilter/dnn/dnn_interface.c +++ b/libavfilter/dnn/dnn_interface.c @@ -26,6 +26,7 @@ #include "../dnn_interface.h" #include "dnn_backend_native.h" #include "dnn_backend_tf.h" +#include "dnn_backend_openvino.h" #include "libavutil/mem.h" DNNModule *ff_get_dnn_module(DNNBackendType backend_type) @@ -53,6 +54,16 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type) return NULL; #endif break; + case DNN_OV: + #if (CONFIG_LIBOPENVINO == 1) + dnn_module->load_model = &ff_dnn_load_model_ov; + dnn_module->execute_model = &ff_dnn_execute_model_ov; + dnn_module->free_model = &ff_dnn_free_model_ov; + #else + av_freep(&dnn_module); + return NULL; + #endif + break; default: av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or tensorflow\n"); av_freep(&dnn_module); diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index b20e5c8..f914265 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -30,7 +30,7 @@ typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType; -typedef enum {DNN_NATIVE, DNN_TF} DNNBackendType; +typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType; typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType; From patchwork Thu Jun 11 13:00:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 20282 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F0DA544AD9B for ; Thu, 11 Jun 2020 16:04:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBB3D68B60D; Thu, 11 Jun 2020 16:04:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57D7468B509 for ; Thu, 11 Jun 2020 16:04:02 +0300 (EEST) IronPort-SDR: x+RJVN/+q7dboh821SZKvxtCdx+78AAzWjWDDrOQb7iroGQGbtMg9hR3g82+8kpzmoOYCnbPeQ fA7aerPgWicw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 06:04:00 -0700 IronPort-SDR: OKSDk9E7zhX8GSNYfoXujou1JNO2wHUjM84hszVIz75ZUViTDPP6cDQ31OFBVdSG6ISfXl/Sdv vCbL8Lj04MWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="275324342" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by orsmga006.jf.intel.com with ESMTP; 11 Jun 2020 06:03:59 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Jun 2020 21:00:49 +0800 Message-Id: <1591880449-24988-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V2 2/2] vf_dnn_processing.c: add dnn backend openvino X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" We can try with the srcnn model from sr filter. 1) get srcnn.pb model file, see filter sr 2) convert srcnn.pb into openvino model with command: python mo_tf.py --input_model srcnn.pb --data_type=FP32 --input_shape [1,960,1440,1] --keep_shape_ops See the script at https://github.com/openvinotoolkit/openvino/tree/master/model-optimizer We'll see srcnn.xml and srcnn.bin at current path, copy them to the directory where ffmpeg is. I have also uploaded the model files at https://github.com/guoyejun/dnn_processing/tree/master/models 3) run with openvino backend: ffmpeg -i input.jpg -vf format=yuv420p,scale=w=iw*2:h=ih*2,dnn_processing=dnn_backend=openvino:model=srcnn.xml:input=x:output=srcnn/Maximum -y srcnn.ov.jpg (The input.jpg resolution is 720*480) Signed-off-by: Guo, Yejun --- doc/filters.texi | 10 +++++++++- libavfilter/vf_dnn_processing.c | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 84567de..d197d33 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -9288,13 +9288,21 @@ TensorFlow backend. To enable this backend you need to install the TensorFlow for C library (see @url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with @code{--enable-libtensorflow} + +@item openvino +OpenVINO backend. To enable this backend you +need to build and install the OpenVINO for C library (see +@url{https://github.com/openvinotoolkit/openvino/blob/master/build-instruction.md}) and configure FFmpeg with +@code{--enable-libopenvino} (--extra-cflags=-I... --extra-ldflags=-L... might +be needed if the header files and libraries are not installed into system path) + @end table Default value is @samp{native}. @item model Set path to model file specifying network architecture and its parameters. -Note that different backends use different file formats. TensorFlow and native +Note that different backends use different file formats. TensorFlow, OpenVINO and native backend can load files for only its format. Native model file (.model) can be generated from TensorFlow model file (.pb) by using tools/python/convert.py diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c index cf589ac..4b31808 100644 --- a/libavfilter/vf_dnn_processing.c +++ b/libavfilter/vf_dnn_processing.c @@ -58,11 +58,14 @@ typedef struct DnnProcessingContext { #define OFFSET(x) offsetof(DnnProcessingContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM static const AVOption dnn_processing_options[] = { - { "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" }, + { "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "backend" }, { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" }, #if (CONFIG_LIBTENSORFLOW == 1) { "tensorflow", "tensorflow backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "backend" }, #endif +#if (CONFIG_LIBOPENVINO == 1) + { "openvino", "openvino backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "backend" }, +#endif { "model", "path to model file", OFFSET(model_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, { "input", "input name of the model", OFFSET(model_inputname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, { "output", "output name of the model", OFFSET(model_outputname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },