Spaces:
Sleeping
Sleeping
Rollback Working except Avatar
Browse files
app.py
CHANGED
|
@@ -56,10 +56,15 @@ def load_models():
|
|
| 56 |
)
|
| 57 |
|
| 58 |
# Stable Diffusion Img2Img pipeline (public model)
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# Optimize for ZeroGPU memory
|
| 65 |
sd_pipe.enable_attention_slicing()
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
# Stable Diffusion Img2Img pipeline (public model)
|
| 59 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 60 |
+
if device == "cuda":
|
| 61 |
+
sd_pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
|
| 62 |
+
"runwayml/stable-diffusion-v1-5",
|
| 63 |
+
torch_dtype=torch.float16
|
| 64 |
+
).to(device)
|
| 65 |
+
else:
|
| 66 |
+
sd_pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
|
| 67 |
+
"runwayml/stable-diffusion-v1-5").to(device)
|
| 68 |
|
| 69 |
# Optimize for ZeroGPU memory
|
| 70 |
sd_pipe.enable_attention_slicing()
|