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

[SOLVED] ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor' #161

Closed
3 tasks done
alessandroperilli opened this issue Dec 23, 2023 · 2 comments

Comments

@alessandroperilli
Copy link

alessandroperilli commented Dec 23, 2023

First, confirm

  • I have read the instruction carefully
  • I have searched the existing issues
  • I have updated the extension to the latest version

What happened?

The last couple of updates to this custom node suite have caused the following error:

File "xyz/ComfyUI/nodes.py", line 1813, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/init.py", line 25, in
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/nodes.py", line 19, in
from basicsr.utils.registry import ARCH_REGISTRY
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/init.py", line 4, in
from .data import *
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/init.py", line 22, in
_dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/init.py", line 22, in
_dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/realesrgan_dataset.py", line 11, in
from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels
File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/degradations.py", line 8, in
from torchvision.transforms.functional_tensor import rgb_to_grayscale
ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

Cannot import xyz/ComfyUI/custom_nodes/comfyui-reactor-node module for custom nodes: No module named 'torchvision.transforms.functional_tensor'

Steps to reproduce the problem

Just update the node suite to the latest version via ComfyUI Manager.

Sysinfo

Apple M2

Relevant console log

>   File "xyz/ComfyUI/nodes.py", line 1813, in load_custom_node
>     module_spec.loader.exec_module(module)
>   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/__init__.py", line 25, in <module>
>     from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/nodes.py", line 19, in <module>
>     from basicsr.utils.registry import ARCH_REGISTRY
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/__init__.py", line 4, in <module>
>     from .data import *
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/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 "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/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 "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
>     return _bootstrap._gcd_import(name[level:], package, level)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/realesrgan_dataset.py", line 11, in <module>
>     from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels
>   File "xyz/ComfyUI/custom_nodes/comfyui-reactor-node/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'
> 
> Cannot import xyz/ComfyUI/custom_nodes/comfyui-reactor-node module for custom nodes: No module named 'torchvision.transforms.functional_tensor'

Additional information

The solution to this problem is described here: AUTOMATIC1111/stable-diffusion-webui#13985 (comment)

@alessandroperilli alessandroperilli added bug Something isn't working new labels Dec 23, 2023
@Th3Rom3
Copy link

Th3Rom3 commented Dec 23, 2023

I can confirm the solution from AUTOMATIC1111/stable-diffusion-webui#13985 (comment) mentioned in this issue worked well for me. Since the reactor-node ships with the basicsr dependencies now you can do the following:

Change line 8 in
/ComfyUI/custom_nodes/comfyui-reactor-node/basicsr/data/degradations.py
from
from torchvision.transforms.functional_tensor import rgb_to_grayscale
to
from torchvision.transforms.functional import rgb_to_grayscale

thanks for pointing it out.

@Gourieff Gourieff added ✔ solved and removed bug Something isn't working new labels Dec 24, 2023
@Gourieff Gourieff changed the title ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor' [SOLVED] ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor' Dec 24, 2023
@Gourieff Gourieff pinned this issue Dec 24, 2023
Gourieff added a commit that referenced this issue Dec 24, 2023
@alessandroperilli
Copy link
Author

Thanks!

mautech05 added a commit to mautech05/easygan-media-restoration-tool that referenced this issue Mar 26, 2024
Pequeña corrección de errores relacionados con python y los complementos de GFP-GAN y RealESRGAN.

Adicionalmente, estoy consciente del error con basicsr+torchvision y [cómo solucionarlo](Gourieff/comfyui-reactor-node#161 (comment)), pero he decicido NO hacer un arreglo 'hard-coded' en caso de que actualicen la librería (aunque ya lleva algunos meses).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants