Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StableDiffusionImg2ImgPipeline broken in 0.3.0 release for Apple MPS #462

Closed
FahimF opened this issue Sep 10, 2022 · 2 comments
Closed

StableDiffusionImg2ImgPipeline broken in 0.3.0 release for Apple MPS #462

FahimF opened this issue Sep 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@FahimF
Copy link

FahimF commented Sep 10, 2022

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

@FahimF FahimF added the bug Something isn't working label Sep 10, 2022
@abesmon
Copy link

abesmon commented Sep 11, 2022

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?:

@FahimF
Copy link
Author

FahimF commented Sep 11, 2022

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

@FahimF FahimF closed this as completed Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants