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

2d bbox wbf compute result error #56

Open VariableXX opened 1 year ago

VariableXX commented 1 year ago
from ensemble_boxes import *

box_list = [[[0.3186783194541931, 0.7567034912109375, 0.3458101451396942, 0.8225753173828125],
             [0.2893345057964325, 0.7414910888671875, 0.30395767092704773, 0.82741845703125],
             [0.08234874159097672, 0.7192938232421875, 0.10110706090927124, 0.7978226318359375],
             [0.03901633247733116, 0.6389908447265625, 0.08065500855445862, 0.794277587890625],
             [0.10205534100532532, 0.7005220947265625, 0.3009164333343506, 0.8869298095703125],
             [0.013241510838270187, 0.7410292358398437, 0.4873046875, 0.9892860717773437],
             [0.20103125274181366, 0.6678619384765625, 0.2735580503940582, 0.8197706298828125],
             [0.2807173728942871, 0.748069091796875, 0.34884029626846313, 0.8265133056640624]],
            [[499.8333263993263, 0.7574194946289062, 499.8582033813, 0.8213037719726562],
             [499.80139984190464, 0.744067626953125, 499.8154309540987, 0.83922900390625],
             [499.79503624141216, 0.7509530639648437, 499.86309084296227, 0.8289489135742187],
             [499.52070143818855, 0.7752119750976563, 500.0, 0.9840308227539063],
             [499.5126953125, 0.5068761901855469, 499.98771003447473, 0.74507958984375]],
            [[0.31953710317611694, 0.758130859375, 0.34634509682655334, 0.821462158203125],
             [0.2890157401561737, 0.7444622192382813, 0.3044307231903076, 0.8266027221679687],
             [0.008551719598472118, 0.4673032836914062, 0.36901113390922546, 0.7606300659179688],
             [0.0, 0.4736612548828125, 0.4354751706123352, 0.738594970703125],
             [0.004452536813914776, 0.7197838134765625, 0.4873046875, 1.0818572998046876],
             [0.0, 0.7836503295898437, 0.4873046875, 0.9610354614257812],
             [0.0, 0.4444543762207031, 0.4644381105899811, 0.7153197021484375],
             [0.0, 0.4595667419433594, 0.45853325724601746, 0.745251220703125]],
            [[0.31933701038360596, 0.7575816040039063, 0.3459422290325165, 0.8217849731445312],
             [0.2892712652683258, 0.742080322265625, 0.3039073348045349, 0.82669189453125],
             [0.08082691580057144, 0.7194573364257812, 0.10114574432373047, 0.7929706420898438],
             [0.014002567157149315, 0.73406103515625, 0.4873046875, 1.049856201171875],
             [0.0058621931821107864, 0.485712646484375, 0.39766108989715576, 0.765383544921875],
             [0.0058621931821107864, 0.485712646484375, 0.39766108989715576, 0.765383544921875],
             [0.0010756775736808777, 0.7905551147460937, 0.4873046875, 0.9734806518554687]],
            [[0.3187095522880554, 0.7571224365234375, 0.34541282057762146, 0.82177685546875],
             [0.2895776629447937, 0.7409693603515625, 0.3036201298236847, 0.8277974853515625],
             [0.09533613175153732, 0.6792424926757813, 0.2974565327167511, 0.8962586059570312],
             [0.08239483088254929, 0.720238525390625, 0.10080346465110779, 0.7970889892578125],
             [0.03715477138757706, 0.6399656372070313, 0.08126747608184814, 0.7963726196289063],
             [0.11268552392721176, 0.6827256469726563, 0.12404713779687881, 0.7254093627929687],
             [0.13349150121212006, 0.6368695678710937, 0.14964361488819122, 0.6750675659179688],
             [0.15557613968849182, 0.6638201904296875, 0.28306907415390015, 0.858079833984375],
             [0.01832456886768341, 0.7675958251953126, 0.47474271059036255, 0.944915283203125],
             [0.4468492865562439, 0.6279349975585937, 0.4620358347892761, 0.6685007934570313]],
            [[0.3194415271282196, 0.7588555908203125, 0.3447743058204651, 0.8150806884765625],
             [0.0741792619228363, 0.6543595581054688, 0.3116285800933838, 0.9023289184570312],
             [0.08234858512878418, 0.7222454223632813, 0.10103598982095718, 0.7950789184570313],
             [0.13459675014019012, 0.6382381591796875, 0.1480436772108078, 0.6662626953125],
             [0.28921717405319214, 0.738470703125, 0.3036784827709198, 0.8197808837890626],
             [0.007326365448534489, 0.7826550903320313, 0.4597592055797577, 0.9532874145507813],
             [0.0, 0.6689840087890625, 0.0, 0.70613916015625]]]

score_list = [[0.83423, 0.79483235, 0.6388512, 0.18261029, 0.14935824, 0.088351235, 0.08091657, 0.07652432],
              [0.879186, 0.60111153, 0.14815152, 0.14187415, 0.063758574],
              [0.5681963, 0.4344975, 0.31340924, 0.21414337, 0.14648718, 0.07502777, 0.06623978, 0.06619557],
              [0.7660579, 0.6813378, 0.24239238, 0.11751874, 0.11032326, 0.10366057, 0.074862376],
              [0.8430377, 0.82931787, 0.7683554, 0.6823021, 0.28933194, 0.18235974, 0.17097037, 0.09869627, 0.08994506, 0.079594925],
              [0.78075427, 0.7309819, 0.6295794, 0.48739368, 0.39831838, 0.073874675, 0.059466254]]

label_list = [[6, 6, 6, 7, 7, 9, 7, 6],
              [6, 6, 6, 9, 11],
              [6, 6, 13, 11, 13, 9, 8, 0],
              [6, 6, 6, 13, 11, 13, 9],
              [6, 6, 7, 6, 7, 6, 6, 7, 9, 6],
              [6, 7, 6, 6, 6, 9, 6]]

weights = [1, 1, 1, 1, 1, 1]
box_list, score_list, label_list = weighted_boxes_fusion(box_list, score_list, label_list,
                                                         weights=weights, iou_thr=0.5,
                                                         skip_box_thr=0.1)
print(box_list)
print(score_list)
print(label_list)

and the result is:

[[0.31910411 0.75763094 0.34561539 0.82052845]
 [0.28932601 0.7415092  0.30388758 0.82627851]
 [0.08219483 0.72045314 0.10099649 0.79627055]
 [0.08656451 0.67013788 0.3040534  0.89810479]
 [0.13430972 0.63788271 0.14845915 0.66854924]
 [0.03787507 0.63958848 0.0810305  0.79556197]
 [0.00788325 0.47187883 0.37613192 0.76181149]
 [0.00199323 0.47775888 0.42261785 0.74770349]
 [0.00870361 0.72613913 0.48730466 1.        ]
 [0.11268552 0.68272565 0.12404714 0.72540936]]
[0.63204601 0.52305063 0.36552083 0.2747826  0.10972734 0.07865704
 0.06951164 0.05407777 0.04400099 0.03039329]
[ 6.  6.  6.  7.  6.  7. 13. 11. 13.  6.]

The low confidence box that lower than 0.1 (skip_box_thr) not be filtrated.