Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -125,6 +125,133 @@ def add_new_eval(
|
|
| 125 |
print("success update", model_name)
|
| 126 |
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
def get_normalized_df(df):
|
| 129 |
# final_score = df.drop('name', axis=1).sum(axis=1)
|
| 130 |
# df.insert(1, 'Overall Score', final_score)
|
|
@@ -137,7 +264,7 @@ def get_normalized_df(df):
|
|
| 137 |
|
| 138 |
def get_normalized_i2v_df(df):
|
| 139 |
normalize_df = df.copy().fillna(0.0)
|
| 140 |
-
for column in normalize_df.columns[1
|
| 141 |
min_val = NORMALIZE_DIC_I2V[column]['Min']
|
| 142 |
max_val = NORMALIZE_DIC_I2V[column]['Max']
|
| 143 |
normalize_df[column] = (normalize_df[column] - min_val) / (max_val - min_val)
|
|
@@ -208,7 +335,7 @@ def get_final_score(df, selected_columns):
|
|
| 208 |
def get_final_score_i2v(df, selected_columns):
|
| 209 |
normalize_df = get_normalized_i2v_df(df)
|
| 210 |
#final_score = normalize_df.drop('name', axis=1).sum(axis=1)
|
| 211 |
-
for name in normalize_df.drop('Model Name (clickable)', axis=1).drop('Video-Text Camera Motion', axis=1):
|
| 212 |
normalize_df[name] = normalize_df[name]*DIM_WEIGHT_I2V[name]
|
| 213 |
quality_score = normalize_df[I2V_QUALITY_LIST].sum(axis=1)/sum([DIM_WEIGHT_I2V[i] for i in I2V_QUALITY_LIST])
|
| 214 |
i2v_score = normalize_df[I2V_LIST].sum(axis=1)/sum([DIM_WEIGHT_I2V[i] for i in I2V_LIST ])
|
|
@@ -603,7 +730,7 @@ with block:
|
|
| 603 |
gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
|
| 604 |
|
| 605 |
# table submission
|
| 606 |
-
with gr.TabItem("🚀 Submit here! ", elem_id="mvbench-tab-table", id=6):
|
| 607 |
gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
|
| 608 |
|
| 609 |
with gr.Row():
|
|
@@ -672,6 +799,77 @@ with block:
|
|
| 672 |
],
|
| 673 |
outputs=[submit_button, submit_succ_button, fail_textbox]
|
| 674 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
|
| 676 |
|
| 677 |
def refresh_data():
|
|
|
|
| 125 |
print("success update", model_name)
|
| 126 |
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 127 |
|
| 128 |
+
def add_new_eval_i2v(
|
| 129 |
+
input_file,
|
| 130 |
+
model_name_textbox: str,
|
| 131 |
+
revision_name_textbox: str,
|
| 132 |
+
model_link: str,
|
| 133 |
+
team_name: str,
|
| 134 |
+
contact_email: str,
|
| 135 |
+
model_publish: str,
|
| 136 |
+
model_resolution: str,
|
| 137 |
+
model_fps: str,
|
| 138 |
+
model_frame: str,
|
| 139 |
+
model_video_length: str,
|
| 140 |
+
model_checkpoint: str,
|
| 141 |
+
model_commit_id: str,
|
| 142 |
+
model_video_format: str
|
| 143 |
+
):
|
| 144 |
+
COLNAME2KEY={
|
| 145 |
+
"Video-Text Camera Motion":"camera_motion",
|
| 146 |
+
"Video-Image Subject Consistency": "i2v_subject",
|
| 147 |
+
"Video-Image Background Consistency": "i2v_background",
|
| 148 |
+
"Subject Consistency": "subject_consistency",
|
| 149 |
+
"Background Consistency": "background_consistency",
|
| 150 |
+
"Motion Smoothness": "motion_smoothness",
|
| 151 |
+
"Dynamic Degree": "dynamic_degree",
|
| 152 |
+
"Aesthetic Quality": "aesthetic_quality",
|
| 153 |
+
"Imaging Quality": "imaging_quality",
|
| 154 |
+
"Temporal Flickering": "temporal_flickering"
|
| 155 |
+
}
|
| 156 |
+
if input_file is None:
|
| 157 |
+
return "Error! Empty file!"
|
| 158 |
+
if model_link == '' or model_name_textbox == '' or contact_email == '':
|
| 159 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
|
| 160 |
+
|
| 161 |
+
upload_content = input_file
|
| 162 |
+
submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
|
| 163 |
+
submission_repo.git_pull()
|
| 164 |
+
filename = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 165 |
+
|
| 166 |
+
now = datetime.datetime.now()
|
| 167 |
+
update_time = now.strftime("%Y-%m-%d") # Capture update time
|
| 168 |
+
with open(f'{SUBMISSION_NAME}/{filename}.zip','wb') as f:
|
| 169 |
+
f.write(input_file)
|
| 170 |
+
# shutil.copyfile(CSV_DIR, os.path.join(SUBMISSION_NAME, f"{input_file}"))
|
| 171 |
+
|
| 172 |
+
csv_data = pd.read_csv(I2V_DIR)
|
| 173 |
+
|
| 174 |
+
if revision_name_textbox == '':
|
| 175 |
+
col = csv_data.shape[0]
|
| 176 |
+
model_name = model_name_textbox.replace(',',' ')
|
| 177 |
+
else:
|
| 178 |
+
model_name = revision_name_textbox.replace(',',' ')
|
| 179 |
+
model_name_list = csv_data['Model Name (clickable)']
|
| 180 |
+
name_list = [name.split(']')[0][1:] for name in model_name_list]
|
| 181 |
+
if revision_name_textbox not in name_list:
|
| 182 |
+
col = csv_data.shape[0]
|
| 183 |
+
else:
|
| 184 |
+
col = name_list.index(revision_name_textbox)
|
| 185 |
+
if model_link == '':
|
| 186 |
+
model_name = model_name # no url
|
| 187 |
+
else:
|
| 188 |
+
model_name = '[' + model_name + '](' + model_link + ')'
|
| 189 |
+
|
| 190 |
+
os.makedirs(filename, exist_ok=True)
|
| 191 |
+
with zipfile.ZipFile(io.BytesIO(input_file), 'r') as zip_ref:
|
| 192 |
+
zip_ref.extractall(filename)
|
| 193 |
+
|
| 194 |
+
upload_data = {}
|
| 195 |
+
for file in os.listdir(filename):
|
| 196 |
+
if file.startswith('.') or file.startswith('__'):
|
| 197 |
+
print(f"Skip the file: {file}")
|
| 198 |
+
continue
|
| 199 |
+
cur_file = os.path.join(filename, file)
|
| 200 |
+
if os.path.isdir(cur_file):
|
| 201 |
+
for subfile in os.listdir(cur_file):
|
| 202 |
+
if subfile.endswith(".json"):
|
| 203 |
+
with open(os.path.join(cur_file, subfile)) as ff:
|
| 204 |
+
cur_json = json.load(ff)
|
| 205 |
+
print(file, type(cur_json))
|
| 206 |
+
if isinstance(cur_json, dict):
|
| 207 |
+
print(cur_json.keys())
|
| 208 |
+
for key in cur_json:
|
| 209 |
+
upload_data[key] = cur_json[key][0]
|
| 210 |
+
print(f"{key}:{cur_json[key][0]}")
|
| 211 |
+
elif cur_file.endswith('json'):
|
| 212 |
+
with open(cur_file) as ff:
|
| 213 |
+
cur_json = json.load(ff)
|
| 214 |
+
print(file, type(cur_json))
|
| 215 |
+
if isinstance(cur_json, dict):
|
| 216 |
+
print(cur_json.keys())
|
| 217 |
+
for key in cur_json:
|
| 218 |
+
upload_data[key] = cur_json[key][0]
|
| 219 |
+
print(f"{key}:{cur_json[key][0]}")
|
| 220 |
+
# add new data
|
| 221 |
+
new_data = [model_name]
|
| 222 |
+
print('upload_data:', upload_data)
|
| 223 |
+
I2V_HEAD= ["Video-Text Camera Motion",
|
| 224 |
+
"Video-Image Subject Consistency",
|
| 225 |
+
"Video-Image Background Consistency",
|
| 226 |
+
"Subject Consistency",
|
| 227 |
+
"Background Consistency",
|
| 228 |
+
"Temporal Flickering",
|
| 229 |
+
"Motion Smoothness",
|
| 230 |
+
"Dynamic Degree",
|
| 231 |
+
"Aesthetic Quality",
|
| 232 |
+
"Imaging Quality" ]
|
| 233 |
+
for key in I2V_HEAD :
|
| 234 |
+
sub_key = COLNAME2KEY[key]
|
| 235 |
+
if sub_key in upload_data:
|
| 236 |
+
new_data.append(upload_data[sub_key])
|
| 237 |
+
else:
|
| 238 |
+
new_data.append(0)
|
| 239 |
+
if team_name =='' or 'vbench' in team_name.lower():
|
| 240 |
+
new_data.append("User Upload")
|
| 241 |
+
else:
|
| 242 |
+
new_data.append(team_name)
|
| 243 |
+
|
| 244 |
+
new_data.append(contact_email.replace(',',' and ')) # Add contact email [private]
|
| 245 |
+
new_data.append(update_time) # Add the update time
|
| 246 |
+
|
| 247 |
+
csv_data.loc[col] = new_data
|
| 248 |
+
csv_data = csv_data.to_csv(I2V_DIR , index=False)
|
| 249 |
+
with open(INFO_DIR,'a') as f:
|
| 250 |
+
f.write(f"{model_name}\t{update_time}\t{model_publish}\t{model_resolution}\t{model_fps}\t{model_frame}\t{model_video_length}\t{model_checkpoint}\t{model_commit_id}\t{model_video_format}\n")
|
| 251 |
+
submission_repo.push_to_hub()
|
| 252 |
+
print("success update", model_name)
|
| 253 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 254 |
+
|
| 255 |
def get_normalized_df(df):
|
| 256 |
# final_score = df.drop('name', axis=1).sum(axis=1)
|
| 257 |
# df.insert(1, 'Overall Score', final_score)
|
|
|
|
| 264 |
|
| 265 |
def get_normalized_i2v_df(df):
|
| 266 |
normalize_df = df.copy().fillna(0.0)
|
| 267 |
+
for column in normalize_df.columns[1:-3]:
|
| 268 |
min_val = NORMALIZE_DIC_I2V[column]['Min']
|
| 269 |
max_val = NORMALIZE_DIC_I2V[column]['Max']
|
| 270 |
normalize_df[column] = (normalize_df[column] - min_val) / (max_val - min_val)
|
|
|
|
| 335 |
def get_final_score_i2v(df, selected_columns):
|
| 336 |
normalize_df = get_normalized_i2v_df(df)
|
| 337 |
#final_score = normalize_df.drop('name', axis=1).sum(axis=1)
|
| 338 |
+
for name in normalize_df.drop('Model Name (clickable)', axis=1).drop('Video-Text Camera Motion', axis=1).drop('Source', axis=1).drop('Mail', axis=1).drop('Date',axis=1):
|
| 339 |
normalize_df[name] = normalize_df[name]*DIM_WEIGHT_I2V[name]
|
| 340 |
quality_score = normalize_df[I2V_QUALITY_LIST].sum(axis=1)/sum([DIM_WEIGHT_I2V[i] for i in I2V_QUALITY_LIST])
|
| 341 |
i2v_score = normalize_df[I2V_LIST].sum(axis=1)/sum([DIM_WEIGHT_I2V[i] for i in I2V_LIST ])
|
|
|
|
| 730 |
gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
|
| 731 |
|
| 732 |
# table submission
|
| 733 |
+
with gr.TabItem("🚀 [T2V]Submit here! ", elem_id="mvbench-tab-table", id=6):
|
| 734 |
gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
|
| 735 |
|
| 736 |
with gr.Row():
|
|
|
|
| 799 |
],
|
| 800 |
outputs=[submit_button, submit_succ_button, fail_textbox]
|
| 801 |
)
|
| 802 |
+
|
| 803 |
+
with gr.TabItem("🚀 [I2V]Submit here! ", elem_id="mvbench-i2v-tab-table", id=7):
|
| 804 |
+
gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
|
| 805 |
+
|
| 806 |
+
with gr.Row():
|
| 807 |
+
gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")
|
| 808 |
+
|
| 809 |
+
with gr.Row():
|
| 810 |
+
gr.Markdown("# ✉️✨ Submit your i2v model evaluation json file here!", elem_classes="markdown-text")
|
| 811 |
+
|
| 812 |
+
with gr.Row():
|
| 813 |
+
gr.Markdown("Here is a required field", elem_classes="markdown-text")
|
| 814 |
+
with gr.Row():
|
| 815 |
+
with gr.Column():
|
| 816 |
+
model_name_textbox_i2v = gr.Textbox(
|
| 817 |
+
label="Model name", placeholder="Required field"
|
| 818 |
+
)
|
| 819 |
+
revision_name_textbox_i2v = gr.Textbox(
|
| 820 |
+
label="Revision Model Name(Optional)", placeholder="If you need to update the previous results, please fill in this line"
|
| 821 |
+
)
|
| 822 |
+
|
| 823 |
+
with gr.Column():
|
| 824 |
+
model_link_i2v = gr.Textbox(
|
| 825 |
+
label="Project Page/Paper Link/Github/HuggingFace Repo", placeholder="Required field. If filling in the wrong information, your results may be removed."
|
| 826 |
+
)
|
| 827 |
+
team_name_i2v = gr.Textbox(
|
| 828 |
+
label="Your Team Name(If left blank, it will be user upload)", placeholder="User Upload"
|
| 829 |
+
)
|
| 830 |
+
contact_email_i2v = gr.Textbox(
|
| 831 |
+
label="E-Mail(Will not be displayed)", placeholder="Required field"
|
| 832 |
+
)
|
| 833 |
+
with gr.Row():
|
| 834 |
+
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")
|
| 835 |
+
with gr.Row():
|
| 836 |
+
release_time_i2v = gr.Textbox(label="Time of Publish", placeholder="1970-01-01")
|
| 837 |
+
model_resolution_i2v = gr.Textbox(label="resolution", placeholder="Width x Height")
|
| 838 |
+
model_fps_i2v = gr.Textbox(label="model fps", placeholder="FPS(int)")
|
| 839 |
+
model_frame_i2v = gr.Textbox(label="model frame count", placeholder="INT")
|
| 840 |
+
model_video_length_i2v = gr.Textbox(label="model video length", placeholder="float(2.0)")
|
| 841 |
+
model_checkpoint_i2v = gr.Textbox(label="model checkpoint", placeholder="optional")
|
| 842 |
+
model_commit_id_i2v = gr.Textbox(label="github commit id", placeholder='main')
|
| 843 |
+
model_video_format_i2v = gr.Textbox(label="pipeline format", placeholder='mp4')
|
| 844 |
+
with gr.Column():
|
| 845 |
+
input_file_i2v = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
|
| 846 |
+
submit_button_i2v = gr.Button("Submit Eval")
|
| 847 |
+
submit_succ_button_i2v = gr.Markdown("Submit Success! Please press refresh and return to LeaderBoard!", visible=False)
|
| 848 |
+
fail_textbox_i2v = gr.Markdown('<span style="color:red;">Please ensure that the `Model Name`, `Project Page`, and `Email` are filled in correctly.</span>', elem_classes="markdown-text",visible=False)
|
| 849 |
+
|
| 850 |
+
|
| 851 |
+
submission_result_i2v = gr.Markdown()
|
| 852 |
+
submit_button_i2v.click(
|
| 853 |
+
add_new_eval_i2v,
|
| 854 |
+
inputs = [
|
| 855 |
+
input_file_i2v,
|
| 856 |
+
model_name_textbox_i2v,
|
| 857 |
+
revision_name_textbox_i2v,
|
| 858 |
+
model_link_i2v,
|
| 859 |
+
team_name_i2v,
|
| 860 |
+
contact_email_i2v,
|
| 861 |
+
release_time_i2v,
|
| 862 |
+
model_resolution_i2v,
|
| 863 |
+
model_fps_i2v,
|
| 864 |
+
model_frame_i2v,
|
| 865 |
+
model_video_length_i2v,
|
| 866 |
+
model_checkpoint_i2v,
|
| 867 |
+
model_commit_id_i2v,
|
| 868 |
+
model_video_format_i2v
|
| 869 |
+
],
|
| 870 |
+
outputs=[submit_button_i2v, submit_succ_button_i2v, fail_textbox_i2v]
|
| 871 |
+
)
|
| 872 |
+
|
| 873 |
|
| 874 |
|
| 875 |
def refresh_data():
|