Hev832 commited on
Commit
2c81870
1 Parent(s): bc4547e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import DiffusionPipeline
3
+
4
+ # Load the diffusion pipeline
5
+ pipeline = DiffusionPipeline.from_pretrained("sd-community/sdxl-flash-mini")
6
+
7
+ def generate_image(prompt, num_inference_steps=50, guidance_scale=7.5):
8
+ # Generate image based on prompt
9
+ image = pipeline(prompt, num_inference_steps=num_inference_steps, guidance_scale=guidance_scale).images[0]
10
+ return image
11
+
12
+ # Create Gradio interface
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# sdxl-flash-mini")
15
+
16
+ with gr.Row():
17
+ with gr.Column():
18
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here")
19
+ num_inference_steps = gr.Slider(label="Number of Inference Steps", minimum=1, maximum=100, value=50)
20
+ guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, value=7.5)
21
+ generate_button = gr.Button("Generate Image")
22
+
23
+ with gr.Column():
24
+ output_image = gr.Image(label="Generated Image")
25
+
26
+ generate_button.click(
27
+ fn=generate_image,
28
+ inputs=[prompt, num_inference_steps, guidance_scale],
29
+ outputs=output_image
30
+ )
31
+
32
+ # Launch the Gradio interface
33
+ demo.launch()