fix(train): handle NHWC images in wandb logging - #909
Closed
wadeKeith wants to merge 1 commit into
Closed
Conversation
jimmyt857
removed their request for review
March 29, 2026 06:45
Contributor
Author
|
Friendly ping — just checking in on this PR to see if you have any feedback. Happy to address any questions! 🙏 |
The dataloader may return images in NHWC format (matching JAX/LeRobot conventions), but the wandb logging code assumed NCHW. The unconditional permute(1, 2, 0) on NHWC images produced shapes like [224, 9, 224] after concatenation, which wandb cannot display. Now we detect the layout by checking the first dimension: if it is a small channel count (1 or 3), treat as NCHW and permute; otherwise assume NHWC and use as-is. Also normalise pixel values from [-1, 1] to [0, 1] when needed. Closes #877
wadeKeith
force-pushed
the
fix/wandb-image-nhwc-format
branch
from
May 9, 2026 11:21
2e996a2 to
609dc8d
Compare
Contributor
Author
|
@kvablack gentle ping — all CI is green, ready for review. Thanks! |
Contributor
Author
|
Friendly ping for review. Thanks! |
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.
What this PR does
Fixes wandb image logging crash when the dataloader returns images in NHWC format.
Problem
The unified dataloader in PyTorch mode may return observation images in NHWC
[B, H, W, C]layout (consistent with JAX/LeRobot conventions). The current wandb logging code unconditionally callspermute(1, 2, 0)assuming NCHW input. When images are already NHWC:Fix
Detect the image layout before permuting:
frame.shape[0]is a small channel count (1 or 3) → treat as NCHW, permute to NHWCAlso:
[-1, 1]to[0, 1]when needed, avoiding wandb range warningsChanges
scripts/train_pytorch.pyChecklist
Closes #877