torchvision.transforms.functional_tensor import rgb_to_grayscale #451

Open
opened 2026-01-29 21:47:51 +00:00 by claunia · 7 comments
Owner

Originally created by @misssunitaparker on GitHub (Feb 6, 2024).

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'

Originally created by @misssunitaparker on GitHub (Feb 6, 2024). Traceback (most recent call last): File "E:\SOFT\GFPGAN\GFPGAN\inference_gfpgan.py", line 7, in <module> from basicsr.utils import imwrite File "C:\Users\MKN\anaconda3\Lib\site-packages\basicsr\__init__.py", line 4, in <module> from .data import * File "C:\Users\MKN\anaconda3\Lib\site-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 "C:\Users\MKN\anaconda3\Lib\site-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 "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 <module> 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 <module> from torchvision.transforms.functional_tensor import rgb_to_grayscale ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'
Author
Owner

@vltmedia commented on GitHub (Feb 7, 2024):

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 commented on GitHub (Feb 7, 2024): 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. ```
Author
Owner

@MinasFakhori commented on GitHub (Feb 15, 2024):

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 commented on GitHub (Feb 15, 2024): 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 :)
Author
Owner

@misssunitaparker commented on GitHub (Feb 17, 2024):

not solve this problem

@misssunitaparker commented on GitHub (Feb 17, 2024): not solve this problem
Author
Owner

@vltmedia commented on GitHub (Feb 17, 2024):

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 commented on GitHub (Feb 17, 2024): > 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...
Author
Owner

@tzktz commented on GitHub (Feb 20, 2024):

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 commented on GitHub (Feb 20, 2024): > 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 👍
Author
Owner

@yz3358 commented on GitHub (Sep 11, 2024):

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 commented on GitHub (Sep 11, 2024): > 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)
Author
Owner

@misssunitaparker commented on GitHub (Sep 16, 2024):

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 commented on GitHub (Sep 16, 2024): 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: > ***@***.***> >
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#451