Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,15 @@ api_key = "your_huggingface_api_key"
|
|
| 5 |
|
| 6 |
# Load the Stable Diffusion pipeline with the API key
|
| 7 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 8 |
-
"
|
| 9 |
use_auth_token=api_key
|
| 10 |
)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
# Generate an image
|
| 13 |
-
prompt = "A
|
| 14 |
image = pipeline(prompt).images[0]
|
| 15 |
|
| 16 |
# Save the generated image
|
|
|
|
| 5 |
|
| 6 |
# Load the Stable Diffusion pipeline with the API key
|
| 7 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 8 |
+
"CompVis/stable-diffusion-v1-4",
|
| 9 |
use_auth_token=api_key
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# Move the pipeline to GPU if available
|
| 13 |
+
pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 14 |
+
|
| 15 |
# Generate an image
|
| 16 |
+
prompt = "A serene lake surrounded by mountains during sunset"
|
| 17 |
image = pipeline(prompt).images[0]
|
| 18 |
|
| 19 |
# Save the generated image
|