Skip to content

Refactor: extract shared affine helpers for keypoints and bbox#9355

Open
raimbekovm wants to merge 5 commits intopytorch:mainfrom
raimbekovm:refactor/unify-affine-keypoints-bbox
Open

Refactor: extract shared affine helpers for keypoints and bbox#9355
raimbekovm wants to merge 5 commits intopytorch:mainfrom
raimbekovm:refactor/unify-affine-keypoints-bbox

Conversation

@raimbekovm
Copy link
Contributor

Summary

Extracts shared logic from _affine_keypoints_with_expand and _affine_bounding_boxes_with_expand into two helper functions, addressing the TODO added in PR #8817.

Changes

Added two helper functions:

  • _create_affine_matrix() - creates transposed affine matrix for point transformation
  • _apply_affine_expand() - computes translation and new canvas size for expand mode

Both _affine_keypoints_with_expand and _affine_bounding_boxes_with_expand now use these helpers, reducing code duplication.

No functional changes - outputs are identical to before.

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 26, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9355

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 1991aaa with merge base df421b4 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the cla signed label Jan 26, 2026
@raimbekovm
Copy link
Contributor Author

Tried to fix the TorchScript type error by casting angle to float before passing to _get_inverse_affine_matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants