Skip to content

StableDiffusionImg2ImgPipeline broken in 0.3.0 release for Apple MPS #462

Description

@FahimF

Describe the bug

Using StableDiffusionImg2ImgPipeline before the 0.3.0 release used to generate images correctly on Apple Silicon devices. Now, if you use StableDiffusionImg2ImgPipeline, all you get is a brown image.

I've copied and pasted the sample code from the docs (with a few minor modifications) and tried on both an Apple Silicon device and on Google Colab and the it works on Google Colab but not on Apple Silicon.

Reproduction

The following code should show the issue:

device = torch.device("cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu")
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("stable-diffusion-v1-4").to(device)
pipe.safety_checker = lambda images, **kwargs: (images, False)

# let's download an initial image
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"

response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))
prompt = "A fantasy landscape, trending on artstation"
images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5).images
images[0].save("fantasy_landscape.png")

Logs

No response

System Info

diffusers 0.3.0 on an Apple M1 2021 MacBook Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions