Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior of weighted_boxes_fusion #9

Closed
shonenkov opened this issue Jun 6, 2020 · 5 comments
Closed

Strange behavior of weighted_boxes_fusion #9

shonenkov opened this issue Jun 6, 2020 · 5 comments

Comments

@shonenkov
Copy link

shonenkov commented Jun 6, 2020

@ZFTurbo

boxes = [
    [[410, 464, 354, 410],
    [511, 89, 470, 32],
    [503, 213, 447, 166],
    [300, 444, 252, 391],
    [290, 184, 234, 133]],
    
    [[354, 412, 409, 463],
    [447, 165, 504, 212],
    [251, 392, 299, 444],
    [470, 35, 511, 90],
    [187, 316, 240, 378]],

    [[447, 166, 503, 213],
    [355, 412, 411, 464],
    [470, 33, 511, 88],
    [251, 391, 300, 444],
    [234, 132, 289, 184]],

    [[251, 391, 300, 445],
    [354, 412, 410, 463],
    [447, 166, 503, 212],
    [235, 134, 289, 184],
    [191, 316, 239, 380]],

    [[410, 465, 355, 412],
    [511, 88, 470, 33],
    [504, 213, 448, 167],
    [299, 444, 251, 392],
    [289, 185, 236, 133]]
]

scores = [
    [0.893,0.886,0.865,0.864,0.801],
    [0.915,0.881,0.873,0.852,0.844],
    [0.896, 0.895,0.860,0.855,0.801],
    [0.900,0.889,0.861,0.838,0.831],
    [0.897,0.877, 0.877,0.861,0.820],
]

labels = [
    [1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1]
]

wbf_boxes, wbf_scores, wbf_labels = ensemble_boxes.ensemble_boxes_wbf.weighted_boxes_fusion(boxes, scores, labels, weights=None, iou_thr=0.43, skip_box_thr=0.44)

wbf_boxes.shape
>>> (16, 4)

I think we see excess wbf_boxes, it is very strange. Picture with demonstration:

Без названия (1)

Python 3.7.6
numpy==1.18.1
ensemble_boxes==1.0.1

@ZFTurbo
Copy link
Owner

ZFTurbo commented Jun 6, 2020

Coordinates for boxes expected to be normalized e.g in range [0; 1]. Order: x1, y1, x2, y2.

I will add warning on such cases.

@shonenkov
Copy link
Author

@ZFTurbo no, it doesnt help!

wbf_boxes, wbf_scores, wbf_labels = ensemble_boxes.ensemble_boxes_wbf.weighted_boxes_fusion(
    (np.array(boxes)/511).tolist(),
    scores, 
    labels, 
    weights=None, 
    iou_thr=0.43, 
    skip_box_thr=0.44
)
wbf_boxes.shape
>>> (16, 4)

@ZFTurbo
Copy link
Owner

ZFTurbo commented Jun 6, 2020

x1 must be lower than x2 and y1 must be lower than y2. I will fix it next release.

@shonenkov
Copy link
Author

@ZFTurbo thank you! I will try it. I am looking forward to the new release :)

@shonenkov
Copy link
Author

@ZFTurbo thank you! it works for me, I have used temporary "hardcode" (maybe it helps anyone):

   def prepare_boxes(boxes):
        result_boxes = boxes.copy()
        result_boxes[:,0] = np.min(boxes[:, [0,2]], axis=1)
        result_boxes[:,2] = np.max(boxes[:, [0,2]], axis=1)
        result_boxes[:,1] = np.min(boxes[:, [1,3]], axis=1)
        result_boxes[:,3] = np.max(boxes[:, [1,3]], axis=1)
        return result_boxes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants