svjack commited on
Commit
88af592
·
verified ·
1 Parent(s): 29887e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -9
app.py CHANGED
@@ -16,15 +16,19 @@ def generate_image(prompt, guidance_scale, num_inference_steps):
16
 
17
  # Create a Gradio interface for the text-to-image generation
18
  with gr.Blocks() as demo:
19
- # Create a textbox for the user to input the text prompt
20
- prompt_input = gr.Textbox(label="Text Prompt")
21
- # Create sliders for the guidance scale and number of inference steps
22
- guidance_scale_slider = gr.Slider(1, 20, value=7.5, step=0.1, label="Guidance Scale")
23
- num_inference_steps_slider = gr.Slider(1, 100, value=50, step=1, label="Number of Inference Steps")
24
- # Create an image output to display the generated image
25
- image_output = gr.Image(label="Generated Image")
26
- # Create a button to trigger the image generation
27
- generate_button = gr.Button("Generate Image")
 
 
 
 
28
 
29
  # Add some documentation using HTML
30
  gr.HTML("""
@@ -33,8 +37,19 @@ with gr.Blocks() as demo:
33
  <p>Simply enter a text prompt, adjust the parameters, and click the 'Generate Image' button to see the generated image.</p>
34
  """)
35
 
 
 
 
36
  # Define the event listener for the button click
37
  generate_button.click(fn=generate_image, inputs=[prompt_input, guidance_scale_slider, num_inference_steps_slider], outputs=image_output)
 
 
 
 
 
 
 
 
38
 
39
  # Launch the Gradio app with share=True
40
  if __name__ == "__main__":
 
16
 
17
  # Create a Gradio interface for the text-to-image generation
18
  with gr.Blocks() as demo:
19
+ # Create a two-column layout
20
+ with gr.Row():
21
+ with gr.Column():
22
+ # Create a textbox for the user to input the text prompt
23
+ prompt_input = gr.Textbox(label="Text Prompt")
24
+ # Create sliders for the guidance scale and number of inference steps
25
+ guidance_scale_slider = gr.Slider(1, 20, value=7.5, step=0.1, label="Guidance Scale")
26
+ num_inference_steps_slider = gr.Slider(1, 100, value=50, step=1, label="Number of Inference Steps")
27
+ # Add a resolution input
28
+ #resolution_input = gr.Textbox(value="1536x1536", label="Resolution")
29
+ with gr.Column():
30
+ # Create an image output to display the generated image
31
+ image_output = gr.Image(label="Generated Image")
32
 
33
  # Add some documentation using HTML
34
  gr.HTML("""
 
37
  <p>Simply enter a text prompt, adjust the parameters, and click the 'Generate Image' button to see the generated image.</p>
38
  """)
39
 
40
+ # Create a button to trigger the image generation
41
+ generate_button = gr.Button("Generate Image")
42
+
43
  # Define the event listener for the button click
44
  generate_button.click(fn=generate_image, inputs=[prompt_input, guidance_scale_slider, num_inference_steps_slider], outputs=image_output)
45
+
46
+ # Add examples
47
+ examples = [
48
+ ["A fox drinking tea under a cherry blossom tree, anime style, 4K resolution"],
49
+ ["Night view of a futuristic city, cyberpunk style, neon lights"],
50
+ ["Medieval knight battling a dragon, epic scene, oil painting texture"]
51
+ ]
52
+ gr.Examples(examples, [prompt_input, guidance_scale_slider, num_inference_steps_slider])
53
 
54
  # Launch the Gradio app with share=True
55
  if __name__ == "__main__":