xinntao / Real-ESRGAN

Real-ESRGAN aims at developing Practical Algorithms for General Image/Video Restoration.
BSD 3-Clause "New" or "Revised" License
28.31k stars 3.56k forks source link

ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor' #783

Open Matthew-3 opened 6 months ago

Matthew-3 commented 6 months ago

Anyone knows what's happened? C:\Users\......\Desktop\tmp\tmp>python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance Traceback (most recent call last): File "C:\Users\......\Desktop\tmp\tmp\inference_realesrgan.py", line 5, in <module> from basicsr.archs.rrdbnet_arch import RRDBNet File "D:\Python\Python311\Lib\site-packages\basicsr\__init__.py", line 4, in <module> from .data import * File "D:\Python\Python311\Lib\site-packages\basicsr\data\__init__.py", line 22, in <module> _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Python311\Lib\site-packages\basicsr\data\__init__.py", line 22, in <listcomp> _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Python311\Lib\site-packages\basicsr\data\realesrgan_dataset.py", line 11, in <module> from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "D:\Python\Python311\Lib\site-packages\basicsr\data\degradations.py", line 8, in <module> from torchvision.transforms.functional_tensor import rgb_to_grayscale ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

o7451 commented 6 months ago

alter to torchvision.transforms. “_” functional_tensor torchvision.transforms._functional_tensor

VIPJoey commented 6 months ago

alter to torchvision.transforms. “_” functional_tensor torchvision.transforms._functional_tensor

That's help for me.

vim /root/miniconda3/envs/ESRGAN/lib/python3.8/site-packages/basicsr/data/degradations.py

and then replace these code from torchvision.transforms.functional_tensor import rgb_to_grayscale to from torchvision.transforms._functional_tensor import rgb_to_grayscale