huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.

Home Page:https://huggingface.co/docs/diffusers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StableDiffusionImg2ImgPipeline broken in 0.3.0 release for Apple MPS

FahimF opened this issue · comments

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

what's your PyTorch version? I've tried just now on 1.13.0.dev20220909 and can't reproduce problems. Everything seems ok:
fantasy_landscape

  • diffusers version: 0.3.0
  • Platform: macOS-12.4-arm64-arm-64bit
  • Python version: 3.9.12
  • PyTorch version (GPU?): 1.13.0.dev20220909 (False)
  • Huggingface_hub version: 0.8.1
  • Transformers version: 4.21.3
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Failed with PyTorch 1.13.0.dev20220908 but works with 1.13.0.dev20220911. So must have been a PyTorch issue. Closing ticket.