Spaces:
Sleeping
Sleeping
Create app.py
#1
by cyberray6801 - opened
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import PIL
|
| 2 |
+
import requests
|
| 3 |
+
import torch
|
| 4 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
| 5 |
+
|
| 6 |
+
model_id = "timbrooks/instruct-pix2pix"
|
| 7 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
|
| 8 |
+
pipe.to("cuda")
|
| 9 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 10 |
+
|
| 11 |
+
url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
|
| 12 |
+
def download_image(url):
|
| 13 |
+
image = PIL.Image.open(requests.get(url, stream=True).raw)
|