Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
src/excvish/ultralytics/augment.py
Outdated
| if len(new["class_labels"]) > 0: # skip update if no bbox in new im | ||
| labels["img"] = new["image"] | ||
| labels["cls"] = np.array(new["class_labels"]) | ||
| bboxes = np.array(new["bboxes"], dtype=np.float32) | ||
|
|
||
| # Update keypoints if they were transformed | ||
| if "keypoints" in new: | ||
| assert k is not None and dim is not None | ||
| kpts = new["keypoints"] / np.array([W, H]) # Normalize to [0, 1] | ||
| kpts = kpts.reshape(-1, k, dim - 1) | ||
| original_visibility = instances.keypoints[..., 2].reshape(-1, k, 1) | ||
|
|
||
| keypoints = np.concatenate([kpts, original_visibility], axis=-1).astype(np.float32) | ||
| else: | ||
| keypoints = None | ||
|
|
||
| instances.update(bboxes=bboxes, keypoints=keypoints) | ||
|
|
There was a problem hiding this comment.
Update Instances class labels alongside bboxes
After applying the Albumentations transform the code replaces labels["cls"] but calls instances.update with only bboxes and keypoints. When the transform drops or reorders detections, Instances.cls still contains the old labels and length, so the Instances object no longer has matching numbers of boxes and classes. Downstream consumers of Instances (e.g. target builders or visualization) expect bboxes and cls to stay aligned and can mislabel or raise shape errors. Pass the transformed class_labels to instances.update whenever you change the boxes.
Useful? React with 👍 / 👎.
0faf039 to
ce0af25
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
src/excvish/ultralytics/augment.py
Outdated
| if "keypoints" in new: | ||
| assert k is not None and dim is not None | ||
| kpts = new["keypoints"] / np.array([W, H]) # Normalize to [0, 1] | ||
| kpts = kpts.reshape(-1, k, dim - 1) | ||
| original_visibility = instances.keypoints[..., 2].reshape(-1, k, 1) | ||
|
|
||
| keypoints = np.concatenate([kpts, original_visibility], axis=-1).astype(np.float32) |
There was a problem hiding this comment.
Normalize transformed keypoints using resized dimensions
The Albumentations adapter divides new["keypoints"] by the original W/H captured before the transform. For any transform that changes the image size (resize, crop, pad) Albumentations returns keypoints in the resized coordinate space, so normalizing by the original dimensions scales them incorrectly while the image and bboxes are updated to the new size. This produces misaligned keypoints in training samples. Normalize using the width and height of new["image"] instead.
Useful? React with 👍 / 👎.
No description provided.