DigiP-AI commited on
Commit
536c6cd
Β·
verified Β·
1 Parent(s): d98d701

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -37
app.py CHANGED
@@ -83,9 +83,9 @@ def query(prompt, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Ka
83
  return None
84
 
85
  examples = [
86
- ["a beautiful woman with blonde hair and blue eyes"],
87
- ["a beautiful woman with brown hair and grey eyes"],
88
- ["a beautiful woman with black hair and brown eyes"],
89
  ]
90
 
91
  def encode_image(image_path):
@@ -146,7 +146,6 @@ def feifeichat(image):
146
 
147
  # CSS to style the app
148
  css = """
149
- .gradio-container {background-color: MediumAquaMarine}
150
  footer{display:none !important}
151
  #app-container {
152
  max-width: 930px;
@@ -159,20 +158,19 @@ footer{display:none !important}
159
  with gr.Blocks(theme=theme, css=css) as app:
160
  # Add a title to the app
161
  gr.HTML("<center><h1>🎨 Stable Diffusion 3.5 Large Turbo + πŸ‡¬πŸ‡§</h1></center>")
162
- # with gr.Tabs() as tabs:
163
- with gr.Tab(label="πŸ–Ό Image To Prompt πŸ“„", visible=True):
164
- with gr.Row():
165
- with gr.Column():
166
- input_img = gr.Image(label="Input Picture πŸ–ΌοΈ",height=320,type="filepath")
167
- submit_btn = gr.Button(value="Submit", variant='primary')
168
  with gr.Column():
169
  output_text = gr.Textbox(label="Flux Prompt ✍️", show_copy_button = True)
170
  clr_button =gr.Button("Clear πŸ—‘οΈ ",variant="primary", elem_id="clear_button")
171
  clr_button.click(lambda: (None, None), None, [input_img, output_text], queue=False, show_api=False)
172
 
173
  submit_btn.click(feifeichat, [input_img], [output_text])
174
-
175
- #Create image from prompt
176
  with gr.TabItem("✍️ Text to Image πŸ–Ό", visible=True):
177
  # Container for all the UI elements
178
  with gr.Column(elem_id="app-container"):
@@ -203,39 +201,35 @@ with gr.Blocks(theme=theme, css=css) as app:
203
  clear_prompt.click(lambda: (None), None, [text_prompt], queue=False, show_api=False)
204
 
205
  with gr.Column(elem_id="app-container"):
206
- # Image output area to display the generated image
207
- with gr.Row():
208
- image_output = gr.Image(type="pil", label="Image Output", format="png", show_share_button=False, elem_id="gallery")
209
-
210
- with gr.Column():
211
- with gr.Row():
212
- clear_results = gr.Button(value="Clear Image πŸ—‘οΈ", variant="primary", elem_id="clear_button")
213
- clear_results.click(lambda: (None), None, [image_output], queue=False, show_api=False)
214
-
215
- with gr.Row():
216
  gr.Examples(
217
  examples = examples,
218
  inputs = [text_prompt],
219
  )
220
-
 
 
 
 
221
  # Bind the button to the query function with the added width and height inputs
222
-
223
  text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
224
 
225
- #Flip image code
226
- with gr.Tab("πŸ”„ Flip Image", visible=True):
227
- with gr.Row():
228
- image_input = gr.Image(type="numpy", label="Upload Image",height=320)
229
- image_output = gr.Image(format="png")
230
- with gr.Row():
231
- image_button = gr.Button("Run", variant='primary')
232
- image_button.click(flip_image, inputs=image_input, outputs=image_output)
233
- with gr.Row():
234
- clear_results = gr.Button(value="Clear Image", variant="primary", elem_id="clear_button")
235
- clear_results.click(lambda: (None, None), None, [image_input, image_output])
236
-
237
 
238
- with gr.Tab("ℹ️ Tips", visible=True):
239
  with gr.Column():
240
  with gr.Row():
241
  with gr.Column():
 
83
  return None
84
 
85
  examples = [
86
+ "a beautiful woman with blonde hair and blue eyes",
87
+ "a beautiful woman with brown hair and grey eyes",
88
+ "a beautiful woman with black hair and brown eyes",
89
  ]
90
 
91
  def encode_image(image_path):
 
146
 
147
  # CSS to style the app
148
  css = """
 
149
  footer{display:none !important}
150
  #app-container {
151
  max-width: 930px;
 
158
  with gr.Blocks(theme=theme, css=css) as app:
159
  # Add a title to the app
160
  gr.HTML("<center><h1>🎨 Stable Diffusion 3.5 Large Turbo + πŸ‡¬πŸ‡§</h1></center>")
161
+ with gr.Tabs() as tabs:
162
+ with gr.TabItem(label="πŸ–Ό Image To Prompt πŸ“„", visible=True):
163
+ with gr.Row():
164
+ with gr.Column():
165
+ input_img = gr.Image(label="Input Picture πŸ–ΌοΈ",height=320,type="filepath")
166
+ submit_btn = gr.Button(value="Submit", variant='primary')
167
  with gr.Column():
168
  output_text = gr.Textbox(label="Flux Prompt ✍️", show_copy_button = True)
169
  clr_button =gr.Button("Clear πŸ—‘οΈ ",variant="primary", elem_id="clear_button")
170
  clr_button.click(lambda: (None, None), None, [input_img, output_text], queue=False, show_api=False)
171
 
172
  submit_btn.click(feifeichat, [input_img], [output_text])
173
+
 
174
  with gr.TabItem("✍️ Text to Image πŸ–Ό", visible=True):
175
  # Container for all the UI elements
176
  with gr.Column(elem_id="app-container"):
 
201
  clear_prompt.click(lambda: (None), None, [text_prompt], queue=False, show_api=False)
202
 
203
  with gr.Column(elem_id="app-container"):
204
+ with gr.Group():
205
+ # Image output area to display the generated image
206
+ with gr.Row():
207
+ image_output = gr.Image(type="pil", label="Image Output", format="png", show_share_button=False, elem_id="gallery")
208
+
 
 
 
 
 
209
  gr.Examples(
210
  examples = examples,
211
  inputs = [text_prompt],
212
  )
213
+ with gr.Group():
214
+ with gr.Row():
215
+ clear_results = gr.Button(value="Clear Image πŸ—‘οΈ", variant="primary", elem_id="clear_button")
216
+ clear_results.click(lambda: (None), None, [image_output], queue=False, show_api=False)
217
+
218
  # Bind the button to the query function with the added width and height inputs
 
219
  text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
220
 
221
+ with gr.TabItem("πŸ”„ Flip Image", visible=True):
222
+ with gr.Row():
223
+ image_input = gr.Image(label="Upload Image", height=320, type="filepath")
224
+ image_output = gr.Image(format="png")
225
+ with gr.Row():
226
+ image_button = gr.Button("Run", variant='primary')
227
+ image_button.click(flip_image, inputs=image_input, outputs=image_output)
228
+ with gr.Row():
229
+ clear_results = gr.Button(value="Clear Image", variant="primary", elem_id="clear_button")
230
+ clear_results.click(lambda: (None, None), None, [image_input, image_output])
 
 
231
 
232
+ with gr.TabItem("ℹ️ Tips", visible=True):
233
  with gr.Column():
234
  with gr.Row():
235
  with gr.Column():