Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,20 +7,34 @@ import io
|
|
| 7 |
pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
| 8 |
api_key = os.getenv("API_KEY")
|
| 9 |
|
| 10 |
-
def
|
| 11 |
input_prompt = prompt
|
| 12 |
-
generated_image = pipeline
|
| 13 |
|
| 14 |
img = Image.fromarray(generated_image)
|
| 15 |
return img
|
| 16 |
|
| 17 |
-
title = "Stable
|
| 18 |
-
description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
gr.Interface(
|
| 21 |
-
fn=
|
| 22 |
-
inputs=["text", gr.
|
| 23 |
-
outputs="image",
|
| 24 |
-
title=title,
|
| 25 |
-
description=description
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
| 8 |
api_key = os.getenv("API_KEY")
|
| 9 |
|
| 10 |
+
def generate_image(prompt, style):
|
| 11 |
input_prompt = prompt
|
| 12 |
+
generated_image = pipeline(input_prompt)
|
| 13 |
|
| 14 |
img = Image.fromarray(generated_image)
|
| 15 |
return img
|
| 16 |
|
| 17 |
+
title = "Stable Diffusion XL"
|
| 18 |
+
description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model."
|
| 19 |
+
|
| 20 |
+
styles = {
|
| 21 |
+
"background": "linear-gradient(to bottom, #33ccff, #ff99cc)",
|
| 22 |
+
"color": "black",
|
| 23 |
+
"font-family": "Arial, sans-serif"
|
| 24 |
+
}
|
| 25 |
|
| 26 |
gr.Interface(
|
| 27 |
+
fn=generate_image,
|
| 28 |
+
inputs=["text", gr.Textbox(label="Style")],
|
| 29 |
+
outputs="image",
|
| 30 |
+
title=title,
|
| 31 |
+
description=description,
|
| 32 |
+
examples=[["Astronaut riding a horse", ""]],
|
| 33 |
+
theme="compact",
|
| 34 |
+
layout="vertical",
|
| 35 |
+
allow_flagging=False,
|
| 36 |
+
flagging_dir=None,
|
| 37 |
+
flagging_host=None,
|
| 38 |
+
capture_session=True,
|
| 39 |
+
css={"body": styles}
|
| 40 |
+
).launch()
|