Skip to content

Commit

Permalink
Update degradations.py because of torchvision.transforms.functional_t…
Browse files Browse the repository at this point in the history
…ensor 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
  • Loading branch information
atisandev committed May 12, 2024
1 parent c141d1f commit a615d97
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vqfr/data/degradations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import torch
from scipy import special
from scipy.stats import multivariate_normal
from torchvision.transforms.functional_tensor import rgb_to_grayscale
try:
from torchvision.transforms.functional import rgb_to_grayscale
except ImportError:
try:
from torchvision.transforms.functional_tensor import rgb_to_grayscale
except ImportError:
raise ImportError("Failed to import rgb_to_grayscale from torchvision. Ensure you have a compatible version of torchvision installed.")

# -------------------------------------------------------------------- #
# --------------------------- blur kernels --------------------------- #
Expand Down

0 comments on commit a615d97

Please sign in to comment.