File size: 11,270 Bytes
7cbbfe6 55a84fb 96c5fd7 55a84fb 96c5fd7 7cbbfe6 96c5fd7 55a84fb 7cbbfe6 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 7cbbfe6 55a84fb 7cbbfe6 55a84fb 7cbbfe6 55a84fb e585775 55a84fb e585775 55a84fb e585775 55a84fb e585775 55a84fb e585775 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 55a84fb 96c5fd7 e24a92e 55a84fb e24a92e 55a84fb 7cbbfe6 |
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 |
__all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']
import os
import io
import gradio as gr
import pandas as pd
import json
import shutil
import tempfile
import datetime
import zipfile
import numpy as np
from constants import *
from huggingface_hub import Repository
HF_TOKEN = os.environ.get("HF_TOKEN")
global data_component, filter_component
def upload_file(files):
file_paths = [file.name for file in files]
return file_paths
def add_new_eval(
input_file,
model_type,
model_name_textbox,
model_ability,
revision_name_textbox,
access_type,
model_link,
team_name,
contact_email,
release_time,
model_resolution,
model_length,
model_fps,
model_frame,
model_link_optional,
):
if input_file is None:
return "Error! Empty file!"
if model_link == '' or model_name_textbox == '' or contact_email == '':
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
submission_repo.git_pull()
filename = f"{model_name_textbox}_{model_type}_{model_ability}_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}"
now = datetime.datetime.now()
update_time = now.strftime("%Y.%m.%d") # Capture update time
csv_data = pd.read_csv(CSV_DIR)
if revision_name_textbox == '':
col = csv_data.shape[0]
model_name = model_name_textbox.replace(',',' ')
else:
model_name = revision_name_textbox.replace(',',' ')
model_name_list = csv_data['Model Name']
name_list = [name.split(']')[0][1:] for name in model_name_list]
if revision_name_textbox not in name_list:
col = csv_data.shape[0]
else:
col = name_list.index(revision_name_textbox)
if csv_data[col]['Sampled by'] == "WorldScore" or csv_data[col]['Evaluated by'] == "WorldScore":
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
if model_link == '':
model_name = model_name # no url
else:
model_name = '[' + model_name + '](' + model_link + ')'
if model_link_optional == '':
model_link_optional = model_link
try:
with open(input_file, 'r') as f:
upload_data = json.load(f)
# add new data
print('upload_data:', upload_data)
new_data = [model_type, model_name, model_ability]
if team_name == '':
new_data.append(model_name)
new_data.append(model_name)
else:
new_data.append(team_name)
new_data.append(team_name)
new_data.append(access_type)
new_data.append(update_time)
for key in TASK_INFO:
value = COLNAME2KEY[key]
if value in upload_data:
new_data.append(upload_data[value])
else:
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
csv_data.loc[col] = new_data
csv_data = csv_data.to_csv(CSV_DIR, index=False)
with open(INFO_DIR,'a') as f:
f.write(f"{model_type.replace(',', ' ')}\t{model_name.replace(',', ' ')}\t{model_ability.replace(',', ' ')}\t{model_resolution.replace(',', ' ')}\t{model_length.replace(',', ' ')}\t{model_fps.replace(',', ' ')}\t{model_frame.replace(',', ' ')}\t{model_link_optional.replace(',', ' ')}\t{contact_email.replace(',', ' ')}\n")
submission_repo.push_to_hub()
print("success update", model_name)
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
except:
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
def get_baseline_df():
submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
submission_repo.git_pull()
df = pd.read_csv(CSV_DIR)
df = df.sort_values(by=DEFAULT_INFO[0], ascending=False)
return df
block = gr.Blocks(css="""
.container {
max-width: 80%;
margin: auto;
}
""")
with block:
with gr.Column(elem_classes="container"):
gr.Markdown(
LEADERBORAD_INTRODUCTION
)
with gr.Tabs(elem_classes="tab-buttons") as tabs:
# Table 0
with gr.TabItem("π
WorldScore Benchmark", elem_id="worldscore-tab-table", id=0):
with gr.Column():
model_type_filter = gr.CheckboxGroup(
choices=MODEL_TYPE,
value=DEFAULT_MODEL_TYPE,
label="Model Type",
interactive=True
)
ability_filter = gr.CheckboxGroup(
choices=ABILITY,
value=DEFAULT_ABILITY,
label="Ability",
interactive=True
)
data_component = gr.components.Dataframe(
value=get_baseline_df(),
headers=COLUMN_NAMES,
type="pandas",
datatype=DATA_TITILE_TYPE,
interactive=False,
visible=True,
)
def on_filter_change(model_types, abilities):
df = get_baseline_df()
# Filter by selected model types
df = df[df['Model Type'].isin(model_types)]
# Filter by selected abilities
df = df[df['Ability'].isin(abilities)]
return gr.Dataframe(
value=df,
headers=COLUMN_NAMES,
type="pandas",
datatype=DATA_TITILE_TYPE,
interactive=False,
visible=True
)
model_type_filter.change(
fn=on_filter_change,
inputs=[model_type_filter, ability_filter],
outputs=data_component
)
ability_filter.change(
fn=on_filter_change,
inputs=[model_type_filter, ability_filter],
outputs=data_component
)
with gr.TabItem("π Submit here! ", elem_id="submit-tab-table", id=1):
with gr.Row():
gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")
with gr.Row():
gr.Markdown("# Submit your evaluation json file here!", elem_classes="markdown-text")
with gr.Row():
gr.Markdown("Here is a required field", elem_classes="markdown-text")
with gr.Row():
with gr.Column():
model_type = gr.Dropdown(["Video", "3D", "4D"], label="Model Type")
model_name_textbox = gr.Textbox(
label="Model name", placeholder="Your model name"
)
model_ability = gr.Dropdown(["I2V", "T2V"], label="Model Ability")
revision_name_textbox = gr.Textbox(
label="Revision Model Name (Optional)", placeholder="If you need to update the previous submissions, please fill in this line"
)
with gr.Column():
access_type = gr.Dropdown(["Open Source", "Ready to Open Source", "API", "Close"], label="Access")
model_link = gr.Textbox(
label="Link (Website/Paper Link/Github/HuggingFace)", placeholder="If filling in the wrong information, your results may be removed."
)
team_name = gr.Textbox(
label="Your Team Name", placeholder="If left blank, it will be your model name"
)
contact_email = gr.Textbox(
label="E-Mail (Will not be displayed)", placeholder="Contact email"
)
with gr.Row():
gr.Markdown("The following is optional and will be synced to [GitHub] (https://github.com/Vchitect/VBench/tree/master/sampled_videos#what-are-the-details-of-the-video-generation-models)", elem_classes="markdown-text")
with gr.Row():
release_time = gr.Textbox(label="Version", placeholder="2025.03.29")
model_resolution = gr.Textbox(label="Resolution", placeholder="WidthxHeight")
model_length = gr.Textbox(label="Video Length (s)", placeholder="float")
model_fps = gr.Textbox(label="FPS", placeholder="int")
model_frame = gr.Textbox(label="Frame Number", placeholder="int")
model_link_optional = gr.Textbox(label="Link", placeholder='optional')
with gr.Column():
input_file = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
submit_button = gr.Button("Submit Eval")
submit_succ_button = gr.Markdown("Submit Success! Please press refresh and return to WorldScore Benchmark!", visible=False)
fail_textbox = gr.Markdown('<span style="color:red;">Please ensure that the `Model Name`, `Project Page`, and `E-mail` are filled in correctly and the uploaded json file is valid.</span>', elem_classes="markdown-text",visible=False)
submission_result = gr.Markdown()
submit_button.click(
add_new_eval,
inputs = [
input_file,
model_type,
model_name_textbox,
model_ability,
revision_name_textbox,
access_type,
model_link,
team_name,
contact_email,
release_time,
model_resolution,
model_length,
model_fps,
model_frame,
model_link_optional,
],
outputs=[submit_button, submit_succ_button, fail_textbox]
)
def refresh_data():
value = get_baseline_df()
return value, DEFAULT_MODEL_TYPE, DEFAULT_ABILITY
with gr.Row(elem_classes="container"):
data_run = gr.Button("Refresh")
data_run.click(
refresh_data,
inputs=[],
outputs=[data_component, model_type_filter, ability_filter]
)
block.launch()
|