Skip to content

UnboundLocalError: local variable 'image_latents' referenced before assignment #5463

@shubhdotai

Description

@shubhdotai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions