Spaces:
Runtime error
Runtime error
[update] add submit to vbench2
Browse files
app.py
CHANGED
|
@@ -133,6 +133,126 @@ def add_new_eval(
|
|
| 133 |
print("success update", model_name)
|
| 134 |
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def add_new_eval_i2v(
|
| 137 |
input_file,
|
| 138 |
model_name_textbox: str,
|
|
@@ -1072,7 +1192,78 @@ with block:
|
|
| 1072 |
],
|
| 1073 |
outputs=[submit_button_i2v, submit_succ_button_i2v, fail_textbox_i2v]
|
| 1074 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1075 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
|
| 1077 |
|
| 1078 |
def refresh_data():
|
|
|
|
| 133 |
print("success update", model_name)
|
| 134 |
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 135 |
|
| 136 |
+
|
| 137 |
+
def add_new_eval_vbench2(
|
| 138 |
+
input_file,
|
| 139 |
+
model_name_textbox: str,
|
| 140 |
+
revision_name_textbox: str,
|
| 141 |
+
model_link: str,
|
| 142 |
+
team_name: str,
|
| 143 |
+
contact_email: str,
|
| 144 |
+
access_type: str,
|
| 145 |
+
model_publish: str,
|
| 146 |
+
model_resolution: str,
|
| 147 |
+
model_fps: str,
|
| 148 |
+
model_frame: str,
|
| 149 |
+
model_video_length: str,
|
| 150 |
+
model_checkpoint: str,
|
| 151 |
+
model_commit_id: str,
|
| 152 |
+
model_video_format: str
|
| 153 |
+
):
|
| 154 |
+
if input_file is None:
|
| 155 |
+
return "Error! Empty file!"
|
| 156 |
+
if model_link == '' or model_name_textbox == '' or contact_email == '':
|
| 157 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
|
| 158 |
+
upload_content = input_file
|
| 159 |
+
submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
|
| 160 |
+
submission_repo.git_pull()
|
| 161 |
+
filename = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 162 |
+
|
| 163 |
+
now = datetime.datetime.now()
|
| 164 |
+
update_time = now.strftime("%Y-%m-%d") # Capture update time
|
| 165 |
+
with open(f'{SUBMISSION_NAME}/{filename}.zip','wb') as f:
|
| 166 |
+
f.write(input_file)
|
| 167 |
+
|
| 168 |
+
csv_data = pd.read_csv(VBENCH2_DIR)
|
| 169 |
+
|
| 170 |
+
if revision_name_textbox == '':
|
| 171 |
+
col = csv_data.shape[0]
|
| 172 |
+
model_name = model_name_textbox.replace(',',' ')
|
| 173 |
+
else:
|
| 174 |
+
model_name = revision_name_textbox.replace(',',' ')
|
| 175 |
+
model_name_list = csv_data['Model Name (clickable)']
|
| 176 |
+
name_list = [name.split(']')[0][1:] for name in model_name_list]
|
| 177 |
+
if revision_name_textbox not in name_list:
|
| 178 |
+
col = csv_data.shape[0]
|
| 179 |
+
else:
|
| 180 |
+
col = name_list.index(revision_name_textbox)
|
| 181 |
+
if model_link == '':
|
| 182 |
+
model_name = model_name # no url
|
| 183 |
+
else:
|
| 184 |
+
model_name = '[' + model_name + '](' + model_link + ')'
|
| 185 |
+
|
| 186 |
+
os.makedirs(filename, exist_ok=True)
|
| 187 |
+
with zipfile.ZipFile(io.BytesIO(input_file), 'r') as zip_ref:
|
| 188 |
+
zip_ref.extractall(filename)
|
| 189 |
+
|
| 190 |
+
upload_data = {}
|
| 191 |
+
for file in os.listdir(filename):
|
| 192 |
+
if file.startswith('.') or file.startswith('__'):
|
| 193 |
+
print(f"Skip the file: {file}")
|
| 194 |
+
continue
|
| 195 |
+
cur_file = os.path.join(filename, file)
|
| 196 |
+
if os.path.isdir(cur_file):
|
| 197 |
+
for subfile in os.listdir(cur_file):
|
| 198 |
+
cur_subfile = os.path.join(cur_file, subfile)
|
| 199 |
+
if os.path.isdir(cur_subfile):
|
| 200 |
+
for subsubfile in os.listdir(cur_subfile):
|
| 201 |
+
if subsubfile.endswith(".json") and "eval_result" in subsubfile:
|
| 202 |
+
with open(os.path.join(cur_subfile,subsubfile)) as ff:
|
| 203 |
+
cur_json = json.load(ff)
|
| 204 |
+
print(file, type(cur_json))
|
| 205 |
+
if isinstance(cur_json, dict):
|
| 206 |
+
print(cur_json.keys())
|
| 207 |
+
for key in cur_json:
|
| 208 |
+
upload_data[key.replace('_',' ')] = cur_json[key][0]
|
| 209 |
+
print(f"{key}:{cur_json[key][0]}")
|
| 210 |
+
else:
|
| 211 |
+
if subfile.endswith(".json") and "eval_result" in subfile:
|
| 212 |
+
with open(cur_subfile) 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.replace('_',' ')] = cur_json[key][0]
|
| 219 |
+
print(f"{key}:{cur_json[key][0]}")
|
| 220 |
+
elif cur_file.endswith('json') and "eval_result" in subfile:
|
| 221 |
+
with open(cur_file) as ff:
|
| 222 |
+
cur_json = json.load(ff)
|
| 223 |
+
print(file, type(cur_json))
|
| 224 |
+
if isinstance(cur_json, dict):
|
| 225 |
+
print(cur_json.keys())
|
| 226 |
+
for key in cur_json:
|
| 227 |
+
upload_data[key.replace('_',' ')] = cur_json[key][0]
|
| 228 |
+
print(f"{key}:{cur_json[key][0]}")
|
| 229 |
+
# add new data
|
| 230 |
+
new_data = [model_name]
|
| 231 |
+
# print('upload_data:', upload_data)
|
| 232 |
+
for key in TASK_INFO_2:
|
| 233 |
+
if key in upload_data:
|
| 234 |
+
new_data.append(upload_data[key])
|
| 235 |
+
else:
|
| 236 |
+
new_data.append(0)
|
| 237 |
+
if team_name =='' or 'vbench' in team_name.lower():
|
| 238 |
+
new_data.append("User Upload")
|
| 239 |
+
else:
|
| 240 |
+
new_data.append(team_name)
|
| 241 |
+
|
| 242 |
+
new_data.append(contact_email.replace(',',' and ')) # Add contact email [private]
|
| 243 |
+
new_data.append(update_time) # Add the update time
|
| 244 |
+
new_data.append(team_name)
|
| 245 |
+
new_data.append(access_type)
|
| 246 |
+
# print(csv_data, new_data)
|
| 247 |
+
csv_data.loc[col] = new_data
|
| 248 |
+
# print()
|
| 249 |
+
csv_data = csv_data.to_csv(VBENCH2_DIR, index=False)
|
| 250 |
+
with open(INFO_DIR,'a') as f:
|
| 251 |
+
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")
|
| 252 |
+
submission_repo.push_to_hub()
|
| 253 |
+
print("success update", model_name)
|
| 254 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 255 |
+
|
| 256 |
def add_new_eval_i2v(
|
| 257 |
input_file,
|
| 258 |
model_name_textbox: str,
|
|
|
|
| 1192 |
],
|
| 1193 |
outputs=[submit_button_i2v, submit_succ_button_i2v, fail_textbox_i2v]
|
| 1194 |
)
|
| 1195 |
+
with gr.TabItem("⭐ [VBench2]Submit here! ", elem_id="mvbench-tab-table", id=9):
|
| 1196 |
+
gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
|
| 1197 |
+
|
| 1198 |
+
with gr.Row():
|
| 1199 |
+
gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")
|
| 1200 |
+
|
| 1201 |
+
with gr.Row():
|
| 1202 |
+
gr.Markdown("# ✉️✨ Submit your model evaluation json file here!", elem_classes="markdown-text")
|
| 1203 |
+
|
| 1204 |
+
with gr.Row():
|
| 1205 |
+
gr.Markdown("Here is a required field", elem_classes="markdown-text")
|
| 1206 |
+
with gr.Row():
|
| 1207 |
+
with gr.Column():
|
| 1208 |
+
model_name_textbox_vbench2 = gr.Textbox(
|
| 1209 |
+
label="Model name", placeholder="Required field"
|
| 1210 |
+
)
|
| 1211 |
+
revision_name_textbox_vbench2 = gr.Textbox(
|
| 1212 |
+
label="Revision Model Name(Optional)", placeholder="If you need to update the previous results, please fill in this line"
|
| 1213 |
+
)
|
| 1214 |
+
access_type_vbench2 = gr.Dropdown(["Open Source", "Ready to Open Source", "API", "Close"], label="Please select the way user can access your model. You can update the content by revision_name, or contact the VBench Team.")
|
| 1215 |
|
| 1216 |
+
with gr.Column():
|
| 1217 |
+
model_link_vbench2 = gr.Textbox(
|
| 1218 |
+
label="Project Page/Paper Link/Github/HuggingFace Repo", placeholder="Required field. If filling in the wrong information, your results may be removed."
|
| 1219 |
+
)
|
| 1220 |
+
team_name_vbench2 = gr.Textbox(
|
| 1221 |
+
label="Your Team Name(If left blank, it will be user upload)", placeholder="User Upload"
|
| 1222 |
+
)
|
| 1223 |
+
contact_email_vbench2 = gr.Textbox(
|
| 1224 |
+
label="E-Mail(Will not be displayed)", placeholder="Required field"
|
| 1225 |
+
)
|
| 1226 |
+
with gr.Row():
|
| 1227 |
+
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")
|
| 1228 |
+
with gr.Row():
|
| 1229 |
+
release_time_vbench2 = gr.Textbox(label="Time of Publish", placeholder="1970-01-01")
|
| 1230 |
+
model_resolution_vbench2 = gr.Textbox(label="resolution", placeholder="Width x Height")
|
| 1231 |
+
model_fps_vbench2 = gr.Textbox(label="model fps", placeholder="FPS(int)")
|
| 1232 |
+
model_frame_vbench2 = gr.Textbox(label="model frame count", placeholder="INT")
|
| 1233 |
+
model_video_length_vbench2 = gr.Textbox(label="model video length", placeholder="float(2.0)")
|
| 1234 |
+
model_checkpoint_vbench2 = gr.Textbox(label="model checkpoint", placeholder="optional")
|
| 1235 |
+
model_commit_id_vbench2 = gr.Textbox(label="github commit id", placeholder='main')
|
| 1236 |
+
model_video_format_vbench2 = gr.Textbox(label="pipeline format", placeholder='mp4')
|
| 1237 |
+
with gr.Column():
|
| 1238 |
+
input_file_vbench2 = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
|
| 1239 |
+
submit_button_vbench2 = gr.Button("Submit Eval")
|
| 1240 |
+
submit_succ_button_vbench2 = gr.Markdown("Submit Success! Please press refresh and return to LeaderBoard!", visible=False)
|
| 1241 |
+
fail_textbox_vbench2 = 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)
|
| 1242 |
+
|
| 1243 |
+
|
| 1244 |
+
submission_result = gr.Markdown()
|
| 1245 |
+
submit_button_vbench2.click(
|
| 1246 |
+
add_new_eval_vbench2,
|
| 1247 |
+
inputs = [
|
| 1248 |
+
input_file_vbench2,
|
| 1249 |
+
model_name_textbox_vbench2,
|
| 1250 |
+
revision_name_textbox_vbench2,
|
| 1251 |
+
model_link_vbench2,
|
| 1252 |
+
team_name_vbench2,
|
| 1253 |
+
contact_email_vbench2,
|
| 1254 |
+
release_time_vbench2,
|
| 1255 |
+
access_type_vbench2,
|
| 1256 |
+
model_resolution_vbench2,
|
| 1257 |
+
model_fps_vbench2,
|
| 1258 |
+
model_frame_vbench2,
|
| 1259 |
+
model_video_length_vbench2,
|
| 1260 |
+
model_checkpoint_vbench2,
|
| 1261 |
+
model_commit_id_vbench2,
|
| 1262 |
+
model_video_format_vbench2
|
| 1263 |
+
],
|
| 1264 |
+
outputs=[submit_button_vbench2, submit_succ_button_vbench2, fail_textbox_vbench2]
|
| 1265 |
+
)
|
| 1266 |
+
|
| 1267 |
|
| 1268 |
|
| 1269 |
def refresh_data():
|