ZFTurbo / Weighted-Boxes-Fusion

Set of methods to ensemble boxes from different object detection models, including implementation of "Weighted boxes fusion (WBF)" method.
MIT License
1.7k stars 237 forks source link

Strange result if boxes are intersected inside one model #40

Closed Sergey-Zlobin closed 2 years ago

Sergey-Zlobin commented 2 years ago

Example:

from ensemble_boxes import *

boxes_list = [[
    [0.1, 0.1, 0.2, 0.2],
    [0.1, 0.1, 0.2, 0.2],
], [
    [0.3, 0.3, 0.4, 0.4],
]]
scores_list = [[1.0, 1.0], [0.5]]
labels_list = [[0, 0], [0]]
weights = [2, 1]

iou_thr = 0.5
skip_box_thr = 0.0001

boxes, scores, labels = weighted_boxes_fusion(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr,
                                              skip_box_thr=skip_box_thr, allows_overflow=False
                                              )
print(scores)

Actual result: [1.33333337 0.16666667] Expected result: scores are <= 1.

Sergey-Zlobin commented 2 years ago

Workaround: use conf_type='box_and_model_avg' instead of default conf_type='avg'

ZFTurbo commented 2 years ago

This was fixed in pull request: https://github.com/ZFTurbo/Weighted-Boxes-Fusion/pull/25

But you need to change from 'avg' to '_box_and_modelavg'