Repository navigation
Fix colorized semantic segmentation normalization - #7216
AntoineRichard merged 1 commit into
Conversation
There was a problem hiding this comment.
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
imagesargument 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: |
There was a problem hiding this comment.
🔵 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 |
There was a problem hiding this comment.
🔵 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 SummaryThis PR fixes normalization of colorized semantic-segmentation observations while preserving raw semantic-ID maps.
Confidence Score: 5/5The 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
Reviews (1): Last reviewed commit: "Fix colorized semantic segmentation norm..." | Re-trigger Greptile |
mmichelis
left a comment
There was a problem hiding this comment.
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 |
# 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
## 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]>
Description
Fixes
mdp.image(normalize=True)returning colorized semantic-segmentation observations asuint8. The normalizer now recognizes the renderer contract for this output (RGBAuint8) and returns the same normalizedfloat32representation used for RGB-like images. Rawint32semantic-ID maps remain unchanged.No new dependencies.
Type of change
Screenshots
Not applicable.
Checklist
uv run isaaclab -fsource/<pkg>/changelog.d/for every touched packageCONTRIBUTORS.mdor my name already exists there