charliebaby2023 commited on
Commit
feed948
·
verified ·
1 Parent(s): f345af2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -4
app.py CHANGED
@@ -13,8 +13,8 @@ import traceback # For better error reporting
13
  os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
14
  logging.basicConfig(level=logging.WARNING)
15
  now2 = 0
16
- index_tracker = 0 # Index tracker for the current model
17
- model_scores = {model: 0 for model in models} # Dictionary to track scores for each model
18
  processed_models_count = 0
19
  kii=" blonde mohawk femboy playing game with self at computer with programmer socks on, still a wip"
20
  combined_prompt = ""
@@ -56,6 +56,9 @@ def load_fn(models):
56
  models_load[model] = None
57
 
58
 
 
 
 
59
 
60
  #return models_load # Return dictionary instead of using global
61
 
@@ -68,6 +71,19 @@ def update_imgbox(choices):
68
  choices_plus = extend_choices(choices)
69
  return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  executor = ThreadPoolExecutor(max_workers=num_models)
73
 
@@ -142,11 +158,13 @@ def gen_fn(model_str, prompt):
142
  def make_me():
143
  with gr.Row():
144
  txt_input = gr.Textbox(lines=2, value=kii, label=None)
 
145
  gen_button = gr.Button('Generate images')
146
  stop_button = gr.Button('Stop', variant='secondary', interactive=False)
147
 
148
  #gen_button.click(lambda _: gr.update(interactive=True), None, stop_button)
149
- gen_button.click(lambda _: gr.update(interactive=True), None)
 
150
  gr.HTML(""" <div style="text-align: center; max-width: 100%; margin: 0 auto;"> <body> </body> </div> """)
151
 
152
  with gr.Row():
@@ -154,7 +172,13 @@ def make_me():
154
  current_models = [gr.Textbox(m, visible=False) for m in default_models]
155
  for m, o in zip(current_models, output):
156
  gen_event = gen_button.click(gen_fn, [m, txt_input], o)
157
- # stop_button.click(lambda _: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
 
 
 
 
 
 
158
 
159
 
160
  with gr.Accordion('Model selection', visible=False):
@@ -190,3 +214,49 @@ demo.queue()
190
  demo.queue = False
191
  demo.config["queue"] = False
192
  demo.launch(max_threads=200)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
14
  logging.basicConfig(level=logging.WARNING)
15
  now2 = 0
16
+ index_tracker = 0
17
+ model_scores = {model: 0 for model in models}
18
  processed_models_count = 0
19
  kii=" blonde mohawk femboy playing game with self at computer with programmer socks on, still a wip"
20
  combined_prompt = ""
 
56
  models_load[model] = None
57
 
58
 
59
+ # m = gr.Interface(lambda txt: None, ['text'], ['image'])
60
+ # models_load.update({model: m})
61
+
62
 
63
  #return models_load # Return dictionary instead of using global
64
 
 
71
  choices_plus = extend_choices(choices)
72
  return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
73
 
74
+
75
+
76
+
77
+
78
+ #def gen_fn(model_str, prompt):
79
+ # if model_str == 'NA':
80
+ # return None
81
+ # noise = str(randint(0, 9999))
82
+ # return models_load[model_str](f'{prompt} {noise}')
83
+
84
+
85
+
86
+
87
 
88
  executor = ThreadPoolExecutor(max_workers=num_models)
89
 
 
158
  def make_me():
159
  with gr.Row():
160
  txt_input = gr.Textbox(lines=2, value=kii, label=None)
161
+
162
  gen_button = gr.Button('Generate images')
163
  stop_button = gr.Button('Stop', variant='secondary', interactive=False)
164
 
165
  #gen_button.click(lambda _: gr.update(interactive=True), None, stop_button)
166
+ #gen_button.click(lambda s: gr.update(interactive=True), None)
167
+ gen_button.click(lambda _: gr.update(interactive=True), None, stop_button)
168
  gr.HTML(""" <div style="text-align: center; max-width: 100%; margin: 0 auto;"> <body> </body> </div> """)
169
 
170
  with gr.Row():
 
172
  current_models = [gr.Textbox(m, visible=False) for m in default_models]
173
  for m, o in zip(current_models, output):
174
  gen_event = gen_button.click(gen_fn, [m, txt_input], o)
175
+ stop_button.click(lambda s: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
176
+
177
+
178
+
179
+
180
+
181
+
182
 
183
 
184
  with gr.Accordion('Model selection', visible=False):
 
214
  demo.queue = False
215
  demo.config["queue"] = False
216
  demo.launch(max_threads=200)
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ #demo.queue(concurrency_count=999)
230
+ #demo.launch()
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+ #load_fn(models)
247
+ #num_models = len(models)
248
+ #default_models = models[:num_models]
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+