Hello. I’m just getting into SD and I ran into a problem. Here’s my code:
pipe = DiffusionPipeline.from_pretrained(model_id, custom_pipeline="lpw_stable_diffusion", torch_dtype=torch.float16)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16).to(device)
pipe=pipe.to(device)
def get_inputs(batch_size=1):
generator = [torch.Generator(device).manual_seed(i) for i in range(batch_size)]
prompts = batch_size * [prompt]
inputs = {"prompt": prompts, "generator": generator, "width": width, "height": height, "num_inference_steps": steps}
seeds = [gen.seed() for gen in generator]
return inputs, seeds
inputs, seeds = get_inputs(number_images)
images = pipe(**inputs).images
It runs well without custom_pipeline=“lpw_stable_diffusion” but gives me an error with it. What am I doing wrong?
The error:
Token indices sequence length is longer than the specified maximum sequence length for this model (92 > 77). Running this sequence through the model will result in indexing errors
Traceback (most recent call last):
File "D:\somedir\txt2img\StableDiffusion.py", line 64, in <module>
images = pipe(**inputs).images
^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.cache\huggingface\modules\diffusers_modules\git\lpw_stable_diffusion.py", line 807, in __call__
latents, init_latents_orig, noise = self.prepare_latents(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.cache\huggingface\modules\diffusers_modules\git\lpw_stable_diffusion.py", line 640, in prepare_latents
latents = torch.randn(shape, generator=generator, device=device, dtype=dtype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: randn() received an invalid combination of arguments - got (tuple, generator=list, dtype=torch.dtype, device=torch.device), but expected one of:
* (tuple of ints size, *, torch.Generator generator, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
* (tuple of ints size, *, torch.Generator generator, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
* (tuple of ints size, *, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
* (tuple of ints size, *, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)