Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an index error in the browse dataset functionality for MMSegmentation by correcting the tensor indexing pattern and updates the version number.
- Fixed incorrect tensor indexing that was causing an index error when browsing segmentation datasets
- Bumped version from 0.10.10 to 0.10.11
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mmengine/version.py | Version bump to 0.10.11 |
| mmengine/cli/tasks/browse_dataset.py | Fixed tensor indexing from gt_sem_seg[:, idx] to gt_sem_seg[idx] |
Comment on lines
107
to
109
| gt_sem_seg = data_sample.gt_sem_seg.data.copy() | ||
| for idx, img in enumerate(imgs): | ||
| if has_gt: |
There was a problem hiding this comment.
The indexing change from gt_sem_seg[:, idx] to gt_sem_seg[idx] appears correct for fixing the index error, but this assumes gt_sem_seg has the batch dimension first. However, without seeing the tensor shape or how gt_sem_seg is constructed, this change could potentially break other cases where the original indexing was correct. Consider adding a comment explaining the expected tensor shape or adding shape validation.
Suggested change
| gt_sem_seg = data_sample.gt_sem_seg.data.copy() | |
| for idx, img in enumerate(imgs): | |
| if has_gt: | |
| gt_sem_seg = data_sample.gt_sem_seg.data.copy() | |
| # Expect gt_sem_seg to have shape [batch, H, W] or [N, H, W]. | |
| # Validate shape to avoid indexing errors. | |
| assert gt_sem_seg.ndim == 3, ( | |
| f"Expected gt_sem_seg to have 3 dimensions [batch, H, W], " | |
| f"but got shape {gt_sem_seg.shape}" | |
| ) | |
| for idx, img in enumerate(imgs): | |
| if has_gt: | |
| # Assign the segmentation mask for the current image. |
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.
No description provided.