from .utils import * from .vote_utils import ( upvote_last_response_ig as upvote_last_response, downvote_last_response_ig as downvote_last_response, flag_last_response_ig as flag_last_response, leftvote_last_response_igm as leftvote_last_response, left1vote_last_response_igm as left1vote_last_response, rightvote_last_response_igm as rightvote_last_response, right1vote_last_response_igm as right1vote_last_response, tievote_last_response_igm as tievote_last_response, bothbad_vote_last_response_igm as bothbad_vote_last_response, share_click_igm as share_click, generate_vg_annoy, share_js ) from .Ksort import ( add_foreground, reset_level, reset_rank, revote_windows, submit_response_vg, submit_response_rank_vg, reset_submit, clear_rank, reset_mode, reset_chatbot, reset_btn_rank, reset_vote_text, text_response_rank_vg, check_textbox, ) from functools import partial from serve.constants import SSH_SERVER, SSH_PORT, SSH_USER, SSH_PASSWORD from serve.upload import create_ssh_client from serve.update_skill import create_ssh_skill_client from model.matchmaker import create_ssh_matchmaker_client def build_side_by_side_video_ui_anony(models): notice_markdown = """ # โš”๏ธ K-Sort Arena (Text-to-Video Generation) โš”๏ธ ## ๐Ÿ“œ Rules - Input a prompt for four anonymized models (e.g., Sora, Pika, OpenSora, StableVideoDiffusion for Text-guided Video Generation) and vote on their outputs. - Two voting modes available: Rank Mode and Best Mode. Switch freely between modes. Please note that ties are always allowed. In ranking mode, users can input rankings like 1 3 3 1. Any invalid rankings, such as 1 4 4 1, will be automatically corrected during post-processing. - Users are encouraged to make evaluations based on subjective preferences. Evaluation criteria: Alignment (50%) + Aesthetics (50%). - Alignment includes: Video Content Matching (20%) + Movement Matching (15%) + Inter-frame Consistency (15%); - Aesthetics includes: Photorealism (30%) + Physical Correctness (10%) + Absence of Artifacts (10%). - Users can hover over the videos to see a replay button and click to zoom out to full-screen. ## ๐Ÿ‘‡ Generating now! """ model_list = models.model_vg_list state0 = gr.State() state1 = gr.State() state2 = gr.State() state3 = gr.State() gen_func = partial(generate_vg_annoy, models.generate_video_vg_parallel_anony) # gen_func_random = partial(generate_igm_annoy_museum, models.generate_image_ig_museum_parallel_anony) gr.Markdown(notice_markdown, elem_id="notice_markdown") with gr.Group(elem_id="share-region-anony"): with gr.Accordion("๐Ÿ” Expand to see all Arena players", open=False): model_description_md = get_video_model_description_md(model_list) gr.Markdown(model_description_md, elem_id="model_description_markdown") with gr.Row(): with gr.Column(): chatbot_left = gr.Video(width=512, label = "Model A", autoplay=True) with gr.Column(): chatbot_left1 = gr.Video(width=512, label = "Model B", autoplay=True) with gr.Column(): chatbot_right = gr.Video(width=512, label = "Model C", autoplay=True) with gr.Column(): chatbot_right1 = gr.Video(width=512, label = "Model D", autoplay=True) with gr.Row(): with gr.Column(): model_selector_left = gr.Markdown("", visible=False) with gr.Column(): model_selector_left1 = gr.Markdown("", visible=False) with gr.Column(): model_selector_right = gr.Markdown("", visible=False) with gr.Column(): model_selector_right1 = gr.Markdown("", visible=False) with gr.Row(): slow_warning = gr.Markdown("", elem_id="notice_markdown") with gr.Row(elem_classes="row"): with gr.Column(scale=1, min_width=10): leftvote_btn = gr.Button( value="A is Best", visible=False, interactive=False, elem_id="btncolor1", elem_classes="best-button" ) with gr.Column(scale=1, min_width=10): left1vote_btn = gr.Button( value="B is Best", visible=False, interactive=False, elem_id="btncolor1", elem_classes="best-button" ) with gr.Column(scale=1, min_width=10): rightvote_btn = gr.Button( value="C is Best", visible=False, interactive=False, elem_id="btncolor1", elem_classes="best-button" ) with gr.Column(scale=1, min_width=10): right1vote_btn = gr.Button( value="D is Best", visible=False, interactive=False, elem_id="btncolor1", elem_classes="best-button" ) with gr.Column(scale=1, min_width=10): tie_btn = gr.Button( value="๐Ÿค Tie", visible=False, interactive=False, elem_id="btncolor2", elem_classes="best-button" ) with gr.Row(): with gr.Blocks(): with gr.Row(): with gr.Column(scale=1, min_width=10): A1_btn = gr.Button( value="1", visible=False, interactive=False, elem_id="btncolor1", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): A2_btn = gr.Button( value="2", visible=False, interactive=False, elem_id="btncolor2", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): A3_btn = gr.Button( value="3", visible=False, interactive=False, elem_id="btncolor3", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): A4_btn = gr.Button( value="4", visible=False, interactive=False, elem_id="btncolor4", elem_classes="custom-button" ) with gr.Blocks(): with gr.Row(): with gr.Column(scale=1, min_width=10): B1_btn = gr.Button( value="1", visible=False, interactive=False, elem_id="btncolor1", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): B2_btn = gr.Button( value="2", visible=False, interactive=False, elem_id="btncolor2", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): B3_btn = gr.Button( value="3", visible=False, interactive=False, elem_id="btncolor3", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): B4_btn = gr.Button( value="4", visible=False, interactive=False, elem_id="btncolor4", elem_classes="custom-button" ) with gr.Blocks(): with gr.Row(): with gr.Column(scale=1, min_width=10): C1_btn = gr.Button( value="1", visible=False, interactive=False, elem_id="btncolor1", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): C2_btn = gr.Button( value="2", visible=False, interactive=False, elem_id="btncolor2", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): C3_btn = gr.Button( value="3", visible=False, interactive=False, elem_id="btncolor3", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): C4_btn = gr.Button( value="4", visible=False, interactive=False, elem_id="btncolor4", elem_classes="custom-button" ) with gr.Blocks(): with gr.Row(): with gr.Column(scale=1, min_width=10): D1_btn = gr.Button( value="1", visible=False, interactive=False, elem_id="btncolor1", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): D2_btn = gr.Button( value="2", visible=False, interactive=False, elem_id="btncolor2", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): D3_btn = gr.Button( value="3", visible=False, interactive=False, elem_id="btncolor3", elem_classes="custom-button" ) with gr.Column(scale=1, min_width=10): D4_btn = gr.Button( value="4", visible=False, interactive=False, elem_id="btncolor4", elem_classes="custom-button" ) with gr.Row(): vote_textbox = gr.Textbox( show_label=False, placeholder="๐Ÿ‘‰ Enter your rank (you can use buttons above, or directly type here, e.g. 1 2 3 4)", container=True, elem_id="input_box", visible=False, ) vote_submit_btn = gr.Button(value="Submit", visible=False, interactive=False, variant="primary", scale=0, elem_id="btnpink", elem_classes="submit-button") vote_mode_btn = gr.Button(value="๐Ÿ”„ Mode", visible=False, interactive=False, variant="primary", scale=0, elem_id="btnpink", elem_classes="submit-button") with gr.Row(): textbox = gr.Textbox( show_label=False, placeholder="๐Ÿ‘‰ Generate a random prompt and send to video generation", container=True, elem_id="input_box", interactive=False, ) send_btn = gr.Button(value="Send", variant="primary", scale=0, elem_id="btnblue", visible=False, interactive=False) draw_btn = gr.Button(value="๐ŸŽฒ Random Sample", variant="primary", scale=0, elem_id="btnblue") with gr.Row(): clear_btn = gr.Button(value="๐ŸŽฒ New Round", interactive=False) with gr.Blocks(): with gr.Row(elem_id="centered-text"): # user_info = gr.Markdown("User information (to appear on the contributor leaderboard)", visible=True, elem_id="centered-text") #, elem_id="centered-text" # with gr.Blocks(): # name = gr.Markdown("Name", visible=True) user_name = gr.Textbox(show_label=False,placeholder="๐Ÿ‘‰ Enter your name (optional)", elem_classes="custom-width") # with gr.Blocks(): # institution = gr.Markdown("Institution", visible=True) user_institution = gr.Textbox(show_label=False,placeholder="๐Ÿ‘‰ Enter your affiliation (optional)", elem_classes="custom-width") prompt_path = gr.Textbox(value="", visible=False, interactive=False) #gr.Markdown(acknowledgment_md, elem_id="ack_markdown") example1_text = gr.Textbox(value="Chef with recipe book watching young cook preparing dish in the kitchen.", visible=False, interactive=False) example2_text = gr.Textbox(value="A baker turns freshly baked loaves of sourdough bread.", visible=False, interactive=False) example3_text = gr.Textbox(value="Dense fog glows orange and covers hills at dawn.", visible=False, interactive=False) example4_text = gr.Textbox(value="Happy extended family on the sofa at home.", visible=False, interactive=False) # dummy_video_output = gr.Video(width=512, visible=False) # gr.Examples( # examples=[["Chef with recipe book watching young cook preparing dish in the kitchen.", os.path.join("./examples", "video_example1.mp4")], # ["A baker turns freshly baked loaves of sourdough bread.", os.path.join("./examples", "video_example2.mp4")], # ["Dense fog glows orange and covers hills at dawn.",os.path.join("./examples", "video_example3.mp4")], # ["Happy extended family on the sofa at home.", os.path.join("./examples", "video_example4.mp4")]], # inputs = [textbox, dummy_video_output]) order_btn_list = [textbox, send_btn, draw_btn, clear_btn] vote_order_list = [leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn, \ vote_textbox, vote_submit_btn, vote_mode_btn] generate_ig0 = gr.Video(width=512, label = "generate A", visible=False, interactive=False) generate_ig1 = gr.Video(width=512, label = "generate B", visible=False, interactive=False) generate_ig2 = gr.Video(width=512, label = "generate C", visible=False, interactive=False) generate_ig3 = gr.Video(width=512, label = "generate D", visible=False, interactive=False) dummy_left_model = gr.State("") dummy_left1_model = gr.State("") dummy_right_model = gr.State("") dummy_right1_model = gr.State("") ig_rank = [None, None, None, None] bastA_rank = [0, 3, 3, 3] bastB_rank = [3, 0, 3, 3] bastC_rank = [3, 3, 0, 3] bastD_rank = [3, 3, 3, 0] tie_rank = [0, 0, 0, 0] rank = gr.State(ig_rank) rankA = gr.State(bastA_rank) rankB = gr.State(bastB_rank) rankC = gr.State(bastC_rank) rankD = gr.State(bastD_rank) rankTie = gr.State(tie_rank) Top1_text = gr.Textbox(value="Top 1", visible=False, interactive=False) Top2_text = gr.Textbox(value="Top 2", visible=False, interactive=False) Top3_text = gr.Textbox(value="Top 3", visible=False, interactive=False) Top4_text = gr.Textbox(value="Top 4", visible=False, interactive=False) window1_text = gr.Textbox(value="Model A", visible=False, interactive=False) window2_text = gr.Textbox(value="Model B", visible=False, interactive=False) window3_text = gr.Textbox(value="Model C", visible=False, interactive=False) window4_text = gr.Textbox(value="Model D", visible=False, interactive=False) vote_level = gr.Number(value=0, visible=False, interactive=False) # record the level of now object vote_mode = gr.Textbox(value="Rank", visible=False, interactive=False) right_vote_text = gr.Textbox(value="wrong", visible=False, interactive=False) # send_btn.click( # disable_video_order_buttons, # inputs=[textbox, example1_text, example2_text, example3_text, example4_text], # outputs=[textbox, send_btn, draw_btn, clear_btn, prompt_path] # ).then( # gen_func, # ไฟฎๆ”นไธบ่ฐƒๅ–ๅ‡ฝๆ•ฐ่€Œไธๆ˜ฏ็”Ÿๆˆๅ‡ฝๆ•ฐ # inputs=[state0, state1, state2, state3, textbox, prompt_path, model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], # outputs=[state0, state1, state2, state3, generate_ig0, generate_ig1, generate_ig2, generate_ig3, chatbot_left, chatbot_left1, chatbot_right, chatbot_right1, \ # model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], # api_name="send_btn_annony" # ).then( # enable_vote_mode_buttons, # inputs=[vote_mode, textbox], # outputs=vote_order_list # ) draw_btn.click( disable_video_order_buttons, inputs=[], outputs=[textbox, send_btn, draw_btn, clear_btn] ).then( gen_func, inputs=[state0, state1, state2, state3, model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], outputs=[state0, state1, state2, state3, generate_ig0, generate_ig1, generate_ig2, generate_ig3, chatbot_left, chatbot_left1, chatbot_right, chatbot_right1, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, textbox, prompt_path], api_name="send_btn_annony" ).then( enable_vote_mode_buttons, inputs=[vote_mode, textbox], outputs=vote_order_list ) clear_btn.click( clear_history_side_by_side_anony, inputs=None, outputs=[state0, state1, state2, state3, textbox, vote_textbox, chatbot_left, chatbot_left1, chatbot_right, chatbot_right1, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], api_name="clear_btn_annony" ).then( enable_video_order_buttons, inputs=None, outputs=order_btn_list ).then( clear_rank, inputs=[rank, vote_level], outputs=[rank, vote_level] ).then( disable_vote_mode_buttons, inputs=None, outputs=vote_order_list ) vote_mode_btn.click( reset_chatbot, inputs=[vote_mode, generate_ig0, generate_ig1, generate_ig2, generate_ig3], outputs=[chatbot_left, chatbot_left1, chatbot_right, chatbot_right1] ).then( reset_mode, inputs=[vote_mode], outputs=[leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn, \ vote_textbox, vote_submit_btn, vote_mode_btn, vote_mode] ) vote_textbox.submit( disable_vote, inputs=None, outputs=[vote_submit_btn, vote_mode_btn, \ A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn] ).then( text_response_rank_vg, inputs=[vote_textbox], outputs=[vote_textbox, right_vote_text, rank] ).then( submit_response_rank_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rank, right_vote_text, user_name, user_institution], outputs=[A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn, \ vote_textbox, vote_submit_btn, vote_mode_btn, right_vote_text, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], api_name="submit_btn_annony" ) vote_submit_btn.click( disable_vote, inputs=None, outputs=[vote_submit_btn, vote_mode_btn, \ A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn] ).then( text_response_rank_vg, inputs=[vote_textbox], outputs=[vote_textbox, right_vote_text, rank] ).then( submit_response_rank_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rank, right_vote_text, user_name, user_institution], outputs=[A1_btn, A2_btn, A3_btn, A4_btn, B1_btn, B2_btn, B3_btn, B4_btn, C1_btn, C2_btn, C3_btn, C4_btn, D1_btn, D2_btn, D3_btn, D4_btn, \ vote_textbox, vote_submit_btn, vote_mode_btn, right_vote_text, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1], api_name="submit_btn_annony" ) leftvote_btn.click( submit_response_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rankA, user_name, user_institution], outputs=[textbox, leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, \ vote_mode_btn] ) left1vote_btn.click( submit_response_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rankB, user_name, user_institution], outputs=[textbox, leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, \ vote_mode_btn] ) rightvote_btn.click( submit_response_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rankC, user_name, user_institution], outputs=[textbox, leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, \ vote_mode_btn] ) right1vote_btn.click( submit_response_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rankD, user_name, user_institution], outputs=[textbox, leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, \ vote_mode_btn] ) tie_btn.click( submit_response_vg, inputs=[state0, state1, state2, state3, dummy_left_model, dummy_left1_model, dummy_right_model, dummy_right1_model, textbox, prompt_path, rankTie, user_name, user_institution], outputs=[textbox, leftvote_btn, left1vote_btn, rightvote_btn, right1vote_btn, tie_btn, \ model_selector_left, model_selector_left1, model_selector_right, model_selector_right1, \ vote_mode_btn] ) A1_btn.click( reset_btn_rank, inputs=[window1_text, rank, A1_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) A2_btn.click( reset_btn_rank, inputs=[window1_text, rank, A2_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) A3_btn.click( reset_btn_rank, inputs=[window1_text, rank, A3_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) A4_btn.click( reset_btn_rank, inputs=[window1_text, rank, A4_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) B1_btn.click( reset_btn_rank, inputs=[window2_text, rank, B1_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) B2_btn.click( reset_btn_rank, inputs=[window2_text, rank, B2_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) B3_btn.click( reset_btn_rank, inputs=[window2_text, rank, B3_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) B4_btn.click( reset_btn_rank, inputs=[window2_text, rank, B4_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) C1_btn.click( reset_btn_rank, inputs=[window3_text, rank, C1_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) C2_btn.click( reset_btn_rank, inputs=[window3_text, rank, C2_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) C3_btn.click( reset_btn_rank, inputs=[window3_text, rank, C3_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) C4_btn.click( reset_btn_rank, inputs=[window3_text, rank, C4_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) D1_btn.click( reset_btn_rank, inputs=[window4_text, rank, D1_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) D2_btn.click( reset_btn_rank, inputs=[window4_text, rank, D2_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) D3_btn.click( reset_btn_rank, inputs=[window4_text, rank, D3_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] ) D4_btn.click( reset_btn_rank, inputs=[window4_text, rank, D4_btn, vote_level], outputs=[rank, vote_level] ).then( reset_submit, inputs = [rank], outputs = [vote_submit_btn] ).then( reset_vote_text, inputs = [rank], outputs = [vote_textbox] )