Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,25 @@ import time
|
|
| 6 |
import os
|
| 7 |
import torch
|
| 8 |
import spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@spaces.GPU
|
| 10 |
def greet(name):
|
| 11 |
return "Hello there {}".format(name)
|
|
|
|
| 6 |
import os
|
| 7 |
import torch
|
| 8 |
import spaces
|
| 9 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
| 10 |
+
from diffusers.utils import load_image
|
| 11 |
+
|
| 12 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
+
model_repo_id = "timbrooks/instruct-pix2pix"
|
| 14 |
+
|
| 15 |
+
if torch.cuda.is_available():
|
| 16 |
+
torch_dtype = torch.float16
|
| 17 |
+
else:
|
| 18 |
+
torch_dtype = torch.float32
|
| 19 |
+
|
| 20 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
|
| 21 |
+
model_repo_id,
|
| 22 |
+
torch_dtype=torch_dtype,
|
| 23 |
+
safety_checker=None
|
| 24 |
+
)
|
| 25 |
+
pipe = pipe.to(device)
|
| 26 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 27 |
+
|
| 28 |
@spaces.GPU
|
| 29 |
def greet(name):
|
| 30 |
return "Hello there {}".format(name)
|