Spaces:
Running
Running
File size: 27,923 Bytes
7c1eee1 a4c3ce7 7c1eee1 f8f1d3f 7c1eee1 55fb4c1 7c1eee1 55fb4c1 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 a4c3ce7 7c1eee1 6296cf9 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 a4c3ce7 7c1eee1 55fb4c1 7c1eee1 55fb4c1 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 a4c3ce7 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 a2d45c5 7c1eee1 f8f1d3f 7c1eee1 6296cf9 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 6296cf9 7c1eee1 f8f1d3f a4c3ce7 f8f1d3f 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 6296cf9 7c1eee1 6296cf9 7c1eee1 f8f1d3f 6296cf9 f8f1d3f 7c1eee1 6296cf9 7c1eee1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
import json
from functools import partial
from .utils import *
from .vote_utils import (
upvote_last_response_t2s as upvote_last_response,
downvote_last_response_t2s as downvote_last_response,
flag_last_response_t2s as flag_last_response,
leftvote_last_response_t2s_anony as leftvote_last_response_anony,
rightvote_last_response_t2s_anony as rightvote_last_response_anony,
tievote_last_response_t2s_anony as tievote_last_response_anony,
bothbad_vote_last_response_t2s_anony as bothbad_vote_last_response_anony,
leftvote_last_response_t2s_named as leftvote_last_response_named,
rightvote_last_response_t2s_named as rightvote_last_response_named,
tievote_last_response_t2s_named as tievote_last_response_named,
bothbad_vote_last_response_t2s_named as bothbad_vote_last_response_named,
share_click_t2s_multi as share_click,
share_js
)
from .inference import(
sample_t2s_model as sample_model,
sample_prompt,
sample_prompt_side_by_side,
generate_t2s,
generate_t2s_multi,
generate_t2s_multi_annoy
)
def build_t2s_ui_side_by_side_anony(models):
notice_markdown = """
# βοΈ 3DGen-Arena βοΈ : Benchmarking Text-to-3D generative models
## π Rules
- Input prompt to two anonymous models in same area and vote for the better one!
- When the results are ready, click the button below to vote.
- Vote won't be counted if model identity is revealed during conversation.
- Click "Clear" to start a new round.
## π Arena Elo
Find out who is the π₯conditional image generation models! More models are going to be supported.
## π Generating now!
"""
model_list = models.get_t2s_models()
gen_func = partial(generate_t2s_multi_annoy, models.inference_parallel_anony, models.render_parallel)
state_0 = gr.State()
state_1 = gr.State()
gr.Markdown(notice_markdown, elem_id="notice_markdown")
model_str = gr.Markdown(str(model_list), visible=False, elem_id="model list string")
with gr.Group(elem_id="share-region-anony"):
with gr.Accordion("π Expand to see all Arena players", open=False):
model_description_md = get_model_description_md(model_list)
gr.Markdown(model_description_md, elem_id="model_description_markdown")
with gr.Row():
with gr.Column():
normal_left = gr.Image(width=512, label = "Normal A", show_download_button=True)
rgb_left = gr.Image(width=512, label = "RGB A", show_download_button=True)
with gr.Column():
normal_right = gr.Image(width=512, label = "Normal B", show_download_button=True,)
rgb_right = gr.Image(width=512, label = "RGB B", show_download_button=True,)
with gr.Row():
with gr.Column():
model_selector_left =gr.Markdown("", visible=False)
with gr.Column():
model_selector_right = gr.Markdown("", visible=False)
with gr.Row():
slow_warning = gr.Markdown("", elem_id="notice_markdown")
with gr.Row(elem_id="Geometry Plausibility"):
plausive_md = gr.Markdown("Geometry Plausibility: ", visible=False, elem_id="evaldim_markdown")
plausive_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
plausive_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
plausive_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
plausive_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Geometry Quality"):
geo_md = gr.Markdown("Geometry Quality: ", visible=False, elem_id="evaldim_markdown")
geo_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
geo_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
geo_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
geo_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Texture Quality"):
text_md = gr.Markdown("Texture Quality: ", visible=False, elem_id="evaldim_markdown")
text_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
text_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
text_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
text_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Geometry-Texture Coherency"):
coherence_md = gr.Markdown("Geometry-Texture Coherency: ", visible=False, elem_id="evaldim_markdown")
coherence_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
coherence_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
coherence_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
coherence_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Semantic Alignment"):
align_md = gr.Markdown("Semantic Alignment: ", visible=False, elem_id="evaldim_markdown")
align_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
align_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
align_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
align_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row():
textbox = gr.Textbox(
show_label=False,
placeholder="π Enter your prompt or Sample a random prompt, and press ENTER",
container=True,
elem_id="input_box",
interactive=False, ## only support offline
)
sample_btn = gr.Button(value="π² Sample", variant="primary", scale=0)
send_btn = gr.Button(value="π€ Send", variant="primary", scale=0)
with gr.Row():
clear_btn = gr.Button(value="ποΈ Clear", interactive=False)
regenerate_btn = gr.Button(value="π Regenerate", interactive=False)
share_btn = gr.Button(value="π· Share")
gr.Markdown(acknowledgment_md, elem_id="ack_markdown")
states = [state_0, state_1]
model_selectors = [model_selector_left, model_selector_right]
results = [normal_left, rgb_left, normal_right, rgb_right]
geo_btn_list = [geo_leftvote_btn, geo_rightvote_btn, geo_tie_btn, geo_bothbad_btn]
text_btn_list = [text_leftvote_btn, text_rightvote_btn, text_tie_btn, text_bothbad_btn]
align_btn_list = [align_leftvote_btn, align_rightvote_btn, align_tie_btn, align_bothbad_btn]
plausive_btn_list = [plausive_leftvote_btn, plausive_rightvote_btn, plausive_tie_btn, plausive_bothbad_btn]
coherence_btn_list = [coherence_leftvote_btn, coherence_rightvote_btn, coherence_tie_btn, coherence_bothbad_btn]
dim_md_list = [geo_md, text_md, align_md, plausive_md, coherence_md]
vote_btn_list = geo_btn_list + text_btn_list + align_btn_list + plausive_btn_list + coherence_btn_list
for dim_md, btn_list in zip(dim_md_list, [geo_btn_list, text_btn_list, align_btn_list, plausive_btn_list, coherence_btn_list]):
leftvote_btn, rightvote_btn, tie_btn, bothbad_btn = btn_list
leftvote_btn.click(
leftvote_last_response_anony,
states + model_selectors + [dim_md],
states + btn_list + model_selectors
)
rightvote_btn.click(
rightvote_last_response_anony,
states + model_selectors + [dim_md],
states + btn_list + model_selectors
)
tie_btn.click(
tievote_last_response_anony,
states + model_selectors + [dim_md],
states + btn_list + model_selectors
)
bothbad_btn.click(
bothbad_vote_last_response_anony,
states + model_selectors + [dim_md],
states + btn_list + model_selectors
)
sample_btn.click(
sample_prompt_side_by_side,
states + model_selectors,
states + [textbox],
api_name="sample_btn_anony"
)
textbox.submit(
reset_states_side_by_side_anony,
states,
states + model_selectors + vote_btn_list + [regenerate_btn, clear_btn, geo_md, text_md, align_md]
).then(
gen_func,
states + [textbox] + model_selectors,
states + results + model_selectors,
api_name="submit_btn_anony"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
send_btn.click(
reset_states_side_by_side_anony,
states,
states + model_selectors + vote_btn_list + [regenerate_btn, clear_btn, geo_md, text_md, align_md]
).then(
gen_func,
states + [textbox] + model_selectors,
states + results + model_selectors,
api_name="send_btn_anony"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
clear_btn.click(
clear_t2s_history_side_by_side_anony,
None,
states + [textbox] + results + model_selectors,
api_name="clear_btn_anony"
).then(
disable_mds,
None,
dim_md_list
).then(
disable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
regenerate_btn.click(
reset_states_side_by_side_anony,
states,
states + model_selectors + vote_btn_list + [regenerate_btn, clear_btn] + dim_md_list
).then(
gen_func,
states + [textbox] + model_selectors,
states + results + model_selectors,
api_name="regenerate_btn_anony"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
share_btn.click(
share_click,
states + model_selectors,
[],
js=share_js
)
def build_t2s_ui_side_by_side_named(models):
notice_markdown = """
# βοΈ 3DGen-Arena βοΈ : Benchmarking Text-to-3D generative models
## π Rules
- Generate with any two selected models side-by-side and vote!
- Sample or Input prompt you want to generate.
- Click "Send" to submit the prompt.
- Click "Clear" to start a new round.
## π Arena Elo
Find out who is the π₯conditional image generation models! More models are going to be supported.
## π Generating now!
"""
model_list = models.get_t2s_models()
gen_func = partial(generate_t2s_multi, models.inference_parallel, models.render_parallel)
state_0 = gr.State()
state_1 = gr.State()
gr.Markdown(notice_markdown, elem_id="notice_markdown")
with gr.Group(elem_id="share-region-named"):
with gr.Accordion("π Expand to see all Arena players", open=False):
model_description_md = get_model_description_md(model_list)
gr.Markdown(model_description_md, elem_id="model_description_markdown")
with gr.Row():
with gr.Column():
model_selector_left = gr.Dropdown(
choices=model_list,
value=model_list[0] if len(model_list) > 0 else "",
interactive=True,
show_label=False,
container=False,
)
with gr.Column():
model_selector_right = gr.Dropdown(
choices=model_list,
value=model_list[1] if len(model_list) > 1 else "",
interactive=True,
show_label=False,
container=False,
)
with gr.Row():
with gr.Column():
normal_left = gr.Image(width=512, label = "Normal A", show_download_button=True)
rgb_left = gr.Image(width=512, label = "RGB A", show_download_button=True)
with gr.Column():
normal_right = gr.Image(width=512, label = "Normal B", show_download_button=True,)
rgb_right = gr.Image(width=512, label = "RGB B", show_download_button=True,)
with gr.Row():
slow_warning = gr.Markdown("", elem_id="notice_markdown")
with gr.Row(elem_id="Geometry Plausibility"):
plausive_md = gr.Markdown("Geometry Plausibility: ", visible=False, elem_id="evaldim_markdown")
plausive_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
plausive_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
plausive_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
plausive_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Geometry Quality"):
geo_md = gr.Markdown("Geometry Quality: ", visible=False, elem_id="evaldim_markdown")
geo_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
geo_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
geo_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
geo_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Texture Quality"):
text_md = gr.Markdown("Texture Quality: ", visible=False, elem_id="evaldim_markdown")
text_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
text_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
text_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
text_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Geometry-Texture Coherency"):
coherence_md = gr.Markdown("Geometry-Texture Coherency: ", visible=False, elem_id="evaldim_markdown")
coherence_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
coherence_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
coherence_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
coherence_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row(elem_id="Semantic Alignment"):
align_md = gr.Markdown("Semantic Alignment: ", visible=False, elem_id="evaldim_markdown")
align_leftvote_btn = gr.Button(
value="π A is better", visible=False, interactive=False
)
align_rightvote_btn = gr.Button(
value="π B is better", visible=False, interactive=False
)
align_tie_btn = gr.Button(value="π€ Tie", visible=False, interactive=False)
align_bothbad_btn = gr.Button(
value="π Both are bad", visible=False, interactive=False
)
with gr.Row():
textbox = gr.Textbox(
show_label=False,
placeholder="π Enter your prompt or Sample a random prompt, and press ENTER",
container=True,
elem_id="input_box",
interactive=False, ## only support offline
)
sample_btn = gr.Button(value="π² Sample", variant="primary", scale=0)
send_btn = gr.Button(value="π€ Send", variant="primary", scale=0)
with gr.Row():
clear_btn = gr.Button(value="ποΈ Clear", interactive=False)
regenerate_btn = gr.Button(value="π Regenerate", interactive=False)
share_btn = gr.Button(value="π· Share")
gr.Markdown(acknowledgment_md, elem_id="ack_markdown")
states = [state_0, state_1]
model_selectors = [model_selector_left, model_selector_right]
results = [normal_left, rgb_left, normal_right, rgb_right]
geo_btn_list = [geo_leftvote_btn, geo_rightvote_btn, geo_tie_btn, geo_bothbad_btn]
text_btn_list = [text_leftvote_btn, text_rightvote_btn, text_tie_btn, text_bothbad_btn]
align_btn_list = [align_leftvote_btn, align_rightvote_btn, align_tie_btn, align_bothbad_btn]
plausive_btn_list = [plausive_leftvote_btn, plausive_rightvote_btn, plausive_tie_btn, plausive_bothbad_btn]
coherence_btn_list = [coherence_leftvote_btn, coherence_rightvote_btn, coherence_tie_btn, coherence_bothbad_btn]
dim_md_list = [geo_md, text_md, align_md, plausive_md, coherence_md]
vote_btn_list = geo_btn_list + text_btn_list + align_btn_list + plausive_btn_list + coherence_btn_list
model_selector_left.change(
clear_t2s_history_side_by_side,
None,
states + [textbox] + results,
api_name="model_selector_left"
)
model_selector_right.change(
clear_t2s_history_side_by_side,
None,
states + [textbox] + results,
api_name="model_selector_right"
)
for dim_md, btn_list in zip(dim_md_list, [geo_btn_list, text_btn_list, align_btn_list, plausive_btn_list, coherence_btn_list]):
leftvote_btn, rightvote_btn, tie_btn, bothbad_btn = btn_list
leftvote_btn.click(
leftvote_last_response_named,
states + model_selectors + [dim_md],
states + btn_list
)
rightvote_btn.click(
rightvote_last_response_named,
states + model_selectors + [dim_md],
states + btn_list
)
tie_btn.click(
tievote_last_response_named,
states + model_selectors + [dim_md],
states + btn_list
)
bothbad_btn.click(
bothbad_vote_last_response_named,
states + model_selectors + [dim_md],
states + btn_list
)
sample_btn.click(
sample_prompt_side_by_side,
states + model_selectors,
states + [textbox],
api_name="sample_btn_named"
)
textbox.submit(
reset_states_side_by_side,
states,
states + vote_btn_list + [regenerate_btn, clear_btn, geo_md, text_md, align_md]
).then(
gen_func,
states + [textbox] + model_selectors,
states + results,
api_name="submit_btn_named"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
send_btn.click(
reset_states_side_by_side,
states,
states + vote_btn_list + [regenerate_btn, clear_btn] + dim_md_list
).then(
gen_func,
states + [textbox] + model_selectors,
states + results,
api_name="send_btn_named"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
clear_btn.click(
clear_t2s_history_side_by_side,
None,
states + [textbox] + results,
api_name="clear_btn_named"
).then(
disable_mds,
None,
dim_md_list
).then(
disable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
regenerate_btn.click(
reset_states_side_by_side,
states,
states + vote_btn_list + [regenerate_btn, clear_btn, geo_md, text_md, align_md]
).then(
gen_func,
states + [textbox] + model_selectors,
states + results,
api_name="regenerate_btn_named"
).then(
enable_mds,
None,
dim_md_list
).then(
enable_buttons_side_by_side,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
share_btn.click(
share_click,
states + model_selectors,
[],
js=share_js
)
def build_t2s_ui_single_model(models):
notice_markdown = """
# ποΈ Play with Text-to-3D Generation Models
## π€ Choose any model to generate
"""
model_list = models.get_t2s_models()
gen_func = partial(generate_t2s, models.inference, models.render)
gr.Markdown(notice_markdown, elem_id="notice_markdown")
with gr.Row():
with gr.Accordion("π Expand to see all Arena players", open=False):
model_description_md = get_model_description_md(model_list)
gr.Markdown(model_description_md, elem_id="model_description_markdown")
with gr.Row(elem_id="model_selector_row"):
model_selector = gr.Dropdown(
choices=model_list,
value=model_list[0] if len(model_list) > 0 else "",
interactive=True,
show_label=False
)
with gr.Row():
normal = gr.Image(width=512, label = "Normal", show_download_button=True)
rgb = gr.Image(width=512, label = "RGB", show_download_button=True,)
with gr.Row(elem_id="Geometry Plausibility"):
plausive_md = gr.Markdown("Geometry Plausibility: ", elem_id="evaldim_markdown")
plausive_upvote_btn = gr.Button(value="π Upvote", interactive=False)
plausive_downvote_btn = gr.Button(value="π Downvote", interactive=False)
plausive_flag_btn = gr.Button(value="β οΈ Flag", interactive=False)
with gr.Row(elem_id="Geometry Quality"):
geo_md = gr.Markdown("Geometry Quality: ", elem_id="evaldim_markdown")
geo_upvote_btn = gr.Button(value="π Upvote", interactive=False)
geo_downvote_btn = gr.Button(value="π Downvote", interactive=False)
geo_flag_btn = gr.Button(value="β οΈ Flag", interactive=False)
with gr.Row(elem_id="Texture Quality"):
text_md = gr.Markdown("Texture Quality: ", elem_id="evaldim_markdown")
text_upvote_btn = gr.Button(value="π Upvote", interactive=False)
text_downvote_btn = gr.Button(value="π Downvote", interactive=False)
text_flag_btn = gr.Button(value="β οΈ Flag", interactive=False)
with gr.Row(elem_id="Geometry-Texture Coherency"):
coherence_md = gr.Markdown("Geometry-Texture Coherency: ", elem_id="evaldim_markdown")
coherence_upvote_btn = gr.Button(value="π Upvote", interactive=False)
coherence_downvote_btn = gr.Button(value="π Downvote", interactive=False)
coherence_flag_btn = gr.Button(value="β οΈ Flag", interactive=False)
with gr.Row(elem_id="Semantic Alignment"):
align_md = gr.Markdown("Semantic Alignment: ", elem_id="evaldim_markdown")
align_upvote_btn = gr.Button(value="π Upvote", interactive=False)
align_downvote_btn = gr.Button(value="π Downvote", interactive=False)
align_flag_btn = gr.Button(value="β οΈ Flag", interactive=False)
with gr.Row():
textbox = gr.Textbox(
show_label=False,
placeholder="π Enter your prompt or Sample a random prompt, and press ENTER",
container=True,
elem_id="input_box",
interactive=False, ## only support offline
)
sample_btn = gr.Button(value="π² Sample", variant="primary", scale=0)
send_btn = gr.Button(value="π€ Send", variant="primary", scale=0)
with gr.Row():
clear_btn = gr.Button(value="ποΈ Clear", interactive=False)
regenerate_btn = gr.Button(value="π Regenerate", interactive=False)
gr.Markdown(acknowledgment_md, elem_id="ack_markdown")
state = gr.State()
geo_btn_list = [geo_upvote_btn, geo_downvote_btn, geo_flag_btn]
text_btn_list = [text_upvote_btn, text_downvote_btn, text_flag_btn]
align_btn_list = [align_upvote_btn, align_downvote_btn, align_flag_btn]
plausive_btn_list = [plausive_upvote_btn, plausive_downvote_btn, plausive_flag_btn]
coherence_btn_list = [coherence_upvote_btn, coherence_downvote_btn, coherence_flag_btn]
dim_md_list = [geo_md, text_md, align_md, plausive_md, coherence_md]
vote_btn_list = geo_btn_list + text_btn_list + align_btn_list + plausive_btn_list + coherence_btn_list
for dim_md, btn_list in zip(dim_md_list, [geo_btn_list, text_btn_list, align_btn_list, plausive_btn_list, coherence_btn_list]):
upvote_btn, downvote_btn, flag_btn = btn_list
upvote_btn.click(
upvote_last_response,
[state, model_selector, dim_md],
[state] + btn_list
)
downvote_btn.click(
downvote_last_response,
[state, model_selector, dim_md],
[state] + btn_list
)
flag_btn.click(
flag_last_response,
[state, model_selector, dim_md],
[state] + btn_list
)
sample_btn.click(
sample_prompt,
[state, model_selector],
[state, textbox],
api_name="sample_btn_single"
)
textbox.submit(
reset_state,
state,
[state] + vote_btn_list + [regenerate_btn, clear_btn]
).then(
gen_func,
[state, textbox, model_selector],
[state, normal, rgb],
api_name="submit_btn_single",
show_progress = "full"
).then(
enable_buttons,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
send_btn.click(
reset_state,
state,
[state] + vote_btn_list + [regenerate_btn, clear_btn]
).then(
gen_func,
[state, textbox, model_selector],
[state, normal, rgb],
api_name="send_btn_single",
show_progress = "full"
).then(
enable_buttons,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
clear_btn.click(
clear_t2s_history,
None,
[state, textbox, normal, rgb],
api_name="clear_history_single",
show_progress="full"
).then(
disable_buttons,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
regenerate_btn.click(
reset_state,
state,
[state] + vote_btn_list + [regenerate_btn, clear_btn]
).then(
gen_func,
[state, textbox, model_selector],
[state, normal, rgb],
api_name="regenerate_btn_single",
show_progress = "full"
).then(
enable_buttons,
None,
vote_btn_list + [regenerate_btn, clear_btn]
)
|