Spaces:
Runtime error
Runtime error
ejazhabibdar
commited on
Commit
•
5c34942
1
Parent(s):
200adb6
Update app.py
Browse files
app.py
CHANGED
@@ -3,14 +3,16 @@ from diffusers import AutoPipelineForText2Image
|
|
3 |
import torch
|
4 |
|
5 |
def load_model():
|
6 |
-
|
7 |
-
|
|
|
8 |
pipeline = AutoPipelineForText2Image.from_pretrained(
|
9 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
10 |
-
torch_dtype=torch.float16,
|
11 |
-
variant="fp16"
|
12 |
-
).to(
|
13 |
-
|
|
|
14 |
return pipeline
|
15 |
|
16 |
pipeline = load_model()
|
|
|
3 |
import torch
|
4 |
|
5 |
def load_model():
|
6 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
+
print(f"Using device: {device}")
|
8 |
+
|
9 |
pipeline = AutoPipelineForText2Image.from_pretrained(
|
10 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
11 |
+
torch_dtype=torch.float16 if device == "cuda" else torch.float32, # Use float32 if on CPU
|
12 |
+
variant="fp16" if device == "cuda" else "no"
|
13 |
+
).to(device)
|
14 |
+
|
15 |
+
pipeline.load_lora_weights("/content/", weight_name="EnvyFloorplansXL01.safetensors")
|
16 |
return pipeline
|
17 |
|
18 |
pipeline = load_model()
|