Skip to content

Fix colorized semantic segmentation normalization - #7216

Merged
AntoineRichard merged 1 commit into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-colorized-segmentation-normalization
Aug 21, 2026
Merged

AntoineRichard merged 1 commit into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-colorized-segmentation-normalization

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Fixes mdp.image(normalize=True) returning colorized semantic-segmentation observations as uint8. The normalizer now recognizes the renderer contract for this output (RGBA uint8) and returns the same normalized float32 representation used for RGB-like images. Raw int32 semantic-ID maps remain unchanged.

No new dependencies.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Not applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab -f
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@AntoineRichard
AntoineRichard requested a review from a team August 20, 2026 13:21
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Aug 20, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The normalization change correctly routes uint8 colorized semantic-segmentation output through the RGB-like path while preserving raw semantic-ID passthrough. Before merge, the public docstring should be corrected to match the uint8-only dispatch and restore valid argument-description indentation.

  • Design and architecture: Reusing the existing RGB-like normalization branch keeps the Warp fast path and PyTorch fallback centralized. The uint8 predicate appropriately distinguishes colorized semantic segmentation from raw ID maps.
  • API: The function signature is unchanged, but the updated public documentation incorrectly says colorized semantic segmentation of any other dtype takes the PyTorch fallback; the implementation only enters that branch for uint8 input. The images argument continuation is also mis-indented and may render incorrectly in generated API documentation.
  • Implementation: The dispatch predicate and regression test support the intended uint8 RGBA behavior, while existing float and raw-ID inputs remain passthrough values. The required fixes are limited to the changed docstring wording and indentation.

Minor fixes needed. Posted 2 actionable findings inline.

Automated review; human maintainers own approval decisions.

``channel_dim`` are forwarded so callers can reuse a pre-allocated float32 buffer and
select the image layout.
- :func:`is_rgb_like` and any other dtype/shape: pure-PyTorch ``(x.float() / 255.0) - mean``
- :func:`is_rgb_like` or colorized ``"semantic_segmentation"`` and any other dtype/shape:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Suggestion · Api — Documented segmentation fallback broader than code

The dispatch bullet states colorized semantic_segmentation with "any other dtype/shape" takes the PyTorch (x/255)-mean fallback, but line 86 enters the branch only when the dtype is uint8. A caller passing a pre-floated RGBA segmentation tensor gets it back unchanged, as the existing passthrough test asserts. Qualify the documented condition as uint8-only, with shape/contiguity selecting the fallback.

images: The camera-observation tensor. Shape and dtype vary by ``data_type``; the
RGB-like Warp fast path requires 4D contiguous uint8 with the channel axis at
position ``channel_dim``.
RGB-like and colorized semantic-segmentation Warp fast paths require 4D contiguous uint8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Suggestion · Implementation — Malformed Args indentation in public docstring

The continuation line for the images argument is dedented to the same level as the parameter name. Google-style/Napoleon parses Args: entries by indentation, so this line is treated as a new entry instead of part of the images description, garbling the rendered docs for this public function. Re-indent lines 70-71 under images:.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes normalization of colorized semantic-segmentation observations while preserving raw semantic-ID maps.

  • Extends RGB-like normalization to uint8 semantic-segmentation tensors.
  • Adds an RGBA test covering normalized float32 output.
  • Documents the fix in a changelog fragment.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The dtype-gated dispatch matches the renderer distinction between uint8 RGBA colorized output and integer raw semantic IDs, and the shared normalization implementation supports four-channel tensors.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/utils/images.py Correctly routes uint8 colorized semantic segmentation through channel-agnostic image normalization while leaving integer raw-ID maps unchanged.
source/isaaclab/test/utils/test_images.py Adds focused coverage for four-channel uint8 semantic segmentation and verifies values and float32 output.
source/isaaclab/changelog.d/normalize-colorized-semantic-segmentation.rst Accurately documents the user-visible normalization fix.

Reviews (1): Last reviewed commit: "Fix colorized semantic segmentation norm..." | Re-trigger Greptile

@mmichelis mmichelis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In practice the normalize might be called on warp arrays as well, could they? These changes currently only work for torch tensors, is that intended?

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

In practice the normalize might be called on warp arrays as well, could they? These changes currently only work for torch tensors, is that intended?

No that function clearly looks torch only for now:

    if is_rgb_like(data_type):
    if is_rgb_like(data_type) or (data_type == "semantic_segmentation" and images.dtype == torch.uint8):
        if images.dtype == torch.uint8 and images.ndim == 4 and images.is_contiguous():
            return normalize_image_uint8(images, channel_dim=channel_dim, out=out)
        # PyTorch fallback for callers that pre-floated or pass a strided view.
        resolved_channel_dim = channel_dim + images.ndim if channel_dim < 0 else channel_dim
        spatial_dims = tuple(d for d in range(1, images.ndim) if d != resolved_channel_dim)
        images = images.float() / 255.0
        images -= torch.mean(images, dim=spatial_dims, keepdim=True)
        return images
    if is_depth_like(data_type):
        images[images == float("inf")] = 0
        return images
    if is_normals_like(data_type):
        return (images + 1.0) * 0.5
    return images

@AntoineRichard
AntoineRichard merged commit 0451444 into isaac-sim:develop Aug 21, 2026
76 of 78 checks passed
AntoineRichard added a commit that referenced this pull request Aug 21, 2026
# Description

Fixes `mdp.image(normalize=True)` returning colorized
semantic-segmentation observations as `uint8`. The normalizer now
recognizes the renderer contract for this output (RGBA `uint8`) and
returns the same normalized `float32` representation used for RGB-like
images. Raw `int32` semantic-ID maps remain unchanged.

No new dependencies.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Screenshots

Not applicable.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the pre-commit checks with `uv run isaaclab -f`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
kellyguo11 added a commit that referenced this pull request Aug 22, 2026
## Description

Bundled backport to `release/3.0.0` to reduce CI load.

Source PRs reviewed for this bundle:

- #7020 — already represented in `release/3.0.0`; its cherry-pick was
empty, so no duplicate commit was added.
- #7207
- #7229
- #7227
- #7231
- #6762
- #7208
- #7168 — backports the current PR head while the source PR is still
open.
- #7157
- #7216

## Type of change

- Bug fix
- Documentation update
- Workflow / packaging update

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run formatting checks.
- [x] Documentation changes are included.
- [x] Documentation build generates no new warnings.
- [x] Focused regression coverage passed.
- [x] Required changelog fragments are included by the source PRs.
- [x] Contributors are already listed or included by the source PRs.

---------

Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Mustafa H <[email protected]>
Co-authored-by: Richard Lei <[email protected]>
Co-authored-by: Mustafa Haiderbhai <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants