Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from diffusers import StableDiffusionPipeline
|
2 |
|
3 |
# Hugging Face API key
|
@@ -10,7 +11,8 @@ pipeline = StableDiffusionPipeline.from_pretrained(
|
|
10 |
)
|
11 |
|
12 |
# Move the pipeline to GPU if available
|
13 |
-
|
|
|
14 |
|
15 |
# Generate an image
|
16 |
prompt = "A serene lake surrounded by mountains during sunset"
|
|
|
1 |
+
import torch
|
2 |
from diffusers import StableDiffusionPipeline
|
3 |
|
4 |
# Hugging Face API key
|
|
|
11 |
)
|
12 |
|
13 |
# Move the pipeline to GPU if available
|
14 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
15 |
+
pipeline.to(device)
|
16 |
|
17 |
# Generate an image
|
18 |
prompt = "A serene lake surrounded by mountains during sunset"
|