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

run NMS on empty bounding box from one of ensembled models #54

Closed
ramdhan1989 opened this issue Aug 30, 2022 · 5 comments
Closed

run NMS on empty bounding box from one of ensembled models #54

ramdhan1989 opened this issue Aug 30, 2022 · 5 comments

Comments

@ramdhan1989
Copy link

Hi, I tried to ensemble 5 models. if there is no bounding box detected from one of 5 models, the nms gives error as follow :

ValueError                                Traceback (most recent call last)
Input In [39], in <cell line: 14>()
     12 lebar = dict_pred[img.split('\\')[-1].split('.')[0]]['image_width']
     13 tinggi = dict_pred[img.split('\\')[-1].split('.')[0]]['image_height']
---> 14 boxes, scores, labels = nms_method(bbox_list, conf_list, cat_list, method=2, weights=weights, iou_thr=0.3, sigma=0.05, thresh=0.001)

File ~\Anaconda3\envs\SiT\lib\site-packages\ensemble_boxes\ensemble_boxes_nms.py:187, in nms_method(boxes, scores, labels, method, iou_thr, sigma, thresh, weights)
    184             scores[i] = (np.array(scores[i]) * weights[i]) / weights.sum()
    186 # We concatenate everything
--> 187 boxes = np.concatenate(boxes)
    188 scores = np.concatenate(scores)
    189 labels = np.concatenate(labels)

File <__array_function__ internals>:5, in concatenate(*args, **kwargs)

ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 3 has 1 dimension(s)

If I used wbf method, it runs succesfully. is there any solution to run nms in this situation like wbf does. please advise

thank you
regards

@ZFTurbo
Copy link
Owner

ZFTurbo commented Aug 30, 2022

Can you put small example which fails?
I mean archive with files.

@ramdhan1989
Copy link
Author

this is an example


boxes_list = [
    [
        []
    ],
    [
        [0.04, 0.56, 0.84, 0.92]
    ],
]
scores_list = [
    [],
    [0.5]
]
labels_list = [
    [],
    [1]
]
weights = [2, 1]

boxes, scores, labels = nms_method(boxes_list, scores_list, labels_list, method=3, weights=weights, iou_thr=0.5, sigma=0.5, thresh=0.001)

@ZFTurbo
Copy link
Owner

ZFTurbo commented Sep 22, 2022

It was a little bit incorrect. boxes_list shouldn't contain anything if empty:

        boxes_list = [
            [
            ],
            [
                [0.04, 0.56, 0.84, 0.92]
            ],
        ]
        scores_list = [
            [],
            [0.5]
        ]
        labels_list = [
            [],
            [1]
        ]
        weights = [2, 1]

        boxes, scores, labels = nms_method(
            boxes_list,
            scores_list,
            labels_list,
            method=3,
            weights=weights,
            iou_thr=0.5,
            sigma=0.5,
            thresh=0.001
        )

I fixed the problem.

@ZFTurbo ZFTurbo closed this as completed Sep 22, 2022
@zhangxgu
Copy link

zhangxgu commented Oct 2, 2022

It was a little bit incorrect. boxes_list shouldn't contain anything if empty:

        boxes_list = [
            [
            ],
            [
                [0.04, 0.56, 0.84, 0.92]
            ],
        ]
        scores_list = [
            [],
            [0.5]
        ]
        labels_list = [
            [],
            [1]
        ]
        weights = [2, 1]

        boxes, scores, labels = nms_method(
            boxes_list,
            scores_list,
            labels_list,
            method=3,
            weights=weights,
            iou_thr=0.5,
            sigma=0.5,
            thresh=0.001
        )

I fixed the problem.

I meet this problem too. This example can not work for me, it still comes to the ValueError: all the input arrays must have same number of dimensions.
Hope you can give me some advice about how to fix it

@ZFTurbo
Copy link
Owner

ZFTurbo commented Oct 2, 2022

The fix is in repository alredy.

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