Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
|
4 |
+
# Load the diffusion model
|
5 |
+
pipe = DiffusionPipeline.from_pretrained("ByteDance/SDXL-Lightning")
|
6 |
+
|
7 |
+
def generate_image(prompt):
|
8 |
+
# Generate the image based on the prompt
|
9 |
+
image = pipe(prompt).images[0]
|
10 |
+
return image
|
11 |
+
|
12 |
+
# Create a Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_image,
|
15 |
+
inputs=gr.inputs.Textbox(label="Enter your prompt", placeholder="e.g., Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"),
|
16 |
+
outputs=gr.outputs.Image(type="pil", label="Generated Image"),
|
17 |
+
title="Image Generation with SDXL-Lightning",
|
18 |
+
description="Enter a prompt to generate an image using the SDXL-Lightning model."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the Gradio interface
|
22 |
+
if __name__ == "__main__":
|
23 |
+
iface.launch()
|