You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve updated the files inference_realesrgan_video.py and inference_realesrgan.py, which are key entry points, to dynamically handle missing functions without restricting the torchvision version. With these updates, it’s possible to remove the existing limitation on torchvision (and by extension, torch), allowing users to leverage the latest versions of both torch and CUDA.
This updated code:
import sys
import types
try:
# Check if `torchvision.transforms.functional_tensor` and `rgb_to_grayscale` are missing
from torchvision.transforms.functional_tensor import rgb_to_grayscale
except ImportError:
# Import `rgb_to_grayscale` from `functional` if it’s missing in `functional_tensor`
from torchvision.transforms.functional import rgb_to_grayscale
# Create a module for `torchvision.transforms.functional_tensor`
functional_tensor = types.ModuleType("torchvision.transforms.functional_tensor")
functional_tensor.rgb_to_grayscale = rgb_to_grayscale
# Add this module to `sys.modules` so other imports can access it
sys.modules["torchvision.transforms.functional_tensor"] = functional_tensor
Thanks for considering these improvements!
The text was updated successfully, but these errors were encountered:
Hi @xinntao,
I've submitted a pull request addressing the compatibility issue mentioned in issue #768. My changes can be reviewed in the following branch: wladradchenko/Real-ESRGAN.
I’ve updated the files inference_realesrgan_video.py and inference_realesrgan.py, which are key entry points, to dynamically handle missing functions without restricting the torchvision version. With these updates, it’s possible to remove the existing limitation on torchvision (and by extension, torch), allowing users to leverage the latest versions of both torch and CUDA.
This updated code:
Thanks for considering these improvements!
The text was updated successfully, but these errors were encountered: