Fix PETR transforms and box handling to work with old checkpoints#2919
Fix PETR transforms and box handling to work with old checkpoints#2919carlinds wants to merge 2 commits intoopen-mmlab:dev-1.xfrom
Conversation
|
Wow great catch. |
| ]) | ||
|
|
||
| rot_mat_inv = torch.inverse(rot_mat) | ||
| scale_mat_inv = np.linalg.inverse(scale_mat) |
There was a problem hiding this comment.
np.linalg.inverse() does not exist AttributeError: module 'numpy.linalg' has no attribute 'inverse'
Should be np.linalg.inv()
| rot_mat = np.array([[rot_cos, rot_sin, 0, 0], | ||
| [-rot_sin, rot_cos, 0, 0], [0, 0, 1, 0], | ||
| [0, 0, 0, 1]]) | ||
| rot_mat_inv = np.linalg.inverse(rot_mat) |
|
I trained PETR with the current code and with the suggestions in this PR. Both versions end up at the same metrics with only marginal differences: vs. I would not merge this PR, but rather provide new weights for the current setup. |
|
here's a little weight conversion script - import torch
ckpt = torch.load('weights/petr.pth')
keys = [
'pts_bbox_head.reg_branches.0.4.weight',
'pts_bbox_head.reg_branches.1.4.weight',
'pts_bbox_head.reg_branches.2.4.weight',
'pts_bbox_head.reg_branches.3.4.weight',
'pts_bbox_head.reg_branches.4.4.weight',
'pts_bbox_head.reg_branches.5.4.weight',
]
for k in keys:
orig = ckpt['state_dict'][k]
# weights are (10, 256)
modified = orig.clone()
modified[2:3] = orig[3:4]
modified[3:4] = orig[2:3]
ckpt['state_dict'][k] = modified
torch.save(ckpt, 'weights/petr_fixed.pth') |
Providing new weights would also suffice. However, I would still suggest keeping some of the fixes in this request (such as the incorrect rotation, misleading naming and unnecessary conversion between torch and numpy). |
Motivation
Current version of the PETR-project does not produce the reported metrics (see #2510 for more details). The current state of the project has the following issues:
Modification
This PR fixes:
Results from testing the PR on nuScenes validation set (with the old checkpoint):
Log from the test: 20240305_103838.log