How do I set up multiple samples to display in a colab notebook with K-Diffusion?
Hi! I’m working on a notebook right now using the new K-Diffusion pipeline support, does anyone have a code example of how to call for multiple samples and display them all successively in a colab notebook?Passing num_images_per_prompt above 1 in a pipe gives me this error:RuntimeError: The size of tensor a (4) must match the size of tensor b (2) at non-singleton dimension 0Thank you in advance! <3
2022-12-09T19:09:07Z
Interesting! Can you please post a code snippet to show how you’re using it?num_images_per_promptshould work, so there might be a bug there.
2022-12-09T19:32:48Z
Happy to! Thanks! <3The below example works as expected.from diffusers import StableDiffusionKDiffusionPipeline
import torch
from PIL import Image
import os


model_id = "stabilityai/stable-diffusion-2-1-base" 

pipe = StableDiffusionKDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(
    "cuda"
)


k_sampler="sample_dpmpp_2s_ancestral" 
pipe.set_scheduler(k_sampler) 


prompt="mountain landscape in the style of thomas kinkade" 

negative_prompt="3d, monochromatic" 
seed=1 
steps=30 
cfg=6 
width=768 
height=512 

torch.manual_seed(seed)
img = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=cfg, width=width, height=height).images[0]
imgIf I add num_images_per_prompt=2 into the pipe at the bottom, it errors out for me like mentioned above. It could be that I’m just missing something silly, but appreciate you looking into it for me!
2022-12-10T13:03:48Z
Yes, this looks like a bug to me!Currently being discussedin this PR.Thank you!
2022-12-10T19:27:14Z
Thank you so much for looking into this!
2022-12-10T20:14:23Z
It should be fixed now if you install from github:pip uninstall diffusers -y
pip install git+https://github.com/huggingface/diffusers