Yntec commited on
Commit
7f74da5
β€’
1 Parent(s): 06456ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from random import randint
3
  from all_models import models
4
-
5
 
6
 
7
  def load_fn(models):
@@ -11,7 +11,7 @@ def load_fn(models):
11
  for model in models:
12
  if model not in models_load.keys():
13
  try:
14
- m = gr.load(f'models/{model}')
15
  except Exception as error:
16
  m = gr.Interface(lambda txt: None, ['text'], ['image'])
17
  models_load.update({model: m})
@@ -26,11 +26,11 @@ default_models = models[:num_models]
26
 
27
 
28
  def extend_choices(choices):
29
- return choices + (num_models - len(choices)) * ['NA']
30
 
31
 
32
  def update_imgbox(choices):
33
- choices_plus = extend_choices(choices)
34
  return [gr.Image(None, label = m, visible = (m != 'NA')) for m in choices_plus]
35
 
36
 
@@ -43,9 +43,17 @@ def gen_fn(model_str, prompt):
43
 
44
 
45
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
46
  with gr.Tab('The Dream'):
47
- txt_input = gr.Textbox(label = 'Your prompt:', lines=4).style(container=False,min_width=1200)
48
- gen_button = gr.Button('Generate up to 6 images in up to 3 minutes total')
49
  stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
50
  gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
51
  gr.HTML(
@@ -68,7 +76,11 @@ with gr.Blocks() as demo:
68
  gen_event = gen_button.click(gen_fn, [m, txt_input], o)
69
  stop_button.click(lambda s: gr.update(interactive = False), None, stop_button, cancels = [gen_event])
70
  with gr.Accordion('Model selection'):
71
- model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 866 available!', value = default_models, multiselect = True, max_choices = num_models, interactive = True, filterable = False)
 
 
 
 
72
  model_choice.change(update_imgbox, model_choice, output)
73
  model_choice.change(extend_choices, model_choice, current_models)
74
  with gr.Row():
@@ -80,5 +92,5 @@ with gr.Blocks() as demo:
80
  """
81
  )
82
 
83
- demo.queue(concurrency_count = 200)
84
  demo.launch()
 
1
  import gradio as gr
2
  from random import randint
3
  from all_models import models
4
+ from externalmod import gr_Interface_load
5
 
6
 
7
  def load_fn(models):
 
11
  for model in models:
12
  if model not in models_load.keys():
13
  try:
14
+ m = gr_Interface_load(f'models/{model}')
15
  except Exception as error:
16
  m = gr.Interface(lambda txt: None, ['text'], ['image'])
17
  models_load.update({model: m})
 
26
 
27
 
28
  def extend_choices(choices):
29
+ return choices[0:num_models] + (num_models - len(choices[0:num_models])) * ['NA']
30
 
31
 
32
  def update_imgbox(choices):
33
+ choices_plus = extend_choices(choices[0:num_models])
34
  return [gr.Image(None, label = m, visible = (m != 'NA')) for m in choices_plus]
35
 
36
 
 
43
 
44
 
45
  with gr.Blocks() as demo:
46
+ gr.HTML(
47
+ """
48
+ <div>
49
+ <p> <center>For simultaneous generations without queue check out <a href="https://huggingface.co/spaces/Yntec/ToyWorld">Toy World</a>!</center>
50
+ </p></div>
51
+ """
52
+ )
53
+
54
  with gr.Tab('The Dream'):
55
+ txt_input = gr.Textbox(label = 'Your prompt:', lines=4) #.style(container=False,min_width=1200)
56
+ gen_button = gr.Button('Generate up to 6 images from 1 minute to 18 minutes total wait time')
57
  stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
58
  gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
59
  gr.HTML(
 
76
  gen_event = gen_button.click(gen_fn, [m, txt_input], o)
77
  stop_button.click(lambda s: gr.update(interactive = False), None, stop_button, cancels = [gen_event])
78
  with gr.Accordion('Model selection'):
79
+ #model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 866 available!', value = default_models, multiselect = True, max_choices = num_models, interactive = True, filterable = False)
80
+ #model_choice.change(update_imgbox, model_choice, output)
81
+ #model_choice.change(extend_choices, model_choice, current_models)
82
+ model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 874 available!', value = default_models, interactive = True)
83
+ #model_choice.change(lambda x: x[0:num_models], [model_choice], [model_choice])
84
  model_choice.change(update_imgbox, model_choice, output)
85
  model_choice.change(extend_choices, model_choice, current_models)
86
  with gr.Row():
 
92
  """
93
  )
94
 
95
+ demo.queue()
96
  demo.launch()