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

Incorrect allows_overflow=False mode #38

Closed
Sergey-Zlobin opened this issue Sep 13, 2021 · 5 comments
Closed

Incorrect allows_overflow=False mode #38

Sergey-Zlobin opened this issue Sep 13, 2021 · 5 comments

Comments

@Sergey-Zlobin
Copy link
Contributor

Sergey-Zlobin commented Sep 13, 2021

Example:

from ensemble_boxes import *

weigths = [0.2, 0.2, 0.2, 0.2, 0.2]
pred_boxes = []
pred_scores = []
pred_labels = []
for _ in range(5):
    pred_boxes.append([[0.    , 0.    , 0.0001, 0.0001]])
    pred_scores.append([1.])
    pred_labels.append([0])

pred_boxes, pred_scores, pred_labels = weighted_boxes_fusion(
    pred_boxes,
    pred_scores,
    pred_labels,
    weights=weigths,
    iou_thr=0.4,
    skip_box_thr=0.,
    allows_overflow=False
)
print(pred_scores)

Actual result: score [0.2]
Expected result: score [1]

Probably we need to change the line
weighted_boxes[i][1] = weighted_boxes[i][1] * min(weights.sum(), len(clustered_boxes)) / weights.sum()
->
weighted_boxes[i][1] = weighted_boxes[i][1] * min(len(weights), len(clustered_boxes)) / weights.sum()

@Sergey-Zlobin
Copy link
Contributor Author

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

@ZFTurbo
Copy link
Owner

ZFTurbo commented Sep 15, 2021

Looks fine. Thank you

@shanggdlk
Copy link

Example:

from ensemble_boxes import *

weigths = [0.2, 0.2, 0.2, 0.2, 0.2]
pred_boxes = []
pred_scores = []
pred_labels = []
for _ in range(5):
    pred_boxes.append([[0.    , 0.    , 0.0001, 0.0001]])
    pred_scores.append([1.])
    pred_labels.append([0])

pred_boxes, pred_scores, pred_labels = weighted_boxes_fusion(
    pred_boxes,
    pred_scores,
    pred_labels,
    weights=weigths,
    iou_thr=0.4,
    skip_box_thr=0.,
    allows_overflow=False
)
print(pred_scores)

Actual result: score [0.2] Expected result: score [1]

Probably we need to change the line weighted_boxes[i][1] = weighted_boxes[i][1] * min(weights.sum(), len(clustered_boxes)) / weights.sum() -> weighted_boxes[i][1] = weighted_boxes[i][1] * min(len(weights), len(clustered_boxes)) / weights.sum()

Sorry, I didn't get the point of this line:

Probably we need to change the line 
weighted_boxes[i][1] = weighted_boxes[i][1] * min(**weights.sum()**, len(clustered_boxes)) / weights.sum() -> weighted_boxes[i][1] = weighted_boxes[i][1] * min(**len(weights),** len(clustered_boxes)) / weights.sum()

In the above example, weights.sum()=1, len(clustered_boxes)) = 1, len(weights) = 5. So both two lines have the same output, did I misunderstand something here?

Thank you!

@ZFTurbo
Copy link
Owner

ZFTurbo commented Oct 5, 2021

For line 1 variable is 1. For line 2 variable is 5. Why result must be the same?

@shanggdlk
Copy link

For line 1 variable is 1. For line 2 variable is 5. Why result must be the same?
my bad, misreading the variable. Thanks for the clarification!

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

3 participants