Skip to content

Replace deprecated v2.ToTensor() with v2.ToImage() + v2.ToDtype(scale=True) - #1419

Open
xyf5432 wants to merge 1 commit into
ModelTC:mainfrom
xyf5432:fix-deprecated-v2-totensor
Open

Replace deprecated v2.ToTensor() with v2.ToImage() + v2.ToDtype(scale=True)#1419
xyf5432 wants to merge 1 commit into
ModelTC:mainfrom
xyf5432:fix-deprecated-v2-totensor

Conversation

@xyf5432

@xyf5432 xyf5432 commented Aug 23, 2026

Copy link
Copy Markdown

PR 正文

Fix #1418

Summary

Replaces the deprecated v2.ToTensor() in lightx2v/models/runners/wan/wan_matrix_game2_runner.py with the officially recommended v2.ToImage() + v2.ToDtype(torch.float32, scale=True).

v2.ToTensor() has emitted a UserWarning on construction since torchvision 0.15 (first release of the v2 namespace); the warning text explicitly recommends this exact replacement:

The transform ToTensor() is deprecated and will be removed in a future release. Instead, please use v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)]). Output is equivalent up to float precision.

Changes

  • lightx2v/models/runners/wan/wan_matrix_game2_runner.py: v2.ToTensor()v2.ToImage() + v2.ToDtype(torch.float32, scale=True) inside the existing v2.Compose.

Validation

Verified with torchvision 0.26.0 (CPU): the replacement pipeline constructs cleanly under -W error::UserWarning, and its output is identical to the old pipeline up to float precision (max abs diff ≈ 1e-7, single last-bit rounding on uint8→float32 scaling).

…=True)

v2.ToTensor() has emitted a UserWarning on construction since torchvision 0.15.
Use the officially recommended replacement (output equivalent up to float precision).

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Replace deprecated v2.ToTensor() in wan_matrix_game2_runner.py with v2.ToImage() + v2.ToDtype(scale=True)

1 participant