Spaces:
Sleeping
Sleeping
modify the interface.
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
|
|
6 |
import os
|
7 |
import torch
|
8 |
import time
|
9 |
-
|
10 |
ALLOW_RUN_GENERATION = False
|
11 |
def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
12 |
shared_prompt,
|
@@ -22,7 +22,7 @@ def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, render
|
|
22 |
shared_eta, shared_a_prompt, shared_n_prompt):
|
23 |
global ALLOW_RUN_GENERATION
|
24 |
if not ALLOW_RUN_GENERATION:
|
25 |
-
return
|
26 |
|
27 |
rendered_txt_values = [rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3]
|
28 |
width_values = [width_0, width_1, width_2, width_3]
|
@@ -32,7 +32,7 @@ def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, render
|
|
32 |
yaw_values = [yaw_0, yaw_1, yaw_2, yaw_3]
|
33 |
num_rows_values = [num_rows_0, num_rows_1, num_rows_2, num_rows_3]
|
34 |
ALLOW_RUN_GENERATION = False
|
35 |
-
return render_tool.process_multi(rendered_txt_values, shared_prompt,
|
36 |
width_values, ratio_values,
|
37 |
top_left_x_values, top_left_y_values,
|
38 |
yaw_values, num_rows_values,
|
@@ -64,7 +64,7 @@ def process_multi_wrapper_only_show_rendered(rendered_txt_0, rendered_txt_1, ren
|
|
64 |
num_rows_values = [num_rows_0, num_rows_1, num_rows_2, num_rows_3]
|
65 |
ALLOW_RUN_GENERATION = True
|
66 |
|
67 |
-
return render_tool.process_multi(rendered_txt_values, shared_prompt,
|
68 |
width_values, ratio_values,
|
69 |
top_left_x_values, top_left_y_values,
|
70 |
yaw_values, num_rows_values,
|
@@ -167,9 +167,11 @@ with block:
|
|
167 |
shared_n_prompt = gr.Textbox(label="Negative Prompt",
|
168 |
value='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
169 |
|
170 |
-
with gr.
|
171 |
-
|
172 |
-
|
|
|
|
|
173 |
|
174 |
run_button.click(fn=process_multi_wrapper,
|
175 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
@@ -184,7 +186,7 @@ with block:
|
|
184 |
shared_ddim_steps, shared_guess_mode,
|
185 |
shared_strength, shared_scale, shared_seed,
|
186 |
shared_eta, shared_a_prompt, shared_n_prompt],
|
187 |
-
outputs=[result_gallery])
|
188 |
|
189 |
show_render_button.click(fn=process_multi_wrapper_only_show_rendered,
|
190 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
@@ -199,11 +201,11 @@ with block:
|
|
199 |
shared_ddim_steps, shared_guess_mode,
|
200 |
shared_strength, shared_scale, shared_seed,
|
201 |
shared_eta, shared_a_prompt, shared_n_prompt],
|
202 |
-
outputs=[result_gallery])
|
203 |
|
204 |
load_button.click(fn = load_ckpt,
|
205 |
inputs = [model_ckpt],
|
206 |
-
outputs = [result_gallery]
|
207 |
)
|
208 |
|
209 |
block.launch()
|
|
|
6 |
import os
|
7 |
import torch
|
8 |
import time
|
9 |
+
from PIL import Image
|
10 |
ALLOW_RUN_GENERATION = False
|
11 |
def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
12 |
shared_prompt,
|
|
|
22 |
shared_eta, shared_a_prompt, shared_n_prompt):
|
23 |
global ALLOW_RUN_GENERATION
|
24 |
if not ALLOW_RUN_GENERATION:
|
25 |
+
return "Please get the glyph image first by clicking the 'Only Rendered' button", None
|
26 |
|
27 |
rendered_txt_values = [rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3]
|
28 |
width_values = [width_0, width_1, width_2, width_3]
|
|
|
32 |
yaw_values = [yaw_0, yaw_1, yaw_2, yaw_3]
|
33 |
num_rows_values = [num_rows_0, num_rows_1, num_rows_2, num_rows_3]
|
34 |
ALLOW_RUN_GENERATION = False
|
35 |
+
return "Image generation processes finished!", render_tool.process_multi(rendered_txt_values, shared_prompt,
|
36 |
width_values, ratio_values,
|
37 |
top_left_x_values, top_left_y_values,
|
38 |
yaw_values, num_rows_values,
|
|
|
64 |
num_rows_values = [num_rows_0, num_rows_1, num_rows_2, num_rows_3]
|
65 |
ALLOW_RUN_GENERATION = True
|
66 |
|
67 |
+
return "Glyph images are generated!", render_tool.process_multi(rendered_txt_values, shared_prompt,
|
68 |
width_values, ratio_values,
|
69 |
top_left_x_values, top_left_y_values,
|
70 |
yaw_values, num_rows_values,
|
|
|
167 |
shared_n_prompt = gr.Textbox(label="Negative Prompt",
|
168 |
value='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
169 |
|
170 |
+
with gr.Accordion("Output", open=True):
|
171 |
+
with gr.Row():
|
172 |
+
message = gr.Text(interactive=False, label = "Message")
|
173 |
+
with gr.Row():
|
174 |
+
result_gallery = gr.Gallery(label='Images', show_label=False, elem_id="gallery").style(grid=2, height='auto')
|
175 |
|
176 |
run_button.click(fn=process_multi_wrapper,
|
177 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
|
|
186 |
shared_ddim_steps, shared_guess_mode,
|
187 |
shared_strength, shared_scale, shared_seed,
|
188 |
shared_eta, shared_a_prompt, shared_n_prompt],
|
189 |
+
outputs=[message, result_gallery])
|
190 |
|
191 |
show_render_button.click(fn=process_multi_wrapper_only_show_rendered,
|
192 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
|
|
201 |
shared_ddim_steps, shared_guess_mode,
|
202 |
shared_strength, shared_scale, shared_seed,
|
203 |
shared_eta, shared_a_prompt, shared_n_prompt],
|
204 |
+
outputs=[message, result_gallery])
|
205 |
|
206 |
load_button.click(fn = load_ckpt,
|
207 |
inputs = [model_ckpt],
|
208 |
+
outputs = [message, result_gallery]
|
209 |
)
|
210 |
|
211 |
block.launch()
|