Skip to content

Commit a615d97

Browse files
authored
Update degradations.py because of torchvision.transforms.functional_tensor deprecation in 2024 January
Since 2024 January v0.17.0 of torchvision, the module torchvision.transforms.functional_tensor is removed and the module torchvision.transforms.functional is available. https://github.com/pytorch/vision/releases/tag/v0.17.0 The code is proposed by @Elawfant in this issue of BasicSR: XPixelGroup/BasicSR#677
1 parent c141d1f commit a615d97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vqfr/data/degradations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
import torch
66
from scipy import special
77
from scipy.stats import multivariate_normal
8-
from torchvision.transforms.functional_tensor import rgb_to_grayscale
8+
try:
9+
from torchvision.transforms.functional import rgb_to_grayscale
10+
except ImportError:
11+
try:
12+
from torchvision.transforms.functional_tensor import rgb_to_grayscale
13+
except ImportError:
14+
raise ImportError("Failed to import rgb_to_grayscale from torchvision. Ensure you have a compatible version of torchvision installed.")
915

1016
# -------------------------------------------------------------------- #
1117
# --------------------------- blur kernels --------------------------- #

0 commit comments

Comments
 (0)