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

Open
opened 2026-01-29 21:48:29 +00:00 by claunia · 8 comments
Owner

Originally created by @seth-aung on GitHub (Feb 7, 2025).

Traceback (most recent call last):
File "/content/GFPGAN/inference_gfpgan.py", line 7, in
from basicsr.utils import imwrite
File "/usr/local/lib/python3.11/dist-packages/basicsr/init.py", line 4, in
from .data import *
File "/usr/local/lib/python3.11/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.11/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.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/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.11/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'
ls: cannot access 'results/cmp': No such file or directory

Originally created by @seth-aung on GitHub (Feb 7, 2025). Traceback (most recent call last): File "/content/GFPGAN/inference_gfpgan.py", line 7, in <module> from basicsr.utils import imwrite File "/usr/local/lib/python3.11/dist-packages/basicsr/__init__.py", line 4, in <module> from .data import * File "/usr/local/lib/python3.11/dist-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 "/usr/local/lib/python3.11/dist-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 "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/basicsr/data/realesrgan_dataset.py", line 11, in <module> from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "/usr/local/lib/python3.11/dist-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' ls: cannot access 'results/cmp': No such file or directory
Author
Owner

@SINGHBP29 commented on GitHub (Feb 7, 2025):

Use the Below command to solve the error

  1. pip install --upgrade pip
  2. pip install torchvision
  3. pip install torchvision==0.21.0
  4. pip install torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cpu
  5. pip install torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu
  6. pip install --upgrade torch torchvision
  7. pip install torchvision==0.15.2
  8. pip install git+https://github.com/facebookresearch/pytorchvideo

These commands show attempts to:

  • Upgrade pip.
  • Install the latest torchvision.
  • Install specific versions of torchvision (0.21.0, 0.17.0, and 0.15.2).
  • Install torchvision with a specified index URL for CPU.
  • Install PyTorch and torchvision together with a specified index URL for CPU.
  • Install PyTorchVideo from GitHub.
@SINGHBP29 commented on GitHub (Feb 7, 2025): Use the Below command to solve the error 1. `pip install --upgrade pip` 2. `pip install torchvision` 3. `pip install torchvision==0.21.0` 4. `pip install torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cpu` 5. `pip install torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu` 6. `pip install --upgrade torch torchvision` 7. `pip install torchvision==0.15.2` 8. `pip install git+https://github.com/facebookresearch/pytorchvideo` These commands show attempts to: * Upgrade pip. * Install the latest torchvision. * Install specific versions of torchvision (0.21.0, 0.17.0, and 0.15.2). * Install torchvision with a specified index URL for CPU. * Install PyTorch and torchvision together with a specified index URL for CPU. * Install PyTorchVideo from GitHub.
Author
Owner

@seth-aung commented on GitHub (Feb 7, 2025):

Thank you. I'll try it.

@seth-aung commented on GitHub (Feb 7, 2025): Thank you. I'll try it.
Author
Owner

@YoungSong99 commented on GitHub (Mar 12, 2025):

It works! Thanks @SINGHBP29

@YoungSong99 commented on GitHub (Mar 12, 2025): It works! Thanks @SINGHBP29
Author
Owner

@drkovalskyi commented on GitHub (Mar 29, 2025):

I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in basicsr package and it's fixed already. Install it using

pip install basicsr-fixed

instead of pip install basicsr

@drkovalskyi commented on GitHub (Mar 29, 2025): I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in `basicsr` package and it's fixed already. Install it using ``` pip install basicsr-fixed ``` instead of `pip install basicsr`
Author
Owner

@arshit09 commented on GitHub (Apr 7, 2025):

I had to use both solutions,
pip install basicsr-fixed
thanks @drkovalskyi
and this.
thanks @abdulkarim1422

@arshit09 commented on GitHub (Apr 7, 2025): I had to use both solutions, `pip install basicsr-fixed` thanks @drkovalskyi and [this](https://github.com/TencentARC/GFPGAN/issues/603#issuecomment-2698790946). thanks @abdulkarim1422
Author
Owner

@urlan commented on GitHub (Apr 13, 2025):

I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in basicsr package and it's fixed already. Install it using

pip install basicsr-fixed

instead of pip install basicsr

It works properly.

@urlan commented on GitHub (Apr 13, 2025): > I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in `basicsr` package and it's fixed already. Install it using > > ``` > pip install basicsr-fixed > ``` > > instead of `pip install basicsr` It works properly.
Author
Owner

@JeetDSharma commented on GitHub (Jul 2, 2025):

Thank you @drkovalskyi, that fixed the issue!

@JeetDSharma commented on GitHub (Jul 2, 2025): Thank you @drkovalskyi, that fixed the issue!
Author
Owner

@kuschzzp commented on GitHub (Sep 16, 2025):

I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in basicsr package and it's fixed already. Install it using

pip install basicsr-fixed

instead of pip install basicsr

thanks

@kuschzzp commented on GitHub (Sep 16, 2025): > I think it's better to fix the core problem than trying to play with package versions, since it is likely to cause other problems. The problem is in `basicsr` package and it's fixed already. Install it using > > ``` > pip install basicsr-fixed > ``` > > instead of `pip install basicsr` **thanks**
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#520