Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,16 @@ from PIL import Image
|
|
| 7 |
@st.cache_resource
|
| 8 |
def load_model():
|
| 9 |
model_id = "runwayml/stable-diffusion-v1-5"
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return pipe
|
| 13 |
|
| 14 |
pipe = load_model()
|
|
|
|
| 7 |
@st.cache_resource
|
| 8 |
def load_model():
|
| 9 |
model_id = "runwayml/stable-diffusion-v1-5"
|
| 10 |
+
|
| 11 |
+
# Load the model
|
| 12 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
| 13 |
+
|
| 14 |
+
# Check if CUDA is available and use it, otherwise fall back to CPU
|
| 15 |
+
if torch.cuda.is_available():
|
| 16 |
+
pipe = pipe.to("cuda")
|
| 17 |
+
else:
|
| 18 |
+
pipe = pipe.to("cpu")
|
| 19 |
+
|
| 20 |
return pipe
|
| 21 |
|
| 22 |
pipe = load_model()
|