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

"dataloader.test.batch_size" > 1 when evaluation is not supported! #134

Open
wanghao9610 opened this issue Nov 16, 2022 · 12 comments
Open
Labels
bug Something isn't working

Comments

@wanghao9610
Copy link

wanghao9610 commented Nov 16, 2022

Hi:
I want to set "dataloader.test.batch_size = 16" (default is 1) to accelerate the evaluation speed. But, I get a much smaller mAP results, e.g. 0.59 vs 41.5 mAP. Is it the upper stream(detectron2)'s issue? Could you fix the issue?

@rentainhe
Copy link
Collaborator

Hi: I want to set "dataloader.test.batch_size = 16" (default is 1) to accelerate the evaluation speed. But, I get a much smaller mAP results, e.g. 0.09 vs 41.5 mAP. Is it the upper stream(detectron2)'s issue? Could you fix the issue?

We will check this problem later~

@rentainhe
Copy link
Collaborator

Hi: I want to set "dataloader.test.batch_size = 16" (default is 1) to accelerate the evaluation speed. But, I get a much smaller mAP results, e.g. 0.09 vs 41.5 mAP. Is it the upper stream(detectron2)'s issue? Could you fix the issue?

We will check this problem this weekend, sry for the long time waiting

@rentainhe
Copy link
Collaborator

rentainhe commented Nov 20, 2022

Hi: I want to set "dataloader.test.batch_size = 16" (default is 1) to accelerate the evaluation speed. But, I get a much smaller mAP results, e.g. 0.09 vs 41.5 mAP. Is it the upper stream(detectron2)'s issue? Could you fix the issue?

I was wondering which model you are used in this situation~ @wanghao9610

When setting test.batch_size > 1, the images of different image size will be padding into the same size as a batch input. And the padding part should be masked, however, for convenience, we ignored this situation before and used the same mask for each test image which may raise this issue, we will try to fix it.

@rentainhe rentainhe added the bug Something isn't working label Nov 20, 2022
@rentainhe
Copy link
Collaborator

Hi: I want to set "dataloader.test.batch_size = 16" (default is 1) to accelerate the evaluation speed. But, I get a much smaller mAP results, e.g. 0.09 vs 41.5 mAP. Is it the upper stream(detectron2)'s issue? Could you fix the issue?

You can try this solution if you're in a hurry by modifying the model like:

if self.training:
    batch_size, _, H, W = images.tensor.shape
    img_masks = images.tensor.new_ones(batch_size, H, W)
    for img_id in range(batch_size):
        img_h, img_w = batched_inputs[img_id]["instances"].image_size
        img_masks[img_id, :img_h, :img_w] = 0
else:
    batch_size, _, H, W = images.tensor.shape
    img_masks = images.tensor.new_ones(batch_size, H, W)
    for img_id in range(batch_size):
        img_h, img_w = images.image_sizes[img_id]
        img_masks[img_id, :(img_h-1), :(img_w-1)] = 0

@wanghao9610
Copy link
Author

Thanks for your immediate reply~ I will try your solution.

@wanghao9610
Copy link
Author

@rentainhe Hello, I have tried your provided solution, but I got the same much lower mAP result. Have you try it successfully?

@rentainhe
Copy link
Collaborator

rentainhe commented Nov 20, 2022

@rentainhe Hello, I have tried your provided solution, but I got the same much lower mAP result. Have you try it successfully?

I was wondering which model you're testing under this situation @wanghao9610

I tried this on DINO-R50 with test-batch=2 each GPU, got 49.2AP

@wanghao9610
Copy link
Author

wanghao9610 commented Nov 21, 2022

I run this on DN_DETR-R50 with you provided weight (dn_detr_r50_50ep.pth), setting "dataloader.test.batch_size=16" with 2gpus, got 0.59 AP. My tesing command as below: python ./tools/train_net.py --config-file projects/dn_detr/configs/dn_detr_r50_50ep.py --num-gpus 2 --eval-only train.init_checkpoint=work_dirs/dn_detr_r50_50ep/dn_detr_r50_50ep.pth train.output_dir=work_dirs/dn_detr_r50_50ep dataloader.test.batch_size=16. You could try this command and you will may get the result as same as my.

@rentainhe
Copy link
Collaborator

I run this on DN_DETR-R50 with you provided weight (dn_detr_r50_50ep.pth), setting "dataloader.test.batch_size=16" with 2gpus, got 0.59 AP. My tesing command as below: python ./tools/train_net.py --config-file projects/dn_detr/configs/dn_detr_r50_50ep.py --num-gpus 2 --eval-only train.init_checkpoint=work_dirs/dn_detr_r50_50ep/dn_detr_r50_50ep.pth train.output_dir=work_dirs/dn_detr_r50_50ep dataloader.test.batch_size=16. You could try this command and you will may get the result as same as my.

I will try to reproduce this issue later~

@ihavision
Copy link

ihavision commented Aug 11, 2023

Same problem. I also got <1% AP with DINO-R50 and dataloader.test.batch_size=8 on single GPU. The mask patch provided above doesn't make a difference.

@theneotopia
Copy link

Same problem, still not fixed yet.
Experimented with DETR-R50 (converted) on a single RTX 3090 GPU, I got 0.9675 AP with test.batch_size=16, 7.37 AP with test.batch_size=4, 18.79 AP with test.batch_size=2, and 42.0 AP with test.batch_size=1.
It seems that the evaluator only works correctly when the test.batch_size is set to 1.

@persistorkwj
Copy link

Isn't this BUG fixed yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants