Yntec commited on
Commit
a29b766
β€’
1 Parent(s): cf80411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  from random import randint
3
  from all_models import models
4
 
 
 
5
  def load_fn(models):
6
  global models_load
7
  models_load = {}
@@ -42,33 +44,36 @@ def gen_fn(model_str, prompt):
42
 
43
  with gr.Blocks() as demo:
44
  with gr.Tab('The Dream'):
45
- txt_input = gr.Textbox(label = 'Your prompt:', lines=4).style(container=False,min_width=1200)
46
- gen_button = gr.Button('Generate up to 6 images in up to 3 minutes total')
47
- stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
48
- gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  gr.HTML(
50
  """
51
  <div style="text-align: center; max-width: 1200px; margin: 0 auto;">
52
  <div>
53
  <body>
54
- <div class="center"><p style="margin-bottom: 10px; color: #000000;">Scroll down to see more images and select models.</p>
55
  </div>
56
  </body>
57
  </div>
58
  </div>
59
  """
60
  )
61
- with gr.Row():
62
- output = [gr.Image(label = m, min_width=480) for m in default_models]
63
- current_models = [gr.Textbox(m, visible = False) for m in default_models]
64
-
65
- for m, o in zip(current_models, output):
66
- gen_event = gen_button.click(gen_fn, [m, txt_input], o)
67
- stop_button.click(lambda s: gr.update(interactive = False), None, stop_button, cancels = [gen_event])
68
- with gr.Accordion('Model selection'):
69
- model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 686 available!', value = default_models, multiselect = True, max_choices = num_models, interactive = True, filterable = False)
70
- model_choice.change(update_imgbox, model_choice, output)
71
- model_choice.change(extend_choices, model_choice, current_models)
72
  with gr.Row():
73
  gr.HTML(
74
  """
 
2
  from random import randint
3
  from all_models import models
4
 
5
+
6
+
7
  def load_fn(models):
8
  global models_load
9
  models_load = {}
 
44
 
45
  with gr.Blocks() as demo:
46
  with gr.Tab('The Dream'):
47
+ model_choice2 = gr.Dropdown(models, label = 'Choose model from the 686 available!', value = models[0], filterable = False)
48
+ txt_input2 = gr.Textbox(label = 'Your prompt:')
49
+
50
+ max_images = 6
51
+ num_images = gr.Slider(1, max_images, value = 1, step = 1, label = 'Number of images')
52
+
53
+ gen_button2 = gr.Button('Generate up to 6 images in up to 3 minutes total')
54
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
55
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
56
+
57
+ with gr.Row():
58
+ output2 = [gr.Image(label = '', min_width=480) for _ in range(max_images)]
59
+
60
+ for i, o in enumerate(output2):
61
+ img_i = gr.Number(i, visible = False)
62
+ num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, show_progress = False)
63
+ 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)
64
+ stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
65
  gr.HTML(
66
  """
67
  <div style="text-align: center; max-width: 1200px; margin: 0 auto;">
68
  <div>
69
  <body>
70
+ <div class="center"><p style="margin-bottom: 10px; color: #000000;">Scroll down to see more images.</p>
71
  </div>
72
  </body>
73
  </div>
74
  </div>
75
  """
76
  )
 
 
 
 
 
 
 
 
 
 
 
77
  with gr.Row():
78
  gr.HTML(
79
  """