[FFmpeg-devel] [GSOC] [PATCH] TensorFlow backend introduction for DNN module

James Almer jamrial at gmail.com
Tue Jun 5 17:20:02 EEST 2018


On 6/3/2018 3:02 PM, Sergey Lavrushkin wrote:
> diff --git a/libavfilter/vf_srcnn.c b/libavfilter/vf_srcnn.c
> index d6efe9b478..5c5e26b33a 100644
> --- a/libavfilter/vf_srcnn.c
> +++ b/libavfilter/vf_srcnn.c
> @@ -41,7 +41,6 @@ typedef struct SRCNNContext {
>      DNNData input_output;
>  } SRCNNContext;
>  
> -
>  #define OFFSET(x) offsetof(SRCNNContext, x)
>  #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
>  static const AVOption srcnn_options[] = {
> @@ -55,10 +54,19 @@ static av_cold int init(AVFilterContext* context)
>  {
>      SRCNNContext* srcnn_context = context->priv;
>  
> -    srcnn_context->dnn_module = ff_get_dnn_module(DNN_NATIVE);
> +    srcnn_context->dnn_module = ff_get_dnn_module(DNN_TF);

This should be a filter AVOption, not hardcoded to one or another. What
if i, for whatever reason, want to use the native backend when i have
libtensorflow enabled?

>      if (!srcnn_context->dnn_module){
> -        av_log(context, AV_LOG_ERROR, "could not create dnn module\n");
> -        return AVERROR(ENOMEM);
> +        srcnn_context->dnn_module = ff_get_dnn_module(DNN_NATIVE);
> +        if (!srcnn_context->dnn_module){
> +            av_log(context, AV_LOG_ERROR, "could not create dnn module\n");
> +            return AVERROR(ENOMEM);
> +        }
> +        else{
> +            av_log(context, AV_LOG_INFO, "using native backend for DNN inference\n");

VERBOSE, not INFO

> +        }
> +    }
> +    else{
> +        av_log(context, AV_LOG_INFO, "using tensorflow backend for DNN inference\n");

Ditto.

>      }
>      if (!srcnn_context->model_filename){
>          av_log(context, AV_LOG_INFO, "model file for network was not specified, using default network for x2 upsampling\n");



More information about the ffmpeg-devel mailing list