Skip to content

Conversation

@zy1git
Copy link
Contributor

@zy1git zy1git commented Oct 31, 2025

Summary:
#9221 identifies a confusion around image shape conventions for ToTensor and PILToTensor classes. The docstring has the following statement:
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
This is confusing since PIL Image shape is not (H x W x C) but rather PIL Images expose their size as (W, H) via the size attribute, not as a shape tuple.
Proposed Docstring Update
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).

Differential Revision: D85779518

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 31, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9254

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit d678de1 with merge base 218d2ab (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the cla signed label Oct 31, 2025
@meta-codesync
Copy link

meta-codesync bot commented Oct 31, 2025

@zy1git has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85779518.

Summary:

pytorch#9221 identifies a confusion around image shape conventions for ToTensor and PILToTensor classes. The docstring has the following statement:
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
This is confusing since PIL Image shape is not (H x W x C) but rather PIL Images expose their size as (W, H) via the size attribute, not as a shape tuple.
Proposed Docstring Update
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).

Differential Revision: D85779518
zy1git pushed a commit to zy1git/vision that referenced this pull request Oct 31, 2025
Summary:

pytorch#9221 identifies a confusion around image shape conventions for ToTensor and PILToTensor classes. The docstring has the following statement:
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
This is confusing since PIL Image shape is not (H x W x C) but rather PIL Images expose their size as (W, H) via the size attribute, not as a shape tuple.
Proposed Docstring Update
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).

Reviewed By: AntoineSimoulin

Differential Revision: D85779518
zy1git pushed a commit to zy1git/vision that referenced this pull request Oct 31, 2025
Summary:

pytorch#9221 identifies a confusion around image shape conventions for ToTensor and PILToTensor classes. The docstring has the following statement:
Converts a PIL Image (H x W x C) to a Tensor of shape (C x H x W).
This is confusing since PIL Image shape is not (H x W x C) but rather PIL Images expose their size as (W, H) via the size attribute, not as a shape tuple.
Proposed Docstring Update
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).

Reviewed By: AntoineSimoulin

Differential Revision: D85779518
@meta-codesync meta-codesync bot merged commit cfbc5c2 into pytorch:main Oct 31, 2025
79 of 82 checks passed
@github-actions
Copy link

Hey @meta-codesync[bot]!

You merged this PR, but no labels were added.
The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants