Spaces:
Sleeping
Sleeping
support examples in the demo.
Browse files- app.py +24 -3
- example_list.py +38 -0
app.py
CHANGED
@@ -8,7 +8,7 @@ import time
|
|
8 |
from PIL import Image
|
9 |
from cldm.hack import disable_verbosity, enable_sliced_attention
|
10 |
# from pytorch_lightning import seed_everything
|
11 |
-
|
12 |
def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
13 |
shared_prompt,
|
14 |
width_0, width_1, width_2, width_3,
|
@@ -118,9 +118,11 @@ cfg = OmegaConf.load("config.yaml")
|
|
118 |
model = load_model_from_config(cfg, "checkpoints/laion10M_epoch_6_model_wo_ema.ckpt", verbose=True)
|
119 |
render_tool = Render_Text(model, save_memory = SAVE_MEMORY)
|
120 |
|
121 |
-
|
122 |
description = """
|
123 |
## Control Stable Diffusion with Glyph Images
|
|
|
|
|
|
|
124 |
"""
|
125 |
|
126 |
SPACE_ID = os.getenv('SPACE_ID')
|
@@ -192,7 +194,26 @@ with block:
|
|
192 |
message = gr.Text(interactive=False, label = "Message")
|
193 |
with gr.Row():
|
194 |
result_gallery = gr.Gallery(label='Images', show_label=False, elem_id="gallery").style(grid=2, height='auto')
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
run_button.click(fn=process_multi_wrapper,
|
197 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
198 |
shared_prompt,
|
|
|
8 |
from PIL import Image
|
9 |
from cldm.hack import disable_verbosity, enable_sliced_attention
|
10 |
# from pytorch_lightning import seed_everything
|
11 |
+
from example_list import examples
|
12 |
def process_multi_wrapper(rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
13 |
shared_prompt,
|
14 |
width_0, width_1, width_2, width_3,
|
|
|
118 |
model = load_model_from_config(cfg, "checkpoints/laion10M_epoch_6_model_wo_ema.ckpt", verbose=True)
|
119 |
render_tool = Render_Text(model, save_memory = SAVE_MEMORY)
|
120 |
|
|
|
121 |
description = """
|
122 |
## Control Stable Diffusion with Glyph Images
|
123 |
+
Github link: [Link](https://github.com/AIGText/GlyphControl-release)\n
|
124 |
+
Report: [link](https://arxiv.org/pdf/2305.18259.pdf)\n
|
125 |
+
You could try the listed examples at the bottom by clicking on them. We will update the examples progressively.
|
126 |
"""
|
127 |
|
128 |
SPACE_ID = os.getenv('SPACE_ID')
|
|
|
194 |
message = gr.Text(interactive=False, label = "Message")
|
195 |
with gr.Row():
|
196 |
result_gallery = gr.Gallery(label='Images', show_label=False, elem_id="gallery").style(grid=2, height='auto')
|
197 |
+
export_button = gr.Button(value="Export Parameters")
|
198 |
+
gr.Examples(
|
199 |
+
examples= examples, #"./examples",
|
200 |
+
# [[, "LAION-Glyph-10M-Epoch-6"]],
|
201 |
+
# ["./assets/img2.jpg", "r50-hdetr_sam-vit-b"],
|
202 |
+
# ["./assets/img3.jpg", "r50-hdetr_sam-vit-b"],
|
203 |
+
# ["./assets/img4.jpg", "r50-hdetr_sam-vit-b"]],
|
204 |
+
inputs=[ model_ckpt, shared_prompt,
|
205 |
+
rendered_txt_0, width_0, ratio_0, top_left_x_0, top_left_y_0, yaw_0, num_rows_0,
|
206 |
+
rendered_txt_1, width_1, ratio_1, top_left_x_1, top_left_y_1, yaw_1, num_rows_1,
|
207 |
+
rendered_txt_2, width_2, ratio_2, top_left_x_2, top_left_y_2, yaw_2, num_rows_2,
|
208 |
+
rendered_txt_3, width_3, ratio_3, top_left_x_3, top_left_y_3, yaw_3, num_rows_3,
|
209 |
+
shared_num_samples, shared_image_resolution,
|
210 |
+
shared_ddim_steps, shared_guess_mode,
|
211 |
+
shared_strength, shared_scale, shared_seed,
|
212 |
+
shared_eta, shared_a_prompt, shared_n_prompt],
|
213 |
+
# outputs=output_img,
|
214 |
+
# fn=inference
|
215 |
+
)
|
216 |
+
|
217 |
run_button.click(fn=process_multi_wrapper,
|
218 |
inputs=[rendered_txt_0, rendered_txt_1, rendered_txt_2, rendered_txt_3,
|
219 |
shared_prompt,
|
example_list.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
example_1 = [
|
2 |
+
"LAION-Glyph-10M-Epoch-6",
|
3 |
+
"A gift card with text ""Happy Birthday"" and roses on it.",
|
4 |
+
"Happy Birthday", 0.47, 0, 0.24, 0.4, 5, 1,
|
5 |
+
"", 0.3, 0, 0.15, 0.15, 0, 1,
|
6 |
+
"", 0.3, 0, 0.15, 0.65, 0, 1,
|
7 |
+
"", 0.3, 0, 0.5, 0.65, 0, 1,
|
8 |
+
5,512,20,False,1,9,0,0,
|
9 |
+
"4K, dslr, best quality, extremely detailed",
|
10 |
+
"longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality"
|
11 |
+
]
|
12 |
+
# teaser examples in the report (updating...)
|
13 |
+
# only could generate similar examples due to the fact that our released checkpoints are different from the checkpoint used in the original report.
|
14 |
+
example_2 = [
|
15 |
+
"LAION-Glyph-10M-Epoch-6",
|
16 |
+
'Newspaper with the headline "Aliens Found in Space" and "Monster Attacks Mars".',
|
17 |
+
'Aliens Found in Space', 0.8, 0, 0.1, 0.1, 0, 1,
|
18 |
+
'Monster Attacks Mars', 0.8, 0, 0.1, 0.45, 0, 1,
|
19 |
+
"", 0.3, 0, 0.15, 0.65, 0, 1,
|
20 |
+
"", 0.3, 0, 0.5, 0.65, 0, 1,
|
21 |
+
5,512,20,False,1,9,430637146,
|
22 |
+
0, "4K, dslr, best quality, extremely detailed",
|
23 |
+
"longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality"
|
24 |
+
]
|
25 |
+
examples = [example_1, example_2]
|
26 |
+
|
27 |
+
# example_3 = [
|
28 |
+
# "LAION-Glyph-10M-Epoch-6",
|
29 |
+
# 'A decorative greeting card that reads "Congratulations on achieving state of the art".',
|
30 |
+
# 'Congratulations', 0.6, 0, 0.2, 0.1, 0, 1,
|
31 |
+
# 'on achieving', 0.5, 0, 0.25, 0.22, 0, 1,
|
32 |
+
# 'state of the art', 0.6, 0, 0.21, 0.34, 0, 1,
|
33 |
+
# "", 0.3, 0, 0.5, 0.65, 0, 1,
|
34 |
+
# 5,512,20,False,1,9, 1540281202, #364285590,
|
35 |
+
# 0, "best quality, extremely detailed",
|
36 |
+
# "longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality"
|
37 |
+
# ]
|
38 |
+
# examples = [example_1, example_2, example_3]
|