-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix PETR transforms and box handling to work with old checkpoints #2919
base: dev-1.x
Are you sure you want to change the base?
Conversation
Wow great catch. |
[scale_ratio, 0, 0, 0], | ||
[0, scale_ratio, 0, 0], | ||
[0, 0, scale_ratio, 0], | ||
[0, 0, 0, 1], | ||
]) | ||
|
||
rot_mat_inv = torch.inverse(rot_mat) | ||
scale_mat_inv = np.linalg.inverse(scale_mat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
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