harubaru / waifu-diffusion

stable diffusion finetuned on weeb stuff
GNU Affero General Public License v3.0
1.94k stars 177 forks source link

Prediction fails on `num_outputs = 4` #41

Closed vikiival closed 1 year ago

vikiival commented 1 year ago

I am playing with this awesome model, however when I want to make a 4 outputs it fails

d908d47fa301ffe59dce52588e0603add72bfcbc4bb3f78b4516cac541ba7b2b

Sample input:

{
  "width": 512,
  "height": 512,
  "num_outputs": 4,
  "guidance_scale": 6,
  "negative_prompt": "ugly face",
  "positive_prompt": "a cute ghost girl is with a kitsune mask floating in the night sky with a bamboo umbrella, wearing a flowery kimono, art by fuji choko, sharp focus, highly detailed, incredible quality, artstation",
  "num_inference_steps": 50
}

Output I get from the model

Using seed: 12336\n  0%|          | 0/50 [00:00<?, ?it/s]\n0%|          | 0/50 [00:00<?, ?it/s]\nTraceback (most recent call last):
\nFile \"/src/src/cog/python/cog/server/worker.py\", line 209, in _predict\nresult = self._predictor.predict(**payload)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/autograd/grad_mode.py\", line 27, in decorate_context\nreturn func(*args, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/amp/autocast_mode.py\", line 12, in decorate_autocast\nreturn func(*args, **kwargs)\nFile \"predict.py\", line 93, in predict\noutput = self.pipe(\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/autograd/grad_mode.py\", line 27, in decorate_context\nreturn func(*args, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py\", line 312, in __call__\nnoise_pred = self.unet(latent_model_input, t, encoder_hidden_states=text_embeddings).sample\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1130, in _call_impl\nreturn forward_call(*input, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/unet_2d_condition.py\", line 283, in forward\nsample, res_samples = downsample_block(\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1130, in _call_impl\nreturn forward_call(*input, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/unet_blocks.py\", line 565, in forward\nhidden_states = attn(hidden_states, context=encoder_hidden_states)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1130, in _call_impl\nreturn forward_call(*input, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/attention.py\", line 149, in forward\nhidden_states = block(hidden_states, context=context)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1130, in _call_impl\nreturn forward_call(*input, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/attention.py\", line 199, in forward\nhidden_states = self.attn2(self.norm2(hidden_states), context=context) + hidden_states\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1130, in _call_impl\nreturn forward_call(*input, **kwargs)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/attention.py\", line 270, in forward\nhidden_states = self._attention(query, key, value)\nFile \"/root/.pyenv/versions/3.9.15/lib/python3.9/site-packages/diffusers/models/attention.py\", line 278, in _attention\nattention_scores = torch.matmul(query, key.transpose(-1, -2)) * self.scale\nRuntimeError: The size of tensor a (64) must match the size of tensor b (160) at non-singleton dimension 0
harubaru commented 1 year ago

Make an issue on the author's repository

vikiival commented 1 year ago

I decided to use your model in the end ❤️ .

FYI: Author (@multitrickfox) of the 16-bit-waifu marked this repository as source.

MultiTrickFox commented 1 year ago

Hey, I saw your @. I noticed the issue earlier for the diffusers==0.4.0 models; using batch & negative prompt at the same time causes the error. So the batch arg is not compatible with the version on replicate (currently).

Btw its harubaru's work originally, I just created its cog as an exercise :)

Hi harubaru