Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def update_imgbox(choices):
|
|
34 |
choices_plus = extend_choices(choices)
|
35 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
36 |
|
37 |
-
def gen_fn(model_str, prompt, negative_prompt, max_retries=10
|
38 |
if model_str == 'NA':
|
39 |
return None, ""
|
40 |
|
@@ -43,10 +43,18 @@ def gen_fn(model_str, prompt, negative_prompt, max_retries=10, progress=gr.Progr
|
|
43 |
while retries < max_retries:
|
44 |
try:
|
45 |
noise = str(randint(0, 9999999))
|
46 |
-
with
|
47 |
-
for
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
if hasattr(models_load[model_str], 'negative_prompt'):
|
52 |
result = models_load[model_str](f'{prompt} {noise}', negative_prompt=negative_prompt)
|
@@ -106,7 +114,7 @@ def make_me():
|
|
106 |
progress_bars.append(gr.Progress(visible=False))
|
107 |
|
108 |
for m, o, p, l, c in zip(current_models, output, progress_bars, progress_labels, default_models):
|
109 |
-
|
110 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
111 |
|
112 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|
|
|
34 |
choices_plus = extend_choices(choices)
|
35 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
36 |
|
37 |
+
def gen_fn(model_str, prompt, negative_prompt, max_retries=10):
|
38 |
if model_str == 'NA':
|
39 |
return None, ""
|
40 |
|
|
|
43 |
while retries < max_retries:
|
44 |
try:
|
45 |
noise = str(randint(0, 9999999))
|
46 |
+
with gr.Blocks.update():
|
47 |
+
for i, m in enumerate(default_models):
|
48 |
+
if m == model_str:
|
49 |
+
progress_bars[i].update(value=0, visible=True)
|
50 |
+
progress_labels[i].update(value=f"**Progress for {m}**")
|
51 |
+
|
52 |
+
for step in range(1, 101):
|
53 |
+
time.sleep(0.05) # Simulate work being done
|
54 |
+
with gr.Blocks.update():
|
55 |
+
for i, m in enumerate(default_models):
|
56 |
+
if m == model_str:
|
57 |
+
progress_bars[i].update(value=step / 100)
|
58 |
|
59 |
if hasattr(models_load[model_str], 'negative_prompt'):
|
60 |
result = models_load[model_str](f'{prompt} {noise}', negative_prompt=negative_prompt)
|
|
|
114 |
progress_bars.append(gr.Progress(visible=False))
|
115 |
|
116 |
for m, o, p, l, c in zip(current_models, output, progress_bars, progress_labels, default_models):
|
117 |
+
gen_button.click(gen_fn, [m, txt_input, negative_txt_input, gr.Slider(1, 10, value=10, label="Max Retries")], [o, feedback_box])
|
118 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
119 |
|
120 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|