Spaces:
Sleeping
Sleeping
Download app.py from leftoverRays/README: direct link, hf CLI and curl.
- Browser
- Download file 578 Bytes
-
https://huggingface.co/spaces/leftoverRays/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/leftoverRays/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/leftoverRays/README/resolve/main/app.py
578 Bytes
| import PIL | |
| import requests | |
| import torch | |
| from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler | |
| model_id = "timbrooks/instruct-pix2pix" | |
| pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None) | |
| pipe.to("cuda") | |
| pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config) | |
| url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg" | |
| def download_image(url): | |
| image = PIL.Image.open(requests.get(url, stream=True).raw) |