Summary
lightx2v/models/runners/wan/wan_matrix_game2_runner.py:160 (WanSFMtxg2Runner.__init__) instantiates torchvision.transforms.v2.ToTensor(), which is a deprecated alias: constructing it emits a UserWarning on every instantiation:
self.frame_process = v2.Compose(
[
v2.Resize(size=(352, 640), antialias=True),
v2.ToTensor(), # ← emits UserWarning on construction
v2.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
]
)
Warning text (verified on torchvision 0.26.0):
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)]).
This warning has been present since torchvision 0.15 (when the v2 namespace was introduced) — torchvision/transforms/v2/_deprecated.py has called warnings.warn in ToTensor.__init__ since the first release. Because WanSFMtxg2Runner is constructed when the runner is registered, every run of this runner surfaces the warning.
Proposed fix
Replace v2.ToTensor() with the officially recommended equivalent inside the same v2.Compose:
self.frame_process = v2.Compose(
[
v2.Resize(size=(352, 640), antialias=True),
v2.ToImage(),
v2.ToDtype(torch.float32, scale=True),
v2.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
]
)
Validation (torchvision 0.26.0+cpu)
v2.ToTensor()(img) and v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])(img) produce identical output up to float precision: max abs diff = 5.96e-8 (a single last-bit rounding difference on uint8→float32 scaling; the official deprecation message itself states "Output is equivalent up to float precision").
- The full pipeline (Resize + ToTensor/ToImage+ToDtype + Normalize) produces the same outputs (max diff 5.96e-8).
- With
warnings.simplefilter("error", UserWarning): the current code raises the deprecation UserWarning; the proposed pipeline constructs and runs cleanly.
Impact
- No deprecation
UserWarning when instantiating the Matrix-Game-2 runner; no behavior change to preprocessing.
References
- torchvision docs: v2.ToTensor (deprecated) — "[DEPRECATED] Use
v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)]) instead."
- torchvision 0.16 release notes — v2 transforms design stabilized;
ToImage/ToDtype introduced as the recommended replacement.
- torchvision source
torchvision/transforms/v2/_deprecated.py — warnings.warn in ToTensor.__init__, present since 0.15.
Summary
lightx2v/models/runners/wan/wan_matrix_game2_runner.py:160(WanSFMtxg2Runner.__init__) instantiatestorchvision.transforms.v2.ToTensor(), which is a deprecated alias: constructing it emits aUserWarningon every instantiation:Warning text (verified on torchvision 0.26.0):
This warning has been present since torchvision 0.15 (when the v2 namespace was introduced) —
torchvision/transforms/v2/_deprecated.pyhas calledwarnings.warninToTensor.__init__since the first release. BecauseWanSFMtxg2Runneris constructed when the runner is registered, every run of this runner surfaces the warning.Proposed fix
Replace
v2.ToTensor()with the officially recommended equivalent inside the samev2.Compose:Validation (torchvision 0.26.0+cpu)
v2.ToTensor()(img)andv2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])(img)produce identical output up to float precision: max abs diff = 5.96e-8 (a single last-bit rounding difference on uint8→float32 scaling; the official deprecation message itself states "Output is equivalent up to float precision").warnings.simplefilter("error", UserWarning): the current code raises the deprecationUserWarning; the proposed pipeline constructs and runs cleanly.Impact
UserWarningwhen instantiating the Matrix-Game-2 runner; no behavior change to preprocessing.References
v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])instead."ToImage/ToDtypeintroduced as the recommended replacement.torchvision/transforms/v2/_deprecated.py—warnings.warninToTensor.__init__, present since 0.15.