Kosinkadink / ComfyUI-AnimateDiff-Evolved

Improved AnimateDiff for ComfyUI and Advanced Sampling Support
Apache License 2.0
2.68k stars 204 forks source link

[ImportError: cannot import name 'attention_basic' from 'comfy.ldm.modules.attention' - UPDATE YOUR COMFYUI TO FIX] Comfyui doesn't recognize Animatediff nodes #95

Closed JerryOver closed 11 months ago

JerryOver commented 1 year ago

I was following a Youtube tutorial by MDMZ on the install of AnimateDiff. I used the ComfyUI Manager to install it, but when I loaded the workflow from the tutorial, I got the following error message from the picture below. It said that "TypeError: widget[GET_CONFIG] is not a function." When I read the comments for this Youtube tutorial, other people were having the same error, but I saw no solution. So I then uninstalled AnimateDiff and reinstalled it but no change. I then went to your page, https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved and loaded your txttoimg workflow and got the following error from the picture below. It said, "When loading the graph, the following node types were not found: ADE_AnimateDiffLoaderWithContext..." Error Error B Here is the output from my CMD window:

C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable>.\python_embeded\python.exe -s ComfyUI\main.py --cpu --windows-standalone-build ** ComfyUI start up time: 2023-10-15 04:24:18.339773

Prestartup times for custom nodes: 0.0 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager

Total VRAM 16099 MB, total RAM 16099 MB Set vram state to: DISABLED Device: cpu VAE dtype: torch.float32 Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention Adding extra search path checkpoints D:\AI\sd.webui (1)\webui\models/Stable-diffusion Adding extra search path configs D:\AI\sd.webui (1)\webui\models/Stable-diffusion Adding extra search path vae D:\AI\sd.webui (1)\webui\models/VAE Adding extra search path loras D:\AI\sd.webui (1)\webui\models/Lora Adding extra search path loras D:\AI\sd.webui (1)\webui\models/LyCORIS Adding extra search path upscale_models D:\AI\sd.webui (1)\webui\models/ESRGAN Adding extra search path upscale_models D:\AI\sd.webui (1)\webui\models/RealESRGAN Adding extra search path upscale_models D:\AI\sd.webui (1)\webui\models/SwinIR Adding extra search path embeddings D:\AI\sd.webui (1)\webui\embeddings Adding extra search path hypernetworks D:\AI\sd.webui (1)\webui\models/hypernetworks Adding extra search path controlnet D:\AI\sd.webui (1)\webui\extensions\sd-webui-controlnet\models Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention Traceback (most recent call last): File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1734, 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 "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved__init__.py", line 2, in from .animatediff.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\nodes.py", line 18, in from .motion_module import InjectorVersion, eject_params_from_model, get_injected_mm_params, inject_params_into_model, load_motion_lora, load_motion_module File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\motion_module.py", line 11, in from .motion_module_ad import AnimDiffMotionWrapper, has_mid_block File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\motion_module_ad.py", line 9, in from .motion_utils import GenericMotionWrapper, InjectorVersion, BlockType, CrossAttentionMM File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\motion_utils.py", line 5, in from comfy.ldm.modules.attention import attention_basic, attention_pytorch, attention_split, attention_sub_quad, attention_xformers, default ImportError: cannot import name 'attention_basic' from 'comfy.ldm.modules.attention' (C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py)

Cannot import C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved module for custom nodes: cannot import name 'attention_basic' from 'comfy.ldm.modules.attention' (C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py)

Loading: ComfyUI-Manager (V0.34)

ComfyUI Revision: UNKNOWN (The currently installed ComfyUI is not a Git repository)

Registered sys.path: ['C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\init.py', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\custom_pycocotools', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\custom_oneformer', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\custom_mmpkg', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\custom_midas_repo', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\custom_detectron2', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\controlnet_aux', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\comfy', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages\git\ext\gitdb', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\python311.zip', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages\win32', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages\win32\lib', 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages\Pythonwin', '../..'] C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\node_wrappers\dwpose.py:26: UserWarning: Onnxruntime not found or doesn't come with acceleration providers, switch to OpenCV with CPU device (super slow) warnings.warn("Onnxruntime not found or doesn't come with acceleration providers, switch to OpenCV with CPU device (super slow)") FizzleDorf Custom Nodes: Loaded Traceback (most recent call last): File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1734, in load_custom_node module_spec.loader.exec_module(module) File "", line 936, in exec_module File "", line 1073, in get_code File "", line 1130, in get_data FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\custom_nodes\init.py'

Cannot import C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\custom_nodes module for custom nodes: [Errno 2] No such file or directory: 'C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\custom_nodes\init.py'

Import times for custom nodes: 0.0 seconds (IMPORT FAILED): C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\custom_nodes 0.0 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet 0.0 seconds (IMPORT FAILED): C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved 0.1 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-VideoHelperSuite 0.1 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager 0.3 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux 0.3 seconds: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_FizzNodes

Starting server

To see the GUI go to: http://127.0.0.1:8188 FETCH DATA from: C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager\extension-node-map.json

Kosinkadink commented 1 year ago

The widget thing I'm pretty sure is unrelated to AnimateDiff-Evolved, so I think I can't help with that.

As for the import error in AnimateDiff-Evolved, your ComfyUI is outdated - if you update ComfyUI, that should go away. Let me know what (or if any) errors remain once you update ComfyUI!

ultimatech-cn commented 1 year ago

I got the similar error today just after I update the latest version of comfyui.

Traceback (most recent call last): File "C:\DEV\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1734, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-animatediff__init__.py", line 2, in from .animatediff.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-animatediff\animatediff\nodes.py", line 13, in from .motion_module import MotionWrapper File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-animatediff\animatediff\motion_module.py", line 8, in from comfy.ldm.modules.attention import ( ImportError: cannot import name 'CrossAttentionDoggettx' from 'comfy.ldm.modules.attention' (C:\DEV\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py)

Cannot import C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-animatediff module for custom nodes: cannot import name 'CrossAttentionDoggettx' from 'comfy.ldm.modules.attention' (C:\DEV\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py) Traceback (most recent call last): File "C:\DEV\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1734, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved__init__.py", line 2, in from .animatediff.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\nodes.py", line 18, in from .motion_module import InjectorVersion, eject_params_from_model, get_injected_mm_params, inject_params_into_model, load_motion_lora, load_motion_module File "C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\motion_module.py", line 7, in from comfy.ldm.modules.attention import CrossAttentionBirchSan, CrossAttentionDoggettx, CrossAttentionPytorch, FeedForward, CrossAttention, MemoryEfficientCrossAttention ImportError: cannot import name 'CrossAttentionBirchSan' from 'comfy.ldm.modules.attention' (C:\DEV\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py)

Cannot import C:\DEV\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved module for custom nodes: cannot import name 'CrossAttentionBirchSan' from 'comfy.ldm.modules.attention' (C:\DEV\ComfyUI_windows_portable\ComfyUI\comfy\ldm\modules\attention.py)

I will open an issue on comfyui.

Kosinkadink commented 1 year ago

@ultimatech-cn you have the opposite problem of the OP - you have an outdated version of AnimateDiff-Evolved, and your ComfyUI is (probably) up to date. Update AnimateDiff-Evolved (and ComfyUI for good measure), and you'll be good. Btw you can stick with just AnimateDiff-Evolved to avoid potential compatiblity/double injection issues with the other animatediff repo, although hypothetically as long as you don't use their ksampler with my loader it should be ok.

You can reference the example workflows on my README to see how to use the loader - you can use any KSampler you'd like with it.

ultimatech-cn commented 12 months ago

Thanks, It works well.

@ultimatech-cn you have the opposite problem of the OP - you have an outdated version of AnimateDiff-Evolved, and your ComfyUI is (probably) up to date. Update AnimateDiff-Evolved (and ComfyUI for good measure), and you'll be good. Btw you can stick with just AnimateDiff-Evolved to avoid potential compatiblity/double injection issues with the other animatediff repo, although hypothetically as long as you don't use their ksampler with my loader it should be ok.

You can reference the example workflows on my README to see how to use the loader - you can use any KSampler you'd like with it.

Kosinkadink commented 12 months ago

@JerryOver did updating ComfyUI fix your problem?

JerryOver commented 12 months ago

So when I tried to run update_comfyui.bat, I got this message... I am new to comfyui.

C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\update>..\python_embeded\python.exe .\update.py ..\ComfyUI\ Traceback (most recent call last): File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\update\update.py", line 45, in repo = pygit2.Repository(str(sys.argv[1])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\python_embeded\Lib\site-packages\pygit2\repository.py", line 1759, in init path_backend = init_file_backend(path, flags) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _pygit2.GitError: Repository not found at ..\ComfyUI\

C:\Users\hinso\OneDrive\Documents\ComfyUI_windows_portable\update>pause Press any key to continue . . .

olegpars commented 12 months ago

I am having almost the same issue - first install of ComfyUI to use with Animatediff Evolved. The Animatediff Evolved does not install correctly, and gives same error when installing an example workflow "When loading the graph, the following node types were not found: ADE_AnimateDiffLoaderWithContext".

I tried updating Comfyui and Animatediff but it did not help. Did a clean reinstall but the problem persists.

Screenshot: https://i.imgur.com/Fr0spkm.png

Kosinkadink commented 12 months ago

@olegpars can you screenshot all the errors you see during install or while using? Specifically the text in the console

olegpars commented 12 months ago

@Kosinkadink thank you for your fast response!

Here is a screenshot: https://i.imgur.com/06YyHMW.png

Kosinkadink commented 12 months ago

@olegpars Looking at your error, it cannot load up AnimateDiff-Evolved because your ComfyUI is outdated. Your AnimateDiff-Evolved is up to date, as it is correctly looking for attention_basic, but your ComfyUI does not have it, which means it is outdated. Make sure your portable version is getting updated properly, and if it is not, you may just need to download a new portable version and try again. (Or, setup a manual install of ComfyUI if you'd like)

olegpars commented 12 months ago

Wow, thank you! I updated it through Comfy Manager and it all works now.

Strange thing is i already tried updating comfyui in the previous install, but it did not help. Now everything works just fine. Thank you again for your help!

JerryOver commented 11 months ago

Do you know why I'm having trouble updating? I'll put here what it said again:

C:\Users\hinso\OneDrive\Desktop\ComfyUI_windows_portable\update>..\python_embeded\python.exe .\update.py ..\ComfyUI\ Traceback (most recent call last): File "C:\Users\hinso\OneDrive\Desktop\ComfyUI_windows_portable\update\update.py", line 45, in repo = pygit2.Repository(str(sys.argv[1])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hinso\OneDrive\Desktop\ComfyUI_windows_portable\python_embeded\Lib\site-packages\pygit2\repository.py", line 1759, in init path_backend = init_file_backend(path, flags) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _pygit2.GitError: Repository not found at ..\ComfyUI\

C:\Users\hinso\OneDrive\Desktop\ComfyUI_windows_portable\update>pause Press any key to continue . . .

rch-goldsnaker commented 11 months ago

I had the same error, and I solved Updating ConfyUI, Thanks, It works well.