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

Reflect the changes of the default behavior of grid_sample and affine_grid #993

Merged
merged 2 commits into from
Jun 6, 2022

Conversation

malicd
Copy link
Contributor

@malicd malicd commented Jun 3, 2022

If PyTorch >= 1.3.0 align_corners will be set to False by default (but True is expected). This drastically reduces the SECONDIoU performance.

Evaluation of the KITTI model from the model zoo before changes:

Car AP@0.70, 0.70, 0.70:
bbox AP:89.7310, 88.8442, 88.5237
bev  AP:87.9080, 86.0925, 85.3315
3d   AP:84.9374, 76.3029, 75.9794
aos  AP:89.72, 88.73, 88.33
Car AP_R40@0.70, 0.70, 0.70:
bbox AP:94.6412, 93.1969, 91.1178
bev  AP:90.2307, 86.6130, 86.3666
3d   AP:86.7701, 79.2383, 77.1712
aos  AP:94.62, 93.06, 90.90
Car AP@0.70, 0.50, 0.50:
bbox AP:89.7310, 88.8442, 88.5237
bev  AP:89.8455, 92.4825, 88.7309
3d   AP:89.8455, 88.9443, 88.6950
aos  AP:89.72, 88.73, 88.33
Car AP_R40@0.70, 0.50, 0.50:
bbox AP:94.6412, 93.1969, 91.1178
bev  AP:94.7744, 94.6186, 93.4341
3d   AP:94.7605, 93.5132, 93.3093
aos  AP:94.62, 93.06, 90.90
Pedestrian AP@0.50, 0.50, 0.50:
bbox AP:52.6865, 50.1583, 48.8715
bev  AP:41.8535, 38.3748, 36.5096
3d   AP:37.2133, 34.9030, 32.1629
aos  AP:48.68, 46.20, 44.69
Pedestrian AP_R40@0.50, 0.50, 0.50:
bbox AP:51.2331, 48.3129, 46.9594
bev  AP:40.6510, 37.6296, 35.3592
3d   AP:36.4529, 33.5773, 31.1664
aos  AP:46.64, 43.80, 42.16
Pedestrian AP@0.50, 0.25, 0.25:
bbox AP:52.6865, 50.1583, 48.8715
bev  AP:55.4892, 54.5069, 53.4370
3d   AP:55.2917, 54.0297, 53.0834
aos  AP:48.68, 46.20, 44.69
Pedestrian AP_R40@0.50, 0.25, 0.25:
bbox AP:51.2331, 48.3129, 46.9594
bev  AP:54.4850, 53.4042, 51.6815
3d   AP:54.3276, 52.6706, 51.2269
aos  AP:46.64, 43.80, 42.16
Cyclist AP@0.50, 0.50, 0.50:
bbox AP:87.5908, 77.1372, 73.2886
bev  AP:84.6306, 66.8497, 63.4334
3d   AP:80.4156, 64.2871, 60.1949
aos  AP:87.18, 76.37, 72.42
Cyclist AP_R40@0.50, 0.50, 0.50:
bbox AP:89.8786, 77.8317, 74.4593
bev  AP:86.4507, 67.7289, 63.3873
3d   AP:83.1880, 63.7510, 60.2381
aos  AP:89.44, 77.03, 73.53
Cyclist AP@0.50, 0.25, 0.25:
bbox AP:87.5908, 77.1372, 73.2886
bev  AP:85.2689, 71.9390, 67.7767
3d   AP:85.2689, 71.9390, 67.7767
aos  AP:87.18, 76.37, 72.42
Cyclist AP_R40@0.50, 0.25, 0.25:
bbox AP:89.8786, 77.8317, 74.4593
bev  AP:87.2232, 72.4660, 68.5129
3d   AP:87.2232, 72.4660, 68.5129
aos  AP:89.44, 77.03, 73.53

and after changes:

Car AP@0.70, 0.70, 0.70:
bbox AP:90.8355, 89.8388, 89.2723
bev  AP:90.2623, 88.1195, 87.1185
3d   AP:89.2615, 79.0942, 78.1158
aos  AP:90.83, 89.77, 89.14
Car AP_R40@0.70, 0.70, 0.70:
bbox AP:95.8844, 94.2788, 92.0230
bev  AP:92.8479, 88.7489, 88.1442
3d   AP:91.5531, 82.3773, 79.6268
aos  AP:95.87, 94.19, 91.88
Car AP@0.70, 0.50, 0.50:
bbox AP:90.8355, 89.8388, 89.2723
bev  AP:90.8161, 93.6902, 89.4748
3d   AP:90.8161, 89.9144, 89.4485
aos  AP:90.83, 89.77, 89.14
Car AP_R40@0.70, 0.50, 0.50:
bbox AP:95.8844, 94.2788, 92.0230
bev  AP:95.8948, 95.8533, 94.3312
3d   AP:95.8869, 94.6650, 94.2326
aos  AP:95.87, 94.19, 91.88
Pedestrian AP@0.50, 0.50, 0.50:
bbox AP:71.1053, 66.2971, 63.3369
bev  AP:65.8997, 60.1765, 55.5646
3d   AP:61.3467, 55.7389, 51.2661
aos  AP:67.46, 62.55, 59.29
Pedestrian AP_R40@0.50, 0.50, 0.50:
bbox AP:71.7175, 66.8540, 63.0351
bev  AP:65.8063, 59.5335, 54.5955
3d   AP:61.1209, 54.5565, 49.4976
aos  AP:67.67, 62.70, 58.59
Pedestrian AP@0.50, 0.25, 0.25:
bbox AP:71.1053, 66.2971, 63.3369
bev  AP:76.8669, 73.8688, 69.7325
3d   AP:76.7553, 73.6554, 69.5219
aos  AP:67.46, 62.55, 59.29
Pedestrian AP_R40@0.50, 0.25, 0.25:
bbox AP:71.7175, 66.8540, 63.0351
bev  AP:78.2582, 74.9524, 70.8233
3d   AP:78.1487, 74.7087, 70.5867
aos  AP:67.67, 62.70, 58.59
Cyclist AP@0.50, 0.50, 0.50:
bbox AP:91.1650, 80.3305, 75.6053
bev  AP:90.7041, 73.7771, 68.5652
3d   AP:86.7106, 71.3100, 65.0472
aos  AP:90.99, 79.94, 75.16
Cyclist AP_R40@0.50, 0.50, 0.50:
bbox AP:94.9268, 81.9768, 77.7136
bev  AP:93.5079, 74.8429, 69.8322
3d   AP:90.6940, 71.2502, 66.2613
aos  AP:94.75, 81.54, 77.23
Cyclist AP@0.50, 0.25, 0.25:
bbox AP:91.1650, 80.3305, 75.6053
bev  AP:90.1900, 78.2873, 73.5401
3d   AP:90.1900, 78.2873, 73.5401
aos  AP:90.99, 79.94, 75.16
Cyclist AP_R40@0.50, 0.25, 0.25:
bbox AP:94.9268, 81.9768, 77.7136
bev  AP:93.7524, 78.8351, 75.0348
3d   AP:93.7524, 78.8351, 75.0348
aos  AP:94.75, 81.54, 77.23

…_grid. If PyTorch > 1.3.0 align_corners will be set to False by default. This is undesired behavior.
@jihanyang
Copy link
Collaborator

jihanyang commented Jun 4, 2022

Hello, thanks for feedback. Actually, we also notice this recently. Since our OpenPCDet should support pytorch >=1.1, the affine_grid and grid_sample do not have the align_corners keyword in pytorch<=1.3. It would be better for you to add these code in the init function to support more pytorch version

        if torch.__version__ >= '1.3':
            self.affine_grid = partial(nn.functional.affine_grid, align_corners=True)
            self.grid_sample = partial(nn.functional.grid_sample, align_corners=True)
        else:
            self.affine_grid = nn.functional.affine_grid
            self.grid_sample = nn.functional.grid_sample

@malicd
Copy link
Contributor Author

malicd commented Jun 5, 2022

Hi, the last commit supports earlier PyTorch versions as well.

@jihanyang jihanyang merged commit dadda9e into open-mmlab:master Jun 6, 2022
@OpenMMLab-Assistant-007
Copy link

Hi @malicd !
First of all, we want to express our gratitude for your significant PR in the OpenMMLab project. Your contribution is highly appreciated, and we are grateful for your efforts in helping improve this open-source project during your personal time. We believe that many developers will benefit from your PR.

We would also like to invite you to join our Special Interest Group (SIG) private channel on Discord, where you can share your experiences, ideas, and build connections with like-minded peers. To join the SIG channel, simply message moderator— OpenMMLab on Discord or briefly share your open-source contributions in the #introductions channel and we will assist you. Look forward to seeing you there! Join us :https://discord.gg/UjgXkPWNqA

If you have WeChat account,welcome to join our community on WeChat. You can add our assistant :openmmlabwx. Please add "mmsig + Github ID" as a remark when adding friends:)
Thank you again for your contribution❤

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

Successfully merging this pull request may close these issues.

3 participants