Skip to content

Commit

Permalink
fix torchvision dependency test (#1779)
Browse files Browse the repository at this point in the history
* fix torchvision dependency test

* update dependency check
  • Loading branch information
liopeer authored Jan 13, 2025
1 parent c25309c commit 5db25cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lightly/utils/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ def timm_vit_available() -> bool:

@functools.lru_cache(maxsize=1)
def torchvision_transforms_v2_available() -> bool:
"""Checks if torchvision supports the transforms.v2 API.
"""Checks if torchvision supports the v2 transforms API with the `tv_tensors`
module. Checking for the availability of the `transforms.v2` is not sufficient
since it is available in torchvision >= 0.15.1, but the `tv_tensors` module is
only available in torchvision >= 0.16.0.
Returns:
True if transforms.v2 are available, False otherwise
"""
try:
from torchvision.transforms import v2
from torchvision import tv_tensors
except ImportError:
return False
return True

0 comments on commit 5db25cf

Please sign in to comment.