Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,20 @@
|
|
| 1 |
-
from
|
| 2 |
|
| 3 |
-
#
|
| 4 |
api_key = "your_huggingface_api_key"
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
"
|
| 9 |
-
model="CompVis/stable-diffusion-v1-4-original",
|
| 10 |
use_auth_token=api_key
|
| 11 |
)
|
| 12 |
|
| 13 |
-
# Generate an image
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import StableDiffusionPipeline
|
| 2 |
|
| 3 |
+
# Replace with your Hugging Face API key
|
| 4 |
api_key = "your_huggingface_api_key"
|
| 5 |
|
| 6 |
+
# Load the Stable Diffusion pipeline
|
| 7 |
+
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 8 |
+
"stabilityai/stable-diffusion-v1-5-base",
|
|
|
|
| 9 |
use_auth_token=api_key
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# Generate an image from a text prompt
|
| 13 |
+
prompt = "A serene mountain landscape at sunset with a lake reflecting the sky"
|
| 14 |
+
image = pipeline(prompt).images[0]
|
| 15 |
|
| 16 |
+
# Save the generated image to a file
|
| 17 |
+
image.save("generated_image_v1_5.png")
|
| 18 |
+
|
| 19 |
+
# Optionally display the image if your environment supports it
|
| 20 |
+
image.show()
|