Real-ESRGAN icon indicating copy to clipboard operation
Real-ESRGAN copied to clipboard

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

Open Haremakhet opened this issue 11 months ago • 7 comments

Traceback (most recent call last): File "/content/Real-ESRGAN/inference_realesrgan.py", line 5, in from basicsr.archs.rrdbnet_arch import RRDBNet File "/usr/local/lib/python3.10/dist-packages/basicsr/init.py", line 4, in from .data import * File "/usr/local/lib/python3.10/dist-packages/basicsr/data/init.py", line 22, in _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/usr/local/lib/python3.10/dist-packages/basicsr/data/init.py", line 22, in _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/local/lib/python3.10/dist-packages/basicsr/data/realesrgan_dataset.py", line 11, in from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py", line 8, in from torchvision.transforms.functional_tensor import rgb_to_grayscale ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

Haremakhet avatar Mar 14 '24 12:03 Haremakhet

go to the file show here "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py" do this change in the code - torchvision.transforms.functional import rgb_to_grayscale you have to replace it every single use

RohitPoul avatar Mar 14 '24 21:03 RohitPoul

go to the file show here "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py" do this change in the code - torchvision.transforms.functional import rgb_to_grayscale you have to replace it every single use

So does this imply that this repo wont function anymore without explicity changing this? At the same time colab wont work either?

tushar-31093 avatar Mar 15 '24 07:03 tushar-31093

`!nvidia-smi

from PIL import Image import cv2, os, subprocess from google.colab import drive from tqdm import tqdm

!git clone https://github.com/xinntao/Real-ESRGAN.git %cd Real-ESRGAN

with open('requirements.txt', 'w') as arquivo: arquivo.write("basicsr==1.3.5\ngfpgan>=1.3.5\nnumpy\nopencv-python\nPillow\ntorch>=1.7\ntorchvision\ntqdm\n")

!pip install facexlib ffmpeg ffmpeg-python !pip install -r requirements.txt !python setup.py develop

with open('/usr/local/lib/python3.10/dist-packages/basicsr-1.3.5-py3.10.egg/basicsr/data/degradations.py', 'r') as file: file_data = file.read() file_data = file_data.replace('from torchvision.transforms.functional_tensor import rgb_to_grayscale', 'from torchvision.transforms.functional import rgb_to_grayscale') with open('/usr/local/lib/python3.10/dist-packages/basicsr-1.3.5-py3.10.egg/basicsr/data/degradations.py', 'w') as file: file.write(file_data)

mount_drive=False #@param{type:"boolean"}

if mount_drive: drive.mount('/content/gdrive/')`

viniciusmods avatar Mar 15 '24 16:03 viniciusmods

I don't know why in Colab, whenever something gets updated, it always has to mess up everything else. To solve this problem, you need to execute this command.

!python -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118

After this, everything should work fine.

JossCamp avatar Mar 17 '24 02:03 JossCamp

go to the file show here "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py" do this change in the code - torchvision.transforms.functional import rgb_to_grayscale you have to replace it every single use

please give a proper video

rahulmahmud avatar Mar 17 '24 10:03 rahulmahmud

I don't know why in Colab, whenever something gets updated, it always has to mess up everything else. To solve this problem, you need to execute this command.

!python -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118

After this, everything should work fine.

Can confirm, this worked for me in colab.

eharsh2711 avatar Mar 20 '24 04:03 eharsh2711

I don't know why in Colab, whenever something gets updated, it always has to mess up everything else. To solve this problem, you need to execute this command.

!python -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118

After this, everything should work fine.

Can confirm, this worked for me in colab.

ERROR: Could not find a version that satisfies the requirement torch==2.0.1 (from versions: 2.2.0, 2.2.1, 2.2.2) ERROR: No matching distribution found for torch==2.0.1

m4ra7h0n avatar Apr 04 '24 14:04 m4ra7h0n