GFPGAN icon indicating copy to clipboard operation
GFPGAN copied to clipboard

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

Open seth-aung opened this issue 10 months ago • 8 comments

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

seth-aung avatar Feb 07 '25 01:02 seth-aung

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 avatar Feb 07 '25 19:02 SINGHBP29

Thank you. I'll try it.

seth-aung avatar Feb 07 '25 19:02 seth-aung

It works! Thanks @SINGHBP29

YoungSong99 avatar Mar 12 '25 06:03 YoungSong99

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 avatar Mar 29 '25 08:03 drkovalskyi

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

arshit09 avatar Apr 07 '25 22:04 arshit09

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 avatar Apr 13 '25 20:04 urlan

Thank you @drkovalskyi, that fixed the issue!

JeetDSharma avatar Jul 02 '25 16:07 JeetDSharma

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 avatar Sep 16 '25 08:09 kuschzzp