Skip to content

Commit

Permalink
remove ToTensor() for later
Browse files Browse the repository at this point in the history
  • Loading branch information
liopeer committed Nov 5, 2024
1 parent aaeb94f commit 70af715
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions lightly/transforms/torchvision_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,3 @@
from torchvision import transforms as torchvision_transforms

Check warning on line 21 in lightly/transforms/torchvision_transforms.py

View check run for this annotation

Codecov / codecov/patch

lightly/transforms/torchvision_transforms.py#L20-L21

Added lines #L20 - L21 were not covered by tests

_TRANSFORMS_V2 = False

Check warning on line 23 in lightly/transforms/torchvision_transforms.py

View check run for this annotation

Codecov / codecov/patch

lightly/transforms/torchvision_transforms.py#L23

Added line #L23 was not covered by tests


def ToTensor() -> Union[torchvision_transforms.Compose, ToTensorV1]:
T = torchvision_transforms
if _TRANSFORMS_V2 and hasattr(T, "ToImage") and hasattr(T, "ToDtype"):
# v2.transforms.ToTensor is deprecated and will be removed in the future.
# This is the new recommended way to convert a PIL Image to a tensor since
# torchvision v0.16.
# See also https://github.com/pytorch/vision/blame/33e47d88265b2d57c2644aad1425be4fccd64605/torchvision/transforms/v2/_deprecated.py#L19
return T.Compose([T.ToImage(), T.ToDtype(dtype=torch.float32, scale=True)])
else:
return T.ToTensor()

0 comments on commit 70af715

Please sign in to comment.