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

Using different batch size leads to different results when running test.py #819

Closed
pprp opened this issue Jan 31, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@pprp
Copy link

pprp commented Jan 31, 2020

🐛 Bug

@glenn-jocher Thank you for your excellent work, but I encountered a bug.

I only have 39 pictures for testing.

If batch size > total number of pictures, the F1 score is 86.4% and map is 78.2%.

If batch size <total number of pictures, the F1 score is 85% and the map is 77.7%.

To Reproduce

Steps to reproduce the behavior:

  1. batch size = 64
python test.py --cfg cfg/yolov3.cfg --weights  weights/best.pt --batch-size 64

I got:

Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16276MB)
           device1 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16276MB)

               Class    Images   Targets         P         R   mAP@0.5        F1: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:11<00:00, 11.50s/it]
                 all        39        65     0.962     0.785     0.782     0.864

  1. batch size = 4
python test.py --cfg cfg/yolov3.cfg --weights  weights/best.pt --batch-size 4

I got:

Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16276MB)
           device1 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16276MB)

               Class    Images   Targets         P         R   mAP@0.5        F1: 100%|███████████████████████████████████████████████████████████████████████████| 10/10 [00:10<00:00,  1.09s/it]
                 all        39        65     0.927     0.785     0.777      0.85

Do you know where the problem is? Thank you very much!

@pprp pprp added the bug Something isn't working label Jan 31, 2020
@glenn-jocher
Copy link
Member

@pprp good investigation! This is actually not a bug, it is an effect of the rectangular inference that test.py runs. It orders batches by aspect ratio, grouping images of similar shapes into a batch, and applying the minimum letterbox required to that batch. That means that each of the batches have different letterboxed shapes. See rectangular inference #232

When you do batch-size 64, likely a square letterbox is applied. In any case, the differences should be very minor, as you see. If you had a larger group of test images your results would be even closer I believe.

@pprp
Copy link
Author

pprp commented Feb 1, 2020

Thank you very much for your explanation!

@pprp pprp closed this as completed Feb 1, 2020
@glenn-jocher
Copy link
Member

@pprp you're welcome! If you have any more questions or need further assistance, feel free to ask. Keep up the good work!

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

2 participants