Skip to content

fix: handle NHWC image format in wandb logging for train_pytorch.py#930

Open
enjoysport2022 wants to merge 1 commit intoPhysical-Intelligence:mainfrom
enjoysport2022:fix/wandb-image-nhwc-format
Open

fix: handle NHWC image format in wandb logging for train_pytorch.py#930
enjoysport2022 wants to merge 1 commit intoPhysical-Intelligence:mainfrom
enjoysport2022:fix/wandb-image-nhwc-format

Conversation

@enjoysport2022
Copy link
Copy Markdown

@enjoysport2022 enjoysport2022 commented Apr 18, 2026

Summary

  • Fix wandb image logging error "Un-supported shape [224, 9, 224]" when images are in NHWC format
  • Detect image format by checking first dimension (3 = NCHW, otherwise NHWC)
  • Rescale pixel values from [-1, 1] to [0, 1] range for wandb compatibility

Root Cause

The unified dataloader returns images in NHWC format [B, H, W, C] (consistent with JAX/LeRobot), but the wandb logging code assumed NCHW format and incorrectly applied permute(1, 2, 0), resulting in shape [W, C, H] which wandb cannot recognize.

Test Plan

  • Code passes ruff lint and format checks
  • Manual test with PyTorch training to verify wandb images display correctly

Fixes #877

The unified dataloader returns images in NHWC format [B, H, W, C], but the
wandb logging code assumed NCHW format and incorrectly applied permute(1,2,0),
resulting in "Un-supported shape [224, 9, 224]" error.

Changes:
- Detect image format by checking if first dim is 3 (NCHW) or not (NHWC)
- Only permute when image is actually in NCHW format
- Rescale pixel values from [-1, 1] to [0, 1] range for wandb compatibility
- Clip values to [0, 1] to avoid wandb warnings

Fixes Physical-Intelligence#877

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jimmyt857 jimmyt857 removed their request for review April 18, 2026 16:58
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.

train_pytorch.py: wandb image logging fails with "Un-supported shape [224, 9, 224]" when images are NHWC

1 participant