Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ api_key = "your_huggingface_api_key"
|
|
| 6 |
|
| 7 |
# Load the Stable Diffusion pipeline with the API key
|
| 8 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 9 |
-
"
|
| 10 |
use_auth_token=api_key
|
| 11 |
)
|
| 12 |
|
|
@@ -14,13 +14,13 @@ pipeline = StableDiffusionPipeline.from_pretrained(
|
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
pipeline.to(device)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
# Generate an image
|
| 22 |
prompt = "A serene lake surrounded by mountains during sunset"
|
| 23 |
-
image = pipeline(prompt).images[0]
|
| 24 |
|
| 25 |
# Save the generated image
|
| 26 |
image.save("generated_image.png")
|
|
|
|
| 6 |
|
| 7 |
# Load the Stable Diffusion pipeline with the API key
|
| 8 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 9 |
+
"stabilityai/stable-diffusion-2", # You can try using the newer and faster version of Stable Diffusion.
|
| 10 |
use_auth_token=api_key
|
| 11 |
)
|
| 12 |
|
|
|
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
pipeline.to(device)
|
| 16 |
|
| 17 |
+
# Define a smaller resolution for faster generation
|
| 18 |
+
height = 512 # You can try 512 or 256 to make it faster
|
| 19 |
+
width = 512
|
| 20 |
|
| 21 |
# Generate an image
|
| 22 |
prompt = "A serene lake surrounded by mountains during sunset"
|
| 23 |
+
image = pipeline(prompt, height=height, width=width).images[0]
|
| 24 |
|
| 25 |
# Save the generated image
|
| 26 |
image.save("generated_image.png")
|