RdnUser77 commited on
Commit
4735bd9
1 Parent(s): c9696a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -64,15 +64,23 @@ with gr.Blocks() as demo:
64
  with gr.Tab('Single model'):
65
  model_choice2 = gr.Dropdown(models, label = 'Choose model', value = models[0], filterable = False)
66
  txt_input2 = gr.Textbox(label = 'Prompt text')
 
 
 
 
67
  gen_button2 = gr.Button('Generate')
68
-
 
 
69
  with gr.Row():
70
- num_images = 6
71
- output2 = [gr.Image(label = '') for _ in range(num_images)]
72
 
73
- for o in output2:
74
- gen_button2.click(gen_fn, [model_choice2, txt_input2], o)
75
-
 
 
76
 
 
77
  demo.queue(concurrency_count = 36)
78
  demo.launch()
 
64
  with gr.Tab('Single model'):
65
  model_choice2 = gr.Dropdown(models, label = 'Choose model', value = models[0], filterable = False)
66
  txt_input2 = gr.Textbox(label = 'Prompt text')
67
+
68
+ max_images = 6
69
+ num_images = gr.Slider(1, max_images, value = max_images, step = 1, label = 'Number of images')
70
+
71
  gen_button2 = gr.Button('Generate')
72
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
73
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
74
+
75
  with gr.Row():
76
+ output2 = [gr.Image(label = '') for _ in range(max_images)]
 
77
 
78
+ for i, o in enumerate(output2):
79
+ img_i = gr.Number(i, visible = False)
80
+ num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o)
81
+ gen_event2 = gen_button2.click(lambda i, n, m, t: gen_fn(m, t) if (i < n) else None, [img_i, num_images, model_choice2, txt_input2], o)
82
+ stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
83
 
84
+
85
  demo.queue(concurrency_count = 36)
86
  demo.launch()