Fix colorize_bbox_3d to return correct shape#1859
Open
ubless607 wants to merge 1 commit intoStanfordVL:mainfrom
Open
Fix colorize_bbox_3d to return correct shape#1859ubless607 wants to merge 1 commit intoStanfordVL:mainfrom
ubless607 wants to merge 1 commit intoStanfordVL:mainfrom
Conversation
The `colorize_bbox_3d` function is expected to return an array of shape `(N, 8, 3)`. Since `world_points_homo` is shape `(N, 4)` and `view_proj_mat` is `(4, 4)`, the matrix multiplication is required.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the world_to_image_pinhole function where incorrect matrix operations were producing wrong output shapes. The function is expected to return an array of shape (N, 8, 3) but was using th.dot instead of proper matrix multiplication.
Key Changes
- Replaced
th.dotwithth.matmulfor proper matrix multiplication betweenworld_points_homoandview_proj_mat
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| view_proj_mat = view_mat @ proj_mat | ||
| world_points_homo = th.nn.functional.pad(world_points, (0, 1, 0, 0), value=1.0) | ||
| tf_points = th.dot(world_points_homo, view_proj_mat) | ||
| tf_points = th.matmul(world_points_homo, view_proj_mat) |
There was a problem hiding this comment.
The fix correctly addresses the shape issue. However, th.matmul with these shapes will produce (N, 4) output, not (N, 8, 3) as mentioned in the description. The actual shape depends on the input world_points dimensions. Consider verifying the expected input shape matches the desired output shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
colorize_bbox_3dfunction is expected to return an array of shape(N, 8, 3).Since
world_points_homois shape(N, 4)andview_proj_matis(4, 4), the matrix multiplication is required.