Stability-AI / StableCascade

Official Code for Stable Cascade
MIT License
6.44k stars 518 forks source link

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 2 but got size 1 for tensor number 1 in the list #123

Open deadpipe opened 3 months ago

deadpipe commented 3 months ago

Hi

I am trying to generate an image but I receive the following error in the terminal :

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. All rights reserved.

S:\AI Softwares\Cascade>venv\scripts\activate

(venv) S:\AI Softwares\Cascade>cd stablecascade

(venv) S:\AI Softwares\Cascade\StableCascade>cd gradio_app

(venv) S:\AI Softwares\Cascade\StableCascade\gradio_app>python app.py
RUNNING ON: cuda
Loading pipeline components...:   0%|                                                                                                       | 0/6 [00:00<?, ?it/s]S:\AI Softwares\Cascade\venv\lib\site-packages\diffusers\models\lora.py:387: FutureWarning: `LoRACompatibleLinear` is deprecated and will be removed in version 1.0.0. Use of `LoRACompatibleLinear` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`.
  deprecate("LoRACompatibleLinear", "1.0.0", deprecation_message)
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 6/6 [00:00<00:00,  7.96it/s]
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:13<00:00,  2.66s/it]
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
seed: 164324004
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00,  1.20s/it]
  0%|                                                                                                                                      | 0/10 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\gradio\queueing.py", line 501, in call_prediction
    output = await route_utils.call_process_api(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\gradio\route_utils.py", line 253, in call_process_api
    output = await app.get_blocks().process_api(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\gradio\blocks.py", line 1695, in process_api
    result = await self.call_function(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\gradio\blocks.py", line 1235, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\gradio\utils.py", line 692, in wrapper
    response = f(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "S:\AI Softwares\Cascade\StableCascade\gradio_app\app.py", line 91, in generate
    decoder_output = generate_decoder(
  File "S:\AI Softwares\Cascade\StableCascade\gradio_app\app.py", line 47, in generate_decoder
    decoder_output = decoder(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\diffusers\pipelines\stable_cascade\pipeline_stable_cascade.py", line 412, in __call__
    predicted_latents = self.decoder(
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\diffusers\models\unets\unet_stable_cascade.py", line 603, in forward
    level_outputs = self._down_encode(x, timestep_ratio_embed, clip)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\diffusers\models\unets\unet_stable_cascade.py", line 495, in _down_encode
    x = block(x, clip)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "S:\AI Softwares\Cascade\venv\lib\site-packages\diffusers\models\unets\unet_stable_cascade.py", line 108, in forward
    kv = torch.cat([norm_x.view(batch_size, channel, -1).transpose(1, 2), kv], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 2 but got size 1 for tensor number 1 in the list.

I am using: Windows 10 RTX 3090 24GB RTX 3060 12GB 32GB System RAM Python 3.10.6 CUDA 11.8 Nvidia Driver 531.18

1Nevermore2 commented 3 months ago

COOL

vofan commented 3 months ago

same here. UPD: found a workaround: in advanced settings change Number of images to 1

FurkanGozukara commented 3 months ago

we have number of images support and amazing optimizations having app : https://github.com/Stability-AI/StableCascade/issues/125

by the way the naming of number of images in original gradio is actually = batch size not looping