panelforge commited on
Commit
d16d2c8
·
verified ·
1 Parent(s): e0a5232

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -46,7 +46,8 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
46
  generator=generator
47
  ).images[0]
48
 
49
- return image, seed
 
50
 
51
  examples = [
52
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
@@ -59,6 +60,9 @@ css = """
59
  margin: 0 auto;
60
  max-width: 640px;
61
  }
 
 
 
62
  """
63
 
64
  with gr.Blocks(css=css) as demo:
@@ -71,6 +75,9 @@ with gr.Blocks(css=css) as demo:
71
  # Display result image at the top
72
  result = gr.Image(label="Result", show_label=False)
73
 
 
 
 
74
  # Tabbed interface to select either Prompt or Tags
75
  with gr.Tabs() as tabs:
76
  with gr.TabItem("Prompt Input"):
@@ -92,7 +99,7 @@ with gr.Blocks(css=css) as demo:
92
  use_tags = gr.State(True)
93
 
94
  # Full-width "Run" button
95
- run_button = gr.Button("Run", scale=0)
96
 
97
  with gr.Accordion("Advanced Settings", open=False):
98
  negative_prompt = gr.Text(
@@ -146,10 +153,10 @@ with gr.Blocks(css=css) as demo:
146
  value=35,
147
  )
148
 
149
- gr.Examples(
150
- examples=examples,
151
- inputs=[prompt]
152
- )
153
 
154
  def check_tab(prompt, tag_selection_1, tag_selection_2, selected_tab):
155
  return selected_tab == "Tag Selection"
@@ -160,7 +167,7 @@ with gr.Blocks(css=css) as demo:
160
  triggers=[run_button.click, prompt.submit],
161
  fn=infer,
162
  inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags],
163
- outputs=[result, seed]
164
  )
165
 
166
  demo.queue().launch()
 
46
  generator=generator
47
  ).images[0]
48
 
49
+ # Return image, seed, and the used prompts
50
+ return image, seed, f"Prompt used: {final_prompt}\nNegative prompt used: {negative_prompt}"
51
 
52
  examples = [
53
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
 
60
  margin: 0 auto;
61
  max-width: 640px;
62
  }
63
+ #run-button {
64
+ width: 100%;
65
+ }
66
  """
67
 
68
  with gr.Blocks(css=css) as demo:
 
75
  # Display result image at the top
76
  result = gr.Image(label="Result", show_label=False)
77
 
78
+ # Add a textbox to display the prompts used for generation
79
+ prompt_info = gr.Textbox(label="Prompts Used", lines=3, interactive=False)
80
+
81
  # Tabbed interface to select either Prompt or Tags
82
  with gr.Tabs() as tabs:
83
  with gr.TabItem("Prompt Input"):
 
99
  use_tags = gr.State(True)
100
 
101
  # Full-width "Run" button
102
+ run_button = gr.Button("Run", scale=0, elem_id="run-button")
103
 
104
  with gr.Accordion("Advanced Settings", open=False):
105
  negative_prompt = gr.Text(
 
153
  value=35,
154
  )
155
 
156
+ # gr.Examples(
157
+ # examples=examples,
158
+ # inputs=[prompt]
159
+ # )
160
 
161
  def check_tab(prompt, tag_selection_1, tag_selection_2, selected_tab):
162
  return selected_tab == "Tag Selection"
 
167
  triggers=[run_button.click, prompt.submit],
168
  fn=infer,
169
  inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags],
170
+ outputs=[result, seed, prompt_info] # Include prompt_info in the outputs
171
  )
172
 
173
  demo.queue().launch()