lwpyh commited on
Commit
09048b8
·
verified ·
1 Parent(s): 6167a66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -346
app.py CHANGED
@@ -22,113 +22,6 @@ def upload_file(files):
22
  file_paths = [file.name for file in files]
23
  return file_paths
24
 
25
- def add_new_eval(
26
- input_file,
27
- model_name_textbox: str,
28
- revision_name_textbox: str,
29
- model_link: str,
30
- team_name: str,
31
- contact_email: str,
32
- access_type: str,
33
- model_publish: str,
34
- model_resolution: str,
35
- model_fps: str,
36
- model_frame: str,
37
- model_video_length: str,
38
- model_checkpoint: str,
39
- model_commit_id: str,
40
- model_video_format: str
41
- ):
42
- if input_file is None:
43
- return "Error! Empty file!"
44
- if model_link == '' or model_name_textbox == '' or contact_email == '':
45
- return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
46
- # upload_data=json.loads(input_file)
47
- upload_content = input_file
48
- submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
49
- submission_repo.git_pull()
50
- filename = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
51
-
52
- now = datetime.datetime.now()
53
- update_time = now.strftime("%Y-%m-%d") # Capture update time
54
- with open(f'{SUBMISSION_NAME}/{filename}.zip','wb') as f:
55
- f.write(input_file)
56
- # shutil.copyfile(CSV_DIR, os.path.join(SUBMISSION_NAME, f"{input_file}"))
57
-
58
- csv_data = pd.read_csv(CSV_DIR)
59
-
60
- if revision_name_textbox == '':
61
- col = csv_data.shape[0]
62
- model_name = model_name_textbox.replace(',',' ')
63
- else:
64
- model_name = revision_name_textbox.replace(',',' ')
65
- model_name_list = csv_data['Model Name (clickable)']
66
- name_list = [name.split(']')[0][1:] for name in model_name_list]
67
- if revision_name_textbox not in name_list:
68
- col = csv_data.shape[0]
69
- else:
70
- col = name_list.index(revision_name_textbox)
71
- if model_link == '':
72
- model_name = model_name # no url
73
- else:
74
- model_name = '[' + model_name + '](' + model_link + ')'
75
-
76
- os.makedirs(filename, exist_ok=True)
77
- with zipfile.ZipFile(io.BytesIO(input_file), 'r') as zip_ref:
78
- zip_ref.extractall(filename)
79
-
80
- upload_data = {}
81
- for file in os.listdir(filename):
82
- if file.startswith('.') or file.startswith('__'):
83
- print(f"Skip the file: {file}")
84
- continue
85
- cur_file = os.path.join(filename, file)
86
- if os.path.isdir(cur_file):
87
- for subfile in os.listdir(cur_file):
88
- if subfile.endswith(".json"):
89
- with open(os.path.join(cur_file, subfile)) as ff:
90
- cur_json = json.load(ff)
91
- print(file, type(cur_json))
92
- if isinstance(cur_json, dict):
93
- print(cur_json.keys())
94
- for key in cur_json:
95
- upload_data[key.replace('_',' ')] = cur_json[key][0]
96
- print(f"{key}:{cur_json[key][0]}")
97
- elif cur_file.endswith('json'):
98
- with open(cur_file) as ff:
99
- cur_json = json.load(ff)
100
- print(file, type(cur_json))
101
- if isinstance(cur_json, dict):
102
- print(cur_json.keys())
103
- for key in cur_json:
104
- upload_data[key.replace('_',' ')] = cur_json[key][0]
105
- print(f"{key}:{cur_json[key][0]}")
106
- # add new data
107
- new_data = [model_name]
108
- print('upload_data:', upload_data)
109
- for key in TASK_INFO:
110
- if key in upload_data:
111
- new_data.append(upload_data[key])
112
- else:
113
- new_data.append(0)
114
- if team_name =='' or 'vbench' in team_name.lower():
115
- new_data.append("User Upload")
116
- else:
117
- new_data.append(team_name)
118
-
119
- new_data.append(contact_email.replace(',',' and ')) # Add contact email [private]
120
- new_data.append(update_time) # Add the update time
121
- new_data.append(team_name)
122
- new_data.append(access_type)
123
-
124
- csv_data.loc[col] = new_data
125
- csv_data = csv_data.to_csv(CSV_DIR, index=False)
126
- with open(INFO_DIR,'a') as f:
127
- 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")
128
- submission_repo.push_to_hub()
129
- print("success update", model_name)
130
- return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
131
-
132
  def add_new_eval_i2v(
133
  input_file,
134
  model_name_textbox: str,
@@ -413,41 +306,6 @@ def get_baseline_df():
413
  df = convert_scores_to_percentage(df)
414
  return df
415
 
416
- def get_baseline_df_quality():
417
- submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
418
- submission_repo.git_pull()
419
- df = pd.read_csv(QUALITY_DIR)
420
- df = get_final_score_quality(df, checkbox_group_quality.value)
421
- df = df.sort_values(by="Selected Score", ascending=False)
422
- present_columns = MODEL_INFO_TAB_QUALITY + checkbox_group_quality.value
423
- df = df[present_columns]
424
- df = convert_scores_to_percentage(df)
425
- return df
426
-
427
- def get_baseline_df_i2v():
428
- submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
429
- submission_repo.git_pull()
430
- df = pd.read_csv(I2V_DIR)
431
- df = get_final_score_i2v(df, checkbox_group_i2v.value)
432
- df = df.sort_values(by="Selected Score", ascending=False)
433
- present_columns = MODEL_INFO_TAB_I2V + checkbox_group_i2v.value
434
- # df = df[df["Sampled by"] == 'VBench Team']
435
- df = df[present_columns]
436
- df = convert_scores_to_percentage(df)
437
- return df
438
-
439
- def get_baseline_df_long():
440
- submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
441
- submission_repo.git_pull()
442
- df = pd.read_csv(LONG_DIR)
443
- df = get_final_score(df, checkbox_group.value)
444
- df = df.sort_values(by="Selected Score", ascending=False)
445
- present_columns = MODEL_INFO + checkbox_group.value
446
- # df = df[df["Sampled by"] == 'VBench Team']
447
- df = df[present_columns]
448
- df = convert_scores_to_percentage(df)
449
- return df
450
-
451
  def get_all_df(selected_columns, dir=CSV_DIR):
452
  submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
453
  submission_repo.git_pull()
@@ -673,215 +531,12 @@ with block:
673
  checkbox_group.change(fn=on_filter_model_size_method_change, inputs=[ checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
674
  vbench_team_filter.change(fn=on_filter_model_size_method_change, inputs=[checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
675
  vbench_validate_filter.change(fn=on_filter_model_size_method_change, inputs=[checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
676
- # Table 1
677
- with gr.TabItem("Video Quality", elem_id="vbench-tab-table", id=2):
678
- with gr.Accordion("INSTRUCTION", open=False):
679
- citation_button = gr.Textbox(
680
- value=QUALITY_CLAIM_TEXT,
681
- label="",
682
- elem_id="quality-button",
683
- lines=2,
684
- )
685
- with gr.Row():
686
- with gr.Column(scale=1.0):
687
- # selection for column part:
688
-
689
- checkbox_group_quality = gr.CheckboxGroup(
690
- choices=QUALITY_TAB,
691
- value=QUALITY_TAB,
692
- label="Evaluation Quality Dimension",
693
- interactive=True,
694
- )
695
-
696
- data_component_quality = gr.components.Dataframe(
697
- value=get_baseline_df_quality,
698
- headers=COLUMN_NAMES_QUALITY,
699
- type="pandas",
700
- datatype=DATA_TITILE_TYPE,
701
- interactive=False,
702
- visible=True,
703
- )
704
-
705
- checkbox_group_quality.change(fn=on_filter_model_size_method_change_quality, inputs=[checkbox_group_quality], outputs=data_component_quality)
706
-
707
- # Table i2v
708
- with gr.TabItem("VBench-I2V", elem_id="vbench-tab-table", id=3):
709
- with gr.Accordion("NOTE", open=False):
710
- i2v_note_button = gr.Textbox(
711
- value=I2V_CLAIM_TEXT,
712
- label="",
713
- elem_id="quality-button",
714
- lines=3,
715
- )
716
- with gr.Row():
717
- with gr.Column(scale=1.0):
718
- # selection for column part:
719
- with gr.Row():
720
- vbench_team_filter_i2v = gr.Checkbox(
721
- label="Sampled by VBench Team (Uncheck to view all submissions)",
722
- value=False,
723
- interactive=True
724
- )
725
- vbench_validate_filter_i2v = gr.Checkbox(
726
- label="Evaluated by VBench Team (Uncheck to view all submissions)",
727
- value=False,
728
- interactive=True
729
- )
730
- checkbox_group_i2v = gr.CheckboxGroup(
731
- choices=I2V_TAB,
732
- value=I2V_TAB,
733
- label="Evaluation Quality Dimension",
734
- interactive=True,
735
- )
736
-
737
- data_component_i2v = gr.components.Dataframe(
738
- value=get_baseline_df_i2v,
739
- headers=COLUMN_NAMES_I2V,
740
- type="pandas",
741
- datatype=I2V_TITILE_TYPE,
742
- interactive=False,
743
- visible=True,
744
- )
745
-
746
- checkbox_group_i2v.change(fn=on_filter_model_size_method_change_i2v, inputs=[checkbox_group_i2v, vbench_team_filter_i2v,vbench_validate_filter_i2v], outputs=data_component_i2v)
747
- vbench_team_filter_i2v.change(fn=on_filter_model_size_method_change_i2v, inputs=[checkbox_group_i2v, vbench_team_filter_i2v,vbench_validate_filter_i2v], outputs=data_component_i2v)
748
- vbench_validate_filter_i2v.change(fn=on_filter_model_size_method_change_i2v, inputs=[checkbox_group_i2v, vbench_team_filter_i2v,vbench_validate_filter_i2v], outputs=data_component_i2v)
749
 
750
- with gr.TabItem("📊 VBench-Long", elem_id="vbench-tab-table", id=4):
751
- with gr.Row():
752
- with gr.Accordion("INSTRUCTION", open=False):
753
- citation_button = gr.Textbox(
754
- value=LONG_CLAIM_TEXT,
755
- label="",
756
- elem_id="long-ins-button",
757
- lines=2,
758
- )
759
-
760
- gr.Markdown(
761
- TABLE_INTRODUCTION
762
- )
763
- with gr.Row():
764
- with gr.Column(scale=0.2):
765
- choosen_q_long = gr.Button("Select Quality Dimensions")
766
- choosen_s_long = gr.Button("Select Semantic Dimensions")
767
- enable_b_long = gr.Button("Select All")
768
- disable_b_long = gr.Button("Deselect All")
769
-
770
- with gr.Column(scale=0.8):
771
- with gr.Row():
772
- vbench_team_filter_long = gr.Checkbox(
773
- label="Sampled by VBench Team (Uncheck to view all submissions)",
774
- value=False,
775
- interactive=True
776
- )
777
- vbench_validate_filter_long = gr.Checkbox(
778
- label="Evaluated by VBench Team (Uncheck to view all submissions)",
779
- value=False,
780
- interactive=True
781
- )
782
- checkbox_group_long = gr.CheckboxGroup(
783
- choices=TASK_INFO,
784
- value=DEFAULT_INFO,
785
- label="Evaluation Dimension",
786
- interactive=True,
787
- )
788
-
789
- data_component = gr.components.Dataframe(
790
- value=get_baseline_df_long,
791
- headers=COLUMN_NAMES,
792
- type="pandas",
793
- datatype=DATA_TITILE_TYPE,
794
- interactive=False,
795
- visible=True,
796
- # height=700,
797
- )
798
-
799
- choosen_q_long.click(choose_all_quailty, inputs=None, outputs=[checkbox_group_long]).then(fn=on_filter_model_size_method_change_long, inputs=[ checkbox_group_long, vbench_team_filter_long, vbench_validate_filter_long], outputs=data_component)
800
- choosen_s_long.click(choose_all_semantic, inputs=None, outputs=[checkbox_group_long]).then(fn=on_filter_model_size_method_change_long, inputs=[ checkbox_group_long, vbench_team_filter_long, vbench_validate_filter_long], outputs=data_component)
801
- enable_b_long.click(enable_all, inputs=None, outputs=[checkbox_group_long]).then(fn=on_filter_model_size_method_change_long, inputs=[ checkbox_group_long, vbench_team_filter_long, vbench_validate_filter_long], outputs=data_component)
802
- disable_b_long.click(disable_all, inputs=None, outputs=[checkbox_group_long]).then(fn=on_filter_model_size_method_change_long, inputs=[ checkbox_group_long, vbench_team_filter_long, vbench_validate_filter_long], outputs=data_component)
803
- checkbox_group_long.change(fn=on_filter_model_size_method_change_long, inputs=[checkbox_group_long, vbench_team_filter_long,vbench_validate_filter_long], outputs=data_component)
804
- vbench_team_filter_long.change(fn=on_filter_model_size_method_change_long, inputs=[checkbox_group_long, vbench_team_filter_long,vbench_validate_filter_long], outputs=data_component)
805
- vbench_validate_filter_long.change(fn=on_filter_model_size_method_change_long, inputs=[checkbox_group_long, vbench_team_filter_long,vbench_validate_filter_long], outputs=data_component)
806
-
807
  # table info
808
  with gr.TabItem("📝 About", elem_id="mvbench-tab-table", id=5):
809
  gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
810
 
811
- # table submission
812
- with gr.TabItem("🚀 [T2V]Submit here! ", elem_id="mvbench-tab-table", id=6):
813
- gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
814
-
815
- with gr.Row():
816
- gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")
817
-
818
- with gr.Row():
819
- gr.Markdown("# ✉️✨ Submit your model evaluation json file here!", elem_classes="markdown-text")
820
-
821
- with gr.Row():
822
- gr.Markdown("Here is a required field", elem_classes="markdown-text")
823
- with gr.Row():
824
- with gr.Column():
825
- model_name_textbox = gr.Textbox(
826
- label="Model name", placeholder="Required field"
827
- )
828
- revision_name_textbox = gr.Textbox(
829
- label="Revision Model Name(Optional)", placeholder="If you need to update the previous results, please fill in this line"
830
- )
831
- access_type = 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.")
832
-
833
- with gr.Column():
834
- model_link = gr.Textbox(
835
- label="Project Page/Paper Link/Github/HuggingFace Repo", placeholder="Required field. If filling in the wrong information, your results may be removed."
836
- )
837
- team_name = gr.Textbox(
838
- label="Your Team Name(If left blank, it will be user upload)", placeholder="User Upload"
839
- )
840
- contact_email = gr.Textbox(
841
- label="E-Mail(Will not be displayed)", placeholder="Required field"
842
- )
843
- with gr.Row():
844
- 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")
845
- with gr.Row():
846
- release_time = gr.Textbox(label="Time of Publish", placeholder="1970-01-01")
847
- model_resolution = gr.Textbox(label="resolution", )#placeholder="Width x Height")
848
- model_fps = gr.Textbox(label="model fps", placeholder="FPS(int)")
849
- model_frame = gr.Textbox(label="model frame count", placeholder="INT")
850
- model_video_length = gr.Textbox(label="model video length", placeholder="float(2.0)")
851
- model_checkpoint = gr.Textbox(label="model checkpoint", placeholder="optional")
852
- model_commit_id = gr.Textbox(label="github commit id", placeholder='main')
853
- model_video_format = gr.Textbox(label="pipeline format", placeholder='mp4')
854
- with gr.Column():
855
- input_file = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
856
- submit_button = gr.Button("Submit Eval")
857
- submit_succ_button = gr.Markdown("Submit Success! Please press refresh and return to LeaderBoard!", visible=False)
858
- fail_textbox = 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)
859
-
860
-
861
- submission_result = gr.Markdown()
862
- submit_button.click(
863
- add_new_eval,
864
- inputs = [
865
- input_file,
866
- model_name_textbox,
867
- revision_name_textbox,
868
- model_link,
869
- team_name,
870
- contact_email,
871
- release_time,
872
- access_type,
873
- model_resolution,
874
- model_fps,
875
- model_frame,
876
- model_video_length,
877
- model_checkpoint,
878
- model_commit_id,
879
- model_video_format
880
- ],
881
- outputs=[submit_button, submit_succ_button, fail_textbox]
882
- )
883
-
884
- with gr.TabItem("🚀 [I2V]Submit here! ", elem_id="mvbench-i2v-tab-table", id=7):
885
  gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
886
 
887
  with gr.Row():
 
22
  file_paths = [file.name for file in files]
23
  return file_paths
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def add_new_eval_i2v(
26
  input_file,
27
  model_name_textbox: str,
 
306
  df = convert_scores_to_percentage(df)
307
  return df
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  def get_all_df(selected_columns, dir=CSV_DIR):
310
  submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
311
  submission_repo.git_pull()
 
531
  checkbox_group.change(fn=on_filter_model_size_method_change, inputs=[ checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
532
  vbench_team_filter.change(fn=on_filter_model_size_method_change, inputs=[checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
533
  vbench_validate_filter.change(fn=on_filter_model_size_method_change, inputs=[checkbox_group, vbench_team_filter, vbench_validate_filter], outputs=data_component)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  # table info
536
  with gr.TabItem("📝 About", elem_id="mvbench-tab-table", id=5):
537
  gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
538
 
539
+ with gr.TabItem("🚀 Submit here! ", elem_id="mvbench-i2v-tab-table", id=7):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  gr.Markdown(LEADERBORAD_INTRODUCTION, elem_classes="markdown-text")
541
 
542
  with gr.Row():