Replace deprecated v2.ToTensor() with v2.ToImage() + v2.ToDtype(scale=True) - #1419
Open
xyf5432 wants to merge 1 commit into
Open
Replace deprecated v2.ToTensor() with v2.ToImage() + v2.ToDtype(scale=True)#1419xyf5432 wants to merge 1 commit into
xyf5432 wants to merge 1 commit into
Conversation
…=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>
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.
PR 正文
Fix #1418
Summary
Replaces the deprecated
v2.ToTensor()inlightx2v/models/runners/wan/wan_matrix_game2_runner.pywith the officially recommendedv2.ToImage()+v2.ToDtype(torch.float32, scale=True).v2.ToTensor()has emitted aUserWarningon construction since torchvision 0.15 (first release of the v2 namespace); the warning text explicitly recommends this exact replacement:Changes
lightx2v/models/runners/wan/wan_matrix_game2_runner.py:v2.ToTensor()→v2.ToImage()+v2.ToDtype(torch.float32, scale=True)inside the existingv2.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).