Spaces:
Running
on
Zero
Running
on
Zero
Ahmad Basyouni
commited on
Commit
•
10fd453
1
Parent(s):
23646ec
Add application file
Browse files
app.py
CHANGED
@@ -4,12 +4,12 @@ import torch
|
|
4 |
from PIL import ImageEnhance, Image
|
5 |
import numpy as np
|
6 |
|
7 |
-
# Load Stable Diffusion pipeline
|
8 |
model_id = "CompVis/stable-diffusion-v1-4"
|
9 |
default_scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
10 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=default_scheduler, torch_dtype=torch.float16)
|
11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
12 |
-
|
|
|
13 |
|
14 |
# Scheduler options
|
15 |
schedulers = {
|
|
|
4 |
from PIL import ImageEnhance, Image
|
5 |
import numpy as np
|
6 |
|
7 |
+
# Load Stable Diffusion pipeline with torch.float16 for GPU, fallback to float32 for CPU
|
8 |
model_id = "CompVis/stable-diffusion-v1-4"
|
9 |
default_scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
|
|
10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
11 |
+
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
12 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=default_scheduler, torch_dtype=torch_dtype).to(device)
|
13 |
|
14 |
# Scheduler options
|
15 |
schedulers = {
|