enable font color with slower inference
Browse files
app.py
CHANGED
|
@@ -158,10 +158,11 @@ def main():
|
|
| 158 |
with gr.Blocks(css=css) as demo:
|
| 159 |
url_params = gr.JSON({}, visible=False, label="URL Params")
|
| 160 |
gr.HTML("""<h1 style="font-weight: 900; margin-bottom: 7px;">Expressive Text-to-Image Generation with Rich Text</h1>
|
| 161 |
-
<p> <a href="https://songweige.github.io/">Songwei Ge</a>, <a href="https://taesung.me/">Taesung Park</a>, <a href="https://www.cs.cmu.edu/~junyanz/">Jun-Yan Zhu</a>, <a href="https://jbhuang0604.github.io/">Jia-Bin Huang</a> <p/>
|
| 162 |
<p> UMD, Adobe, CMU <p/>
|
|
|
|
| 163 |
<p> <a href="https://huggingface.co/spaces/songweig/rich-text-to-image?duplicate=true"><img src="https://bit.ly/3gLdBN6" style="display:inline;"alt="Duplicate Space"></a> | <a href="https://rich-text-to-image.github.io">[Website]</a> | <a href="https://github.com/SongweiGe/rich-text-to-image">[Code]</a> | <a href="https://arxiv.org/abs/2304.06720">[Paper]</a><p/>
|
| 164 |
-
<p> For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.""")
|
| 165 |
with gr.Row():
|
| 166 |
with gr.Column():
|
| 167 |
rich_text_el = gr.HTML(canvas_html, elem_id="canvas_html")
|
|
@@ -260,89 +261,78 @@ def main():
|
|
| 260 |
with gr.Row():
|
| 261 |
gr.Markdown(help_text)
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
with gr.Row():
|
| 323 |
color_examples = [
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
# [
|
| 336 |
-
# '{"ops":[{"insert":"a beautifule girl with big eye, skin, and long "},{"attributes":{"color":"#ff5df1"},"insert":"hair"},{"insert":", t-shirt, bursting with vivid color, intricate, elegant, highly detailed, photorealistic, digital painting, artstation, illustration, concept art."}]}',
|
| 337 |
-
# 'lowres, had anatomy, bad hands, cropped, worst quality',
|
| 338 |
-
# 11,
|
| 339 |
-
# 0.5,
|
| 340 |
-
# 0.3,
|
| 341 |
-
# 0.3,
|
| 342 |
-
# 6,
|
| 343 |
-
# 0.5,
|
| 344 |
-
# None,
|
| 345 |
-
# ],
|
| 346 |
[
|
| 347 |
'{"ops":[{"insert":"a beautifule girl with big eye, skin, and long "},{"attributes":{"color":"#999999"},"insert":"hair"},{"insert":", t-shirt, bursting with vivid color, intricate, elegant, highly detailed, photorealistic, digital painting, artstation, illustration, concept art."}]}',
|
| 348 |
'lowres, had anatomy, bad hands, cropped, worst quality',
|
|
@@ -389,112 +379,112 @@ def main():
|
|
| 389 |
cache_examples=True,
|
| 390 |
examples_per_page=20)
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
generate_button.click(fn=lambda: gr.update(visible=False), inputs=None, outputs=share_row, queue=False).then(
|
| 499 |
fn=generate,
|
| 500 |
inputs=[
|
|
|
|
| 158 |
with gr.Blocks(css=css) as demo:
|
| 159 |
url_params = gr.JSON({}, visible=False, label="URL Params")
|
| 160 |
gr.HTML("""<h1 style="font-weight: 900; margin-bottom: 7px;">Expressive Text-to-Image Generation with Rich Text</h1>
|
| 161 |
+
<p> <a href="https://songweige.github.io/">Songwei Ge</a>, <a href="https://taesung.me/">Taesung Park</a>, <a href="https://www.cs.cmu.edu/~junyanz/">Jun-Yan Zhu</a>, <a href="https://jbhuang0604.github.io/">Jia-Bin Huang</a> <p/>
|
| 162 |
<p> UMD, Adobe, CMU <p/>
|
| 163 |
+
<p> ICCV, 2023 <p/>
|
| 164 |
<p> <a href="https://huggingface.co/spaces/songweig/rich-text-to-image?duplicate=true"><img src="https://bit.ly/3gLdBN6" style="display:inline;"alt="Duplicate Space"></a> | <a href="https://rich-text-to-image.github.io">[Website]</a> | <a href="https://github.com/SongweiGe/rich-text-to-image">[Code]</a> | <a href="https://arxiv.org/abs/2304.06720">[Paper]</a><p/>
|
| 165 |
+
<p> Our method is now upgraded to use Stable Diffusion XL. For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.""")
|
| 166 |
with gr.Row():
|
| 167 |
with gr.Column():
|
| 168 |
rich_text_el = gr.HTML(canvas_html, elem_id="canvas_html")
|
|
|
|
| 261 |
with gr.Row():
|
| 262 |
gr.Markdown(help_text)
|
| 263 |
|
| 264 |
+
with gr.Row():
|
| 265 |
+
footnote_examples = [
|
| 266 |
+
[
|
| 267 |
+
'{"ops":[{"insert":"A close-up 4k dslr photo of a "},{"attributes":{"link":"A cat wearing sunglasses and a bandana around its neck."},"insert":"cat"},{"insert":" riding a scooter. Palm trees in the background."}]}',
|
| 268 |
+
'',
|
| 269 |
+
9,
|
| 270 |
+
0.3,
|
| 271 |
+
0.3,
|
| 272 |
+
0.5,
|
| 273 |
+
3,
|
| 274 |
+
0,
|
| 275 |
+
None,
|
| 276 |
+
],
|
| 277 |
+
[
|
| 278 |
+
'{"ops":[{"insert":"A cozy "},{"attributes":{"link":"A charming wooden cabin with Christmas decoration, warm light coming out from the windows."},"insert":"cabin"},{"insert":" nestled in a "},{"attributes":{"link":"Towering evergreen trees covered in a thick layer of pristine snow."},"insert":"snowy forest"},{"insert":", and a "},{"attributes":{"link":"A cute snowman wearing a carrot nose, coal eyes, and a colorful scarf, welcoming visitors with a cheerful vibe."},"insert":"snowman"},{"insert":" stands in the yard."}]}',
|
| 279 |
+
'',
|
| 280 |
+
12,
|
| 281 |
+
0.4,
|
| 282 |
+
0.3,
|
| 283 |
+
0.5,
|
| 284 |
+
3,
|
| 285 |
+
0,
|
| 286 |
+
None,
|
| 287 |
+
],
|
| 288 |
+
[
|
| 289 |
+
'{"ops":[{"insert":"A "},{"attributes":{"link":"Happy Kung fu panda art, elder, asian art, volumetric lighting, dramatic scene, ultra detailed, realism, chinese"},"insert":"panda"},{"insert":" standing on a cliff by a waterfall, wildlife photography, photograph, high quality, wildlife, f 1.8, soft focus, 8k, national geographic, award - winning photograph by nick nichols"}]}',
|
| 290 |
+
'',
|
| 291 |
+
5,
|
| 292 |
+
0.3,
|
| 293 |
+
0,
|
| 294 |
+
0.1,
|
| 295 |
+
4,
|
| 296 |
+
0,
|
| 297 |
+
None,
|
| 298 |
+
],
|
| 299 |
+
]
|
| 300 |
|
| 301 |
+
gr.Examples(examples=footnote_examples,
|
| 302 |
+
label='Footnote examples',
|
| 303 |
+
inputs=[
|
| 304 |
+
text_input,
|
| 305 |
+
negative_prompt,
|
| 306 |
+
num_segments,
|
| 307 |
+
segment_threshold,
|
| 308 |
+
inject_interval,
|
| 309 |
+
inject_background,
|
| 310 |
+
seed,
|
| 311 |
+
color_guidance_weight,
|
| 312 |
+
rich_text_input,
|
| 313 |
+
],
|
| 314 |
+
outputs=[
|
| 315 |
+
plaintext_result,
|
| 316 |
+
richtext_result,
|
| 317 |
+
segments,
|
| 318 |
+
token_map,
|
| 319 |
+
],
|
| 320 |
+
fn=generate,
|
| 321 |
+
cache_examples=True,
|
| 322 |
+
examples_per_page=20)
|
| 323 |
with gr.Row():
|
| 324 |
color_examples = [
|
| 325 |
+
[
|
| 326 |
+
'{"ops":[{"insert":"a beautifule girl with big eye, skin, and long "},{"attributes":{"color":"#04a704"},"insert":"hair"},{"insert":", t-shirt, bursting with vivid color, intricate, elegant, highly detailed, photorealistic, digital painting, artstation, illustration, concept art."}]}',
|
| 327 |
+
'lowres, had anatomy, bad hands, cropped, worst quality',
|
| 328 |
+
11,
|
| 329 |
+
0.5,
|
| 330 |
+
0.3,
|
| 331 |
+
0.3,
|
| 332 |
+
6,
|
| 333 |
+
0.5,
|
| 334 |
+
None,
|
| 335 |
+
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
[
|
| 337 |
'{"ops":[{"insert":"a beautifule girl with big eye, skin, and long "},{"attributes":{"color":"#999999"},"insert":"hair"},{"insert":", t-shirt, bursting with vivid color, intricate, elegant, highly detailed, photorealistic, digital painting, artstation, illustration, concept art."}]}',
|
| 338 |
'lowres, had anatomy, bad hands, cropped, worst quality',
|
|
|
|
| 379 |
cache_examples=True,
|
| 380 |
examples_per_page=20)
|
| 381 |
|
| 382 |
+
with gr.Row():
|
| 383 |
+
style_examples = [
|
| 384 |
+
[
|
| 385 |
+
'{"ops":[{"insert":"a beautiful"},{"attributes":{"font":"mirza"},"insert":" garden"},{"insert":" with a "},{"attributes":{"font":"roboto"},"insert":"snow mountain"},{"insert":" in the background"}]}',
|
| 386 |
+
'',
|
| 387 |
+
10,
|
| 388 |
+
0.6,
|
| 389 |
+
0,
|
| 390 |
+
0.4,
|
| 391 |
+
5,
|
| 392 |
+
0,
|
| 393 |
+
None,
|
| 394 |
+
],
|
| 395 |
+
[
|
| 396 |
+
'{"ops":[{"insert":"a night"},{"attributes":{"font":"slabo"},"insert":" sky"},{"insert":" filled with stars above a turbulent"},{"attributes":{"font":"roboto"},"insert":" sea"},{"insert":" with giant waves"}]}',
|
| 397 |
+
'',
|
| 398 |
+
2,
|
| 399 |
+
0.6,
|
| 400 |
+
0,
|
| 401 |
+
0,
|
| 402 |
+
6,
|
| 403 |
+
0.5,
|
| 404 |
+
None,
|
| 405 |
+
],
|
| 406 |
+
]
|
| 407 |
+
gr.Examples(examples=style_examples,
|
| 408 |
+
label='Font style examples',
|
| 409 |
+
inputs=[
|
| 410 |
+
text_input,
|
| 411 |
+
negative_prompt,
|
| 412 |
+
num_segments,
|
| 413 |
+
segment_threshold,
|
| 414 |
+
inject_interval,
|
| 415 |
+
inject_background,
|
| 416 |
+
seed,
|
| 417 |
+
color_guidance_weight,
|
| 418 |
+
rich_text_input,
|
| 419 |
+
],
|
| 420 |
+
outputs=[
|
| 421 |
+
plaintext_result,
|
| 422 |
+
richtext_result,
|
| 423 |
+
segments,
|
| 424 |
+
token_map,
|
| 425 |
+
],
|
| 426 |
+
fn=generate,
|
| 427 |
+
cache_examples=True,
|
| 428 |
+
examples_per_page=20)
|
| 429 |
|
| 430 |
+
with gr.Row():
|
| 431 |
+
size_examples = [
|
| 432 |
+
[
|
| 433 |
+
'{"ops": [{"insert": "A pizza with "}, {"attributes": {"size": "60px"}, "insert": "pineapple"}, {"insert": " pepperoni, and mushroom on the top"}]}',
|
| 434 |
+
'',
|
| 435 |
+
5,
|
| 436 |
+
0.3,
|
| 437 |
+
0,
|
| 438 |
+
0,
|
| 439 |
+
3,
|
| 440 |
+
1,
|
| 441 |
+
None,
|
| 442 |
+
],
|
| 443 |
+
[
|
| 444 |
+
'{"ops": [{"insert": "A pizza with pineapple, "}, {"attributes": {"size": "60px"}, "insert": "pepperoni"}, {"insert": ", and mushroom on the top"}]}',
|
| 445 |
+
'',
|
| 446 |
+
5,
|
| 447 |
+
0.3,
|
| 448 |
+
0,
|
| 449 |
+
0,
|
| 450 |
+
3,
|
| 451 |
+
1,
|
| 452 |
+
None,
|
| 453 |
+
],
|
| 454 |
+
[
|
| 455 |
+
'{"ops": [{"insert": "A pizza with pineapple, pepperoni, and "}, {"attributes": {"size": "60px"}, "insert": "mushroom"}, {"insert": " on the top"}]}',
|
| 456 |
+
'',
|
| 457 |
+
5,
|
| 458 |
+
0.3,
|
| 459 |
+
0,
|
| 460 |
+
0,
|
| 461 |
+
3,
|
| 462 |
+
1,
|
| 463 |
+
None,
|
| 464 |
+
],
|
| 465 |
+
]
|
| 466 |
+
gr.Examples(examples=size_examples,
|
| 467 |
+
label='Font size examples',
|
| 468 |
+
inputs=[
|
| 469 |
+
text_input,
|
| 470 |
+
negative_prompt,
|
| 471 |
+
num_segments,
|
| 472 |
+
segment_threshold,
|
| 473 |
+
inject_interval,
|
| 474 |
+
inject_background,
|
| 475 |
+
seed,
|
| 476 |
+
color_guidance_weight,
|
| 477 |
+
rich_text_input,
|
| 478 |
+
],
|
| 479 |
+
outputs=[
|
| 480 |
+
plaintext_result,
|
| 481 |
+
richtext_result,
|
| 482 |
+
segments,
|
| 483 |
+
token_map,
|
| 484 |
+
],
|
| 485 |
+
fn=generate,
|
| 486 |
+
cache_examples=True,
|
| 487 |
+
examples_per_page=20)
|
| 488 |
generate_button.click(fn=lambda: gr.update(visible=False), inputs=None, outputs=share_row, queue=False).then(
|
| 489 |
fn=generate,
|
| 490 |
inputs=[
|