diff mbox series

[FFmpeg-devel,3/3] libavfilter/vf_dnn_detect: Use class confidence to filt boxes

Message ID 20240117072151.2155795-3-wenbin.chen@intel.com
State Accepted
Commit d52e8ed114301b44f2a1ff526c6164c43da35749
Headers show
Series [FFmpeg-devel,1/3] libavfilter/dnn_bakcend_openvino: Add automatic input/output detection | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Chen, Wenbin Jan. 17, 2024, 7:21 a.m. UTC
From: Wenbin Chen <wenbin.chen@intel.com>

Use class confidence instead of box_score to filt boxes, which is more
accurate. Class confidence is obtained by multiplying class probability
distribution and box_score.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavfilter/vf_dnn_detect.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Guo, Yejun Jan. 28, 2024, 1:38 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> wenbin.chen-at-intel.com@ffmpeg.org
> Sent: Wednesday, January 17, 2024 3:22 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 3/3] libavfilter/vf_dnn_detect: Use class
> confidence to filt boxes
> 
> From: Wenbin Chen <wenbin.chen@intel.com>
> 
> Use class confidence instead of box_score to filt boxes, which is more
> accurate. Class confidence is obtained by multiplying class probability
> distribution and box_score.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
Looks good to me, will push soon.
diff mbox series

Patch

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index caccbf7a12..2bf5ed7476 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -236,9 +236,6 @@  static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out
                     conf = post_process_raw_data(
                                 detection_boxes_data[cy * cell_w + cx + 4 * cell_w * cell_h]);
                 }
-                if (conf < conf_threshold) {
-                    continue;
-                }
 
                 if (is_NHWC) {
                     x = post_process_raw_data(detection_boxes_data[0]);
@@ -257,6 +254,9 @@  static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out
                     conf = conf * post_process_raw_data(
                                 detection_boxes_data[cy * cell_w + cx + (label_id + 5) * cell_w * cell_h]);
                 }
+                if (conf < conf_threshold) {
+                    continue;
+                }
 
                 bbox = av_mallocz(sizeof(*bbox));
                 if (!bbox)