GFPGAN icon indicating copy to clipboard operation
GFPGAN copied to clipboard

torchvision.transforms.functional_tensor import rgb_to_grayscale

Open misssunitaparker opened this issue 1 year ago • 7 comments

Traceback (most recent call last): File "E:\SOFT\GFPGAN\GFPGAN\inference_gfpgan.py", line 7, in from basicsr.utils import imwrite File "C:\Users\MKN\anaconda3\Lib\site-packages\basicsr_init_.py", line 4, in from .data import * File "C:\Users\MKN\anaconda3\Lib\site-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 "C:\Users\MKN\anaconda3\Lib\site-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 "C:\Users\MKN\anaconda3\Lib\importlib_init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MKN\anaconda3\Lib\site-packages\basicsr\data\realesrgan_dataset.py", line 11, in from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "C:\Users\MKN\anaconda3\Lib\site-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'

misssunitaparker avatar Feb 06 '24 06:02 misssunitaparker

I'm guessing for the time being you may need to check and downgrade your torchvision version.

I've been noticing this deprecation warning with torchvision 0.16.2+cu118 but it is still working and processing properly:

UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.

vltmedia avatar Feb 07 '24 01:02 vltmedia

I have forked the basicsr repo and updated the import to make it work, to use it you have to:

  1. Install it pip install new-basicsr

  2. Change the requirements.txt from: basicsr>=1.4.2 to new-basicsr

  3. Uninstall the old basicsr pip uninstall basicsr

  4. Reinstall requirements.txt

Hope that helps :)

MinasFakhori avatar Feb 15 '24 18:02 MinasFakhori

not solve this problem

misssunitaparker avatar Feb 17 '24 10:02 misssunitaparker

not solve this problem

Just tried it on 3 environments and OS and it does work on a fresh environment with my torchvision fix.... The error literally points to torchvision...

vltmedia avatar Feb 17 '24 11:02 vltmedia

Traceback (most recent call last): File "E:\SOFT\GFPGAN\GFPGAN\inference_gfpgan.py", line 7, in from basicsr.utils import imwrite File "C:\Users\MKN\anaconda3\Lib\site-packages\basicsr__init__.py", line 4, in from .data import * File "C:\Users\MKN\anaconda3\Lib\site-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 "C:\Users\MKN\anaconda3\Lib\site-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 "C:\Users\MKN\anaconda3\Lib\importlib__init_.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MKN\anaconda3\Lib\site-packages\basicsr\data\realesrgan_dataset.py", line 11, in from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "C:\Users\MKN\anaconda3\Lib\site-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'

Change in degradations.py file.. from

from torchvision.transforms.functional_tensor import rgb_to_grayscale

to

from torchvision.transforms.functional import rgb_to_grayscale

Now that will be wrks fine 👍

tzktz avatar Feb 20 '24 06:02 tzktz

I have forked the basicsr repo and updated the import to make it work, to use it you have to:

  1. Install it pip install new-basicsr
  2. Change the requirements.txt from: basicsr>=1.4.2 to new-basicsr
  3. Uninstall the old basicsr pip uninstall basicsr
  4. Reinstall requirements.txt

Hope that helps :)

Thanks! This works well for me. I've been trapped by this dependency issue for a few hours (python newbie here :P)

yz3358 avatar Sep 11 '24 05:09 yz3358

thank you for your response.

On Wed, 11 Sept 2024 at 11:08, yz3358 @.***> wrote:

I have forked the basicsr repo and updated the import to make it work, to use it you have to:

  1. Install it pip install new-basicsr
  2. Change the requirements.txt from: basicsr>=1.4.2 to new-basicsr
  3. Uninstall the old basicsr pip uninstall basicsr
  4. Reinstall requirements.txt

Hope that helps :)

Thanks! This works well for me. I've been trapped by this dependency issue for a few hours (python newbie here :P)

— Reply to this email directly, view it on GitHub https://github.com/TencentARC/GFPGAN/issues/510#issuecomment-2342665254, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFY7OHMYGUUPUGHZVCGP2DTZV7JOHAVCNFSM6AAAAABC3MOA56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGY3DKMRVGQ . You are receiving this because you authored the thread.Message ID: @.***>

misssunitaparker avatar Sep 16 '24 12:09 misssunitaparker