* [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if mandatory anchor option is missing
@ 2025-02-26 14:17 Leandro Santiago
2025-02-27 2:41 ` Chen, Wenbin
0 siblings, 1 reply; 3+ messages in thread
From: Leandro Santiago @ 2025-02-26 14:17 UTC (permalink / raw)
To: ffmpeg-devel
It prevents the filter of running in case such option is missing,
failing early, during init() instead of simply logging an error
during runtime.
It depends on this other change:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/6c4d8098-bb57-4f7c-b86b-9221492b7ced@gmail.com/
Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
---
libavfilter/vf_dnn_detect.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index cd70c64e98..bc9a1777ff 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -173,11 +173,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out
return AVERROR(EINVAL);
}
- if (!anchors) {
- av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n");
- return AVERROR(EINVAL);
- }
-
if (output[output_index].dims[1] * output[output_index].dims[2] *
output[output_index].dims[3] % (box_size * cell_w * cell_h)) {
av_log(filter_ctx, AV_LOG_ERROR, "wrong cell_w, cell_h or nb_classes\n");
@@ -656,6 +651,14 @@ static av_cold int dnn_detect_init(AVFilterContext *context)
DnnDetectContext *ctx = context->priv;
DnnContext *dnn_ctx = &ctx->dnnctx;
int ret;
+ int using_yolo = (ctx->model_type == DDMT_YOLOV3 ||
+ ctx->model_type == DDMT_YOLOV4 ||
+ ctx->model_type == DDMT_YOLOV1V2);
+
+ if (using_yolo && !ctx->anchors) {
+ av_log(ctx, AV_LOG_ERROR, "anchors is not set while being required for YOLO models\n");
+ return AVERROR(EINVAL);
+ }
ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context);
if (ret < 0)
--
2.48.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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if mandatory anchor option is missing
2025-02-26 14:17 [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if mandatory anchor option is missing Leandro Santiago
@ 2025-02-27 2:41 ` Chen, Wenbin
2025-03-03 11:29 ` Guo, Yejun
0 siblings, 1 reply; 3+ messages in thread
From: Chen, Wenbin @ 2025-02-27 2:41 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> It prevents the filter of running in case such option is missing,
> failing early, during init() instead of simply logging an error
> during runtime.
>
> It depends on this other change:
>
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/6c4d8098-bb57-4f7c-
> b86b-9221492b7ced@gmail.com/
>
> Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
> ---
> libavfilter/vf_dnn_detect.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
> index cd70c64e98..bc9a1777ff 100644
> --- a/libavfilter/vf_dnn_detect.c
> +++ b/libavfilter/vf_dnn_detect.c
> @@ -173,11 +173,6 @@ static int dnn_detect_parse_yolo_output(AVFrame
> *frame, DNNData *output, int out
> return AVERROR(EINVAL);
> }
>
> - if (!anchors) {
> - av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n");
> - return AVERROR(EINVAL);
> - }
> -
> if (output[output_index].dims[1] * output[output_index].dims[2] *
> output[output_index].dims[3] % (box_size * cell_w * cell_h)) {
> av_log(filter_ctx, AV_LOG_ERROR, "wrong cell_w, cell_h or
> nb_classes\n");
> @@ -656,6 +651,14 @@ static av_cold int dnn_detect_init(AVFilterContext
> *context)
> DnnDetectContext *ctx = context->priv;
> DnnContext *dnn_ctx = &ctx->dnnctx;
> int ret;
> + int using_yolo = (ctx->model_type == DDMT_YOLOV3 ||
> + ctx->model_type == DDMT_YOLOV4 ||
> + ctx->model_type == DDMT_YOLOV1V2);
> +
> + if (using_yolo && !ctx->anchors) {
> + av_log(ctx, AV_LOG_ERROR, "anchors is not set while being required for
> YOLO models\n");
> + return AVERROR(EINVAL);
> + }
>
> ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context);
> if (ret < 0)
> --
> 2.48.1
>
LGTM. Thanks
Wenbin
>
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if mandatory anchor option is missing
2025-02-27 2:41 ` Chen, Wenbin
@ 2025-03-03 11:29 ` Guo, Yejun
0 siblings, 0 replies; 3+ messages in thread
From: Guo, Yejun @ 2025-03-03 11:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Chen,
> Wenbin
> Sent: Thursday, February 27, 2025 10:41 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if
> mandatory anchor option is missing
>
> > It prevents the filter of running in case such option is missing,
> > failing early, during init() instead of simply logging an error during
> > runtime.
> >
> > It depends on this other change:
> >
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/6c4d8098-bb57-
> 4f7c-
> > b86b-9221492b7ced@gmail.com/
Will push with this link removed.
> >
> > Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
> > ---
> > libavfilter/vf_dnn_detect.c | 13 ++++++++-----
> > 1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
> > index cd70c64e98..bc9a1777ff 100644
> > --- a/libavfilter/vf_dnn_detect.c
> > +++ b/libavfilter/vf_dnn_detect.c
> > @@ -173,11 +173,6 @@ static int
> dnn_detect_parse_yolo_output(AVFrame
> > *frame, DNNData *output, int out
> > return AVERROR(EINVAL);
> > }
> >
> > - if (!anchors) {
> > - av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n");
> > - return AVERROR(EINVAL);
> > - }
> > -
> > if (output[output_index].dims[1] * output[output_index].dims[2] *
> > output[output_index].dims[3] % (box_size * cell_w * cell_h)) {
> > av_log(filter_ctx, AV_LOG_ERROR, "wrong cell_w, cell_h or
> > nb_classes\n"); @@ -656,6 +651,14 @@ static av_cold int
> > dnn_detect_init(AVFilterContext
> > *context)
> > DnnDetectContext *ctx = context->priv;
> > DnnContext *dnn_ctx = &ctx->dnnctx;
> > int ret;
> > + int using_yolo = (ctx->model_type == DDMT_YOLOV3 ||
> > + ctx->model_type == DDMT_YOLOV4 ||
> > + ctx->model_type == DDMT_YOLOV1V2);
> > +
> > + if (using_yolo && !ctx->anchors) {
> > + av_log(ctx, AV_LOG_ERROR, "anchors is not set while being
> > + required for
> > YOLO models\n");
> > + return AVERROR(EINVAL);
> > + }
> >
> > ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context);
> > if (ret < 0)
> > --
> > 2.48.1
> >
> LGTM. Thanks
>
> Wenbin
>
> >
> > _______________________________________________
> > 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".
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-03 11:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-26 14:17 [FFmpeg-devel] [PATCH] avfilter/dnn_detect: fail on filter if mandatory anchor option is missing Leandro Santiago
2025-02-27 2:41 ` Chen, Wenbin
2025-03-03 11:29 ` Guo, Yejun
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