Kohaku-Blueleaf commited on
Commit
7fdb61e
1 Parent(s): 0380877

Avoid conflicting btn

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -275,14 +275,19 @@ TITPOP
275
  input_prompt = gr.Textbox(
276
  label="Input Prompt", lines=1, interactive=False, visible=False
277
  )
278
- gen_img = gr.Button("Generate Image from Result", variant="primary")
279
  with gr.Row():
280
  with gr.Column():
281
  img1 = gr.Image(label="Original Propmt", interactive=False)
282
  with gr.Column():
283
  img2 = gr.Image(label="Generated Prompt", interactive=False)
 
 
 
 
 
284
  submit.click(
285
- generate,
286
  [
287
  tags_input,
288
  nl_prompt_input,
@@ -299,14 +304,21 @@ TITPOP
299
  result,
300
  input_prompt,
301
  cost_time,
 
302
  ],
303
  queue=True,
304
  )
305
  gen_img.click(
306
- generate_image,
307
  [seed, result, input_prompt],
308
- [img1, img2],
309
  queue=True,
310
  )
 
 
 
 
 
 
311
 
312
  demo.launch()
 
275
  input_prompt = gr.Textbox(
276
  label="Input Prompt", lines=1, interactive=False, visible=False
277
  )
278
+ gen_img = gr.Button("Generate Image from Result", variant="primary", interactive=False)
279
  with gr.Row():
280
  with gr.Column():
281
  img1 = gr.Image(label="Original Propmt", interactive=False)
282
  with gr.Column():
283
  img2 = gr.Image(label="Generated Prompt", interactive=False)
284
+ def generate_wrapper(*args):
285
+ yield "", "", "", gr.update(interactive=False),
286
+ for i in generate(*args):
287
+ yield *i, gr.update(interactive=False)
288
+ yield *i, gr.update(interactive=True)
289
  submit.click(
290
+ generate_wrapper,
291
  [
292
  tags_input,
293
  nl_prompt_input,
 
304
  result,
305
  input_prompt,
306
  cost_time,
307
+ gen_img,
308
  ],
309
  queue=True,
310
  )
311
  gen_img.click(
312
+ lambda *args: (*generate_image(*args), gr.update(interactive=True)),
313
  [seed, result, input_prompt],
314
+ [img1, img2, submit],
315
  queue=True,
316
  )
317
+ gen_img.click(
318
+ lambda *args: gr.update(interactive=False),
319
+ None,
320
+ [submit],
321
+ queue=False,
322
+ )
323
 
324
  demo.launch()