diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

UnboundLocalError: local variable 'image_latents' referenced before assignment

Open shubhdotai opened this issue 3 years ago • 3 comments

Describe the bug

Getting this error with strength = 1.0 (is_strength_max) other wise it's working fine in the StableDiffusionXLControlNetInpaintPipeline

Reproduction

sdxl_inpaint_pipe(
        prompt=prompt,
        negative_prompt= negative_prompt,
        width=1024,
        height=1024,
        num_inference_steps=30,
        image= image.convert("RGB"),
        mask_image= mask.convert("L"),
        control_image=control_image,
        controlnet_conditioning_scale=0.5,
        guidance_scale=5,
        num_images_per_prompt=1,
        strength=1.0,
).images

Logs

783     image = image.to(device=device, dtype=dtype)
    784     image_latents = self._encode_vae_image(image=image, generator=generator)
--> 786 image_latents = image_latents.repeat(batch_size // image_latents.shape[0], 1, 1, 1)
    788 if latents is None and add_noise:
    789     noise = randn_tensor(shape, generator=generator, device=device, dtype=dtype)

System Info

  • diffusers version: 0.22.0.dev0
  • Platform: Linux-5.15.0-1041-aws-x86_64-with-glibc2.31
  • Python version: 3.10.12
  • PyTorch version (GPU?): 2.0.1 (True)
  • Huggingface_hub version: 0.16.4
  • Transformers version: 4.30.2
  • Accelerate version: 0.21.0
  • xFormers version: 0.0.20
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Who can help?

@sayakpaul @yiyixuxu @DN6 @patrickvonplaten

shubhdotai avatar Oct 20 '23 05:10 shubhdotai

cc: @yiyixuxu Could you please take a look here?

DN6 avatar Oct 20 '23 07:10 DN6

@shubhamworks we would need a fully reproducible code snippet here I think

patrickvonplaten avatar Oct 23 '23 17:10 patrickvonplaten

@patrickvonplaten The issue got fixed in the last commit Thanks team. Closing it!

shubhdotai avatar Oct 24 '23 13:10 shubhdotai