Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'torchvision.transforms.functional_tensor' #841

Open
purgenetik opened this issue Aug 28, 2024 · 3 comments
Open

No module named 'torchvision.transforms.functional_tensor' #841

purgenetik opened this issue Aug 28, 2024 · 3 comments

Comments

@purgenetik
Copy link

This error is generated trying to run colab demo (step 3)
https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing

and any other code attempts give the same error
Any ideas how to fix it?

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'

@WallaceCCWong
Copy link

edit file "degradation.py" line 8 from:
from torchvision.transforms.functional_tensor import rgb_to_grayscale
to:
from torchvision.transforms._functional_tensor import rgb_to_grayscale

@VATHIAR
Copy link

VATHIAR commented Sep 3, 2024

for anyone found it difficult to find the file,

# Path to the file
file_path = '/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py'

# Open the file, read its contents, and replace the desired line
with open(file_path, 'r') as file:
    code = file.read()

# Replace the import line
modified_code = code.replace(
    "from torchvision.transforms.functional_tensor import rgb_to_grayscale",
    "from torchvision.transforms._functional_tensor import rgb_to_grayscale"
)

# Write the modified code back to the file
with open(file_path, 'w') as file:
    file.write(modified_code)

@amrakm
Copy link

amrakm commented Sep 27, 2024

or downgrade your torchvision to =0.14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants