Skip to content

[fix] an index error in browse dataset - #5

Merged
LoSealL merged 1 commit into
mainfrom
dev
Aug 12, 2025
Merged

[fix] an index error in browse dataset#5
LoSealL merged 1 commit into
mainfrom
dev

Conversation

@LoSealL

@LoSealL LoSealL commented Aug 12, 2025

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings August 12, 2025 10:41
@LoSealL
LoSealL merged commit 115d3ee into main Aug 12, 2025
0 of 11 checks passed
@LoSealL
LoSealL deleted the dev branch August 12, 2025 10:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants