guoyww / AnimateDiff

Official implementation of AnimateDiff.
https://animatediff.github.io
Apache License 2.0
10.64k stars 874 forks source link

EinopsError Shape mismatch #294

Open CHAMYJ opened 8 months ago

CHAMYJ commented 8 months ago

Hi, I am encountered this issue: EinopsError: Error while processing rearrange-reduction pattern "(b f) d c -> (b d) f c". Input tensor shape: torch.Size([2, 8040, 320]). Additional info: {'f': 16}. Shape mismatch, can't divide axis of length 2 in chunks of 16

Please guide me to solve this issue. I installed animateDiff extension from automatic1111, using this link (https://github.com/continue-revolution/sd-webui-animatediff). I am running it on Windows and using RTX4080.

img1 img2

Error Message:

r_webui(self, x, timesteps, context, *args, kwargs) File "C:\Users\User\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py", line 797, in forward h = module(h, emb, context) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\User\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py", line 86, in forward x = layer(x) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 132, in forward return self.temporal_transformer(x) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 190, in forward hidden_states = block(hidden_states) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 244, in forward hidden_states = attention_block(norm_hidden_states) + hidden_states File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 333, in forward x = rearrange(x, "(b f) d c -> (b d) f c", f=video_length) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\einops\einops.py", line 487, in rearrange return reduce(tensor, pattern, reduction='rearrange', **axes_lengths) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\einops\einops.py", line 418, in reduce raise EinopsError(message + '\n {}'.format(e)) einops.EinopsError: Error while processing rearrange-reduction pattern "(b f) d c -> (b d) f c". Input tensor shape: torch.Size([2, 8040, 320]). Additional info: {'f': 16}. Shape mismatch, can't divide axis of length 2 in chunks of 16

jonan10075 commented 8 months ago

I have the same problem, have you solved it yet?

protector131090 commented 8 months ago

same here after updating

CHAMYJ commented 8 months ago

Hi, I managed to solve it by updating the version of automatic1111 web UI from 1.6.0 to 1.8.0.

daizhihui commented 8 months ago

my webui is 1.8.0, still has the problem

jeexianwu commented 8 months ago

update was-node-suite-comfyui to latest version, can fix it.

protector131090 commented 8 months ago

still not fixed in A1111

Saref111 commented 8 months ago

Still doesn't work

joeke80215 commented 8 months ago

still not fixed in A1111

gynoidneko commented 8 months ago

I've been running into this too. No way to get it to work.

ningyuannightware commented 8 months ago

I have the same problem,it doesn't work

juanram0n commented 8 months ago

I managed to solve it changing the Context batch size to 2 or 1, but... the result is crap.

Saref111 commented 8 months ago

Has anybody tried to crate issue in stable-diffusion-webui repo? Looks like this repo is dead

johndpope commented 8 months ago

there's a new player in town - https://www.mmlab-ntu.com/project/fresco/

dlsdani3 commented 8 months ago

same problem here...

Nileneb commented 8 months ago

Solved with bringing einops lib to 0.7.0

xxxsnacks commented 7 months ago

Solved with bringing einops lib to 0.7.0

I tried this and its still giving the same error

submaroon commented 7 months ago

Same problem. If i set Batch Size on 8 and Context batch size in AnimateDiff I get this noise image

veraburg commented 7 months ago

Same problem! solved it yet?

Nileneb commented 7 months ago

Dont know, why my solution does not work for you. Here is my package list: "Packages": [ "absl-py==2.1.0", "accelerate==0.21.0", "aenum==3.1.15", "aiofiles==23.2.1", "aiohttp==3.9.3", "aiosignal==1.3.1", "albumentations==1.4.2", "altair==5.2.0", "antlr4-python3-runtime==4.9.3", "anyio==3.7.1", "asttokens==2.4.1", "async-timeout==4.0.3", "attrs==23.2.0", "av==12.0.0", "beautifulsoup4==4.12.3", "bitsandbytes==0.43.0", "blendmodes==2022", "blobfile==2.1.1", "cachetools==5.3.3", "certifi==2024.2.2", "cffi==1.16.0", "chardet==5.2.0", "charset-normalizer==3.3.2", "clean-fid==0.1.35", "click==8.1.7", "clip==1.0", "coloredlogs==15.0.1", "colorlog==6.8.2", "comm==0.2.2", "contourpy==1.2.0", "coverage==7.4.4", "cssselect2==0.7.0", "cycler==0.12.1", "cython==3.0.9", "dadaptation==3.2", "decorator==4.4.2", "deprecation==2.1.0", "depth-anything==2024.1.22.0", "diffusers==0.27.2", "discord-webhook==1.3.0", "dsine==2024.3.23", "easydict==1.13", "einops==0.4.1", "embreex==2.17.7.post4", "exceptiongroup==1.2.0", "executing==2.0.1", "facexlib==0.3.0", "fastapi==0.94.0", "ffmpy==0.3.2", "filelock==3.13.3", "filterpy==1.4.5", "flatbuffers==24.3.25", "fonttools==4.50.0", "freetype-py==2.4.0", "frozenlist==1.4.1", "fsspec==2024.3.1", "ftfy==6.2.0", "fvcore==0.1.5.post20221221", "gdown==5.1.0", "geffnet==1.0.2", "gitdb==4.0.11", "gitpython==3.1.42", "glob2==0.5", "google-auth-oauthlib==1.0.0", "google-auth==2.29.0", "gradio-client==0.5.0", "gradio==3.41.2", "grpcio==1.62.1", "h11==0.12.0", "handrefinerportable==2024.2.12.0", "hsluv==5.0.4", "httpcore==0.15.0", "httpx==0.24.1", "huggingface-hub==0.22.1", "humanfriendly==10.0", "idna==3.6", "imageio-ffmpeg==0.4.9", "imageio==2.34.0", "importlib-metadata==7.1.0", "importlib-resources==6.4.0", "inflection==0.5.1", "iniconfig==2.0.0", "insightface==0.7.3", "iopath==0.1.9", "ipython==8.22.2", "ipywidgets==8.1.2", "jax==0.4.25", "jaxlib==0.4.25", "jedi==0.19.1", "jinja2==3.1.3", "joblib==1.3.2", "jsonmerge==1.8.0", "jsonschema-specifications==2023.12.1", "jsonschema==4.21.1", "jupyterlab-widgets==3.0.10", "kiwisolver==1.4.5", "kornia==0.6.7", "lark==1.1.2", "lazy-loader==0.3", "lightning-utilities==0.11.2", "llvmlite==0.42.0", "lxml==4.9.4", "mapbox-earcut==1.0.1", "markdown-it-py==3.0.0", "markdown==3.6", "markupsafe==2.1.5", "matplotlib-inline==0.1.6", "matplotlib==3.8.3", "mdurl==0.1.2", "mediapipe==0.10.11", "ml-dtypes==0.3.2", "moviepy==1.0.3", "mpmath==1.3.0", "multidict==6.0.5", "networkx==3.2.1", "numba==0.59.1", "numexpr==2.9.0", "numpy==1.26.2", "oauthlib==3.2.2", "omegaconf==2.2.3", "onnx==1.16.0", "onnxruntime-gpu==1.17.1", "open-clip-torch==2.20.0", "opencv-contrib-python==4.9.0.80", "opencv-python-headless==4.9.0.80", "opencv-python==4.9.0.80", "opt-einsum==3.3.0", "orjson==3.10.0", "packaging==24.0", "pandas==2.2.1", "parso==0.8.3", "pexpect==4.9.0", "piexif==1.1.3", "pillow==9.5.0", "pims==0.6.1", "pip==24.0", "platformdirs==4.2.0", "pluggy==1.4.0", "pooch==1.8.1", "portalocker==2.8.2", "prettytable==3.10.0", "proglog==0.1.10", "prompt-toolkit==3.0.43", "protobuf==3.20.3", "psutil==5.9.5", "ptyprocess==0.7.0", "pure-eval==0.2.2", "pyasn1-modules==0.4.0", "pyasn1==0.6.0", "pycollada==0.8", "pycparser==2.21", "pycryptodomex==3.20.0", "pydantic-requests==0.1.4", "pydantic==1.10.14", "pydub==0.25.1", "pygments==2.17.2", "pymatting==1.1.12", "pyparsing==3.1.2", "pyqt5-qt5==5.15.2", "pyqt5-sip==12.13.0", "pyqt5==5.15.10", "pyqt6-qt6==6.6.2", "pyqt6-sip==13.6.0", "pyqt6==6.6.1", "pysocks==1.7.1", "pytest==8.1.1", "python-dateutil==2.9.0.post0", "python-multipart==0.0.9", "pytorch-lightning==1.9.4", "pytorch-optimizer==2.12.0", "pytz==2024.1", "pywavelets==1.5.0", "pyyaml==6.0.1", "referencing==0.34.0", "regex==2023.12.25", "rembg==2.0.56", "reportlab==4.1.0", "requests-oauthlib==2.0.0", "requests==2.31.0", "resize-right==0.0.2", "rich==13.7.1", "rpds-py==0.18.0", "rsa==4.9", "rtree==1.2.0", "safetensors==0.4.2", "scikit-image==0.21.0", "scikit-learn==1.4.1.post1", "scipy==1.12.0", "semantic-version==2.10.0", "sentencepiece==0.2.0", "setuptools==69.2.0", "shapely==2.0.3", "six==1.16.0", "slicerator==1.1.0", "smmap==5.0.1", "sniffio==1.3.1", "sounddevice==0.4.6", "soupsieve==2.5", "spandrel==0.1.6", "stack-data==0.6.3", "starlette==0.26.1", "svg.path==6.3", "svglib==1.5.1", "sympy==1.12", "syrupy==4.6.1", "tabulate==0.9.0", "tenacity==8.2.3", "tensorboard-data-server==0.7.2", "tensorboard==2.13.0", "termcolor==2.4.0", "threadpoolctl==3.4.0", "tifffile==2024.2.12", "timm==0.9.16", "tinycss2==1.2.1", "tokenizers==0.13.3", "tomesd==0.1.3", "tomli==2.0.1", "toolz==0.12.1", "torch==2.1.2+cu121", "torchdiffeq==0.2.3", "torchmetrics==1.3.2", "torchsde==0.2.6", "torchvision==0.16.2+cu121", "tqdm==4.66.2", "traitlets==5.14.2", "trampoline==0.1.2", "transformers==4.30.2", "transforms3d==0.4.1", "trimesh==4.2.2", "triton==2.1.0", "typing-extensions==4.10.0", "tzdata==2024.1", "urllib3==2.2.1", "uvicorn==0.29.0", "vhacdx==0.0.6", "vispy==0.14.2", "wcwidth==0.2.13", "webencodings==0.5.1", "websockets==11.0.3", "werkzeug==3.0.1", "wheel==0.43.0", "widgetsnbextension==4.0.10", "xatlas==0.0.9", "xformers==0.0.23.post1", "xxhash==3.4.1", "yacs==0.1.8", "yarl==1.9.4", "zipp==3.18.1" ]

veraburg commented 7 months ago

Solved with bringing einops lib to 0.7.0

How do you do this?

Nileneb commented 7 months ago

i worked with visual code and the python extension. Then i chanced the version of einops and all was working. But after copy my version list today i see, actually i got version "einops==0.4.1". So, to be honest, im not really understand, how i solved the bug... Im sorry to bee to much noob, to explain it better

duanjiding commented 6 months ago

Hi, I am encountered this issue: EinopsError: Error while processing rearrange-reduction pattern "(b f) d c -> (b d) f c". Input tensor shape: torch.Size([2, 8040, 320]). Additional info: {'f': 16}. Shape mismatch, can't divide axis of length 2 in chunks of 16

Please guide me to solve this issue. I installed animateDiff extension from automatic1111, using this link (https://github.com/continue-revolution/sd-webui-animatediff). I am running it on Windows and using RTX4080.

img1 img2

Error Message:

r_webui(self, x, timesteps, context, *args, kwargs) File "C:\Users\User\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py", line 797, in forward h = module(h, emb, context) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\User\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py", line 86, in forward x = layer(x) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 132, in forward return self.temporal_transformer(x) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 190, in forward hidden_states = block(hidden_states) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 244, in forward hidden_states = attention_block(norm_hidden_states) + hidden_states File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "C:\Users\User\stable-diffusion-webui\extensions\sd-webui-animatediff\motion_module.py", line 333, in forward x = rearrange(x, "(b f) d c -> (b d) f c", f=video_length) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\einops\einops.py", line 487, in rearrange return reduce(tensor, pattern, reduction='rearrange', **axes_lengths) File "C:\Users\User\stable-diffusion-webui\venv\lib\site-packages\einops\einops.py", line 418, in reduce raise EinopsError(message + '\n {}'.format(e)) einops.EinopsError: Error while processing rearrange-reduction pattern "(b f) d c -> (b d) f c". Input tensor shape: torch.Size([2, 8040, 320]). Additional info: {'f': 16}. Shape mismatch, can't divide axis of length 2 in chunks of 16

i solved it by update the version of SDWEBUI to 1.8.0, good luck, bro

laozhang808 commented 5 months ago

pip install einops SDWEBUI to 1.8.0

quuee commented 1 month ago

Solved with bringing einops lib to 0.7.0

0.8.0 ,same too

seekfeeding commented 1 week ago

I met it too. Try Stable Diffusion webui ver of v20240302 V1.8.0. sd-webui-animatediff ver of 20240712 It work now. Hope it helps