Upload app.py
Browse files
app.py
CHANGED
|
@@ -22,242 +22,242 @@ def upload_file(files):
|
|
| 22 |
file_paths = [file.name for file in files]
|
| 23 |
return file_paths
|
| 24 |
|
| 25 |
-
def add_new_eval(
|
| 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 |
-
def add_new_eval_i2v(
|
| 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 |
def get_normalized_df(df):
|
| 263 |
# final_score = df.drop('name', axis=1).sum(axis=1)
|
|
|
|
| 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,
|
| 135 |
+
# revision_name_textbox: str,
|
| 136 |
+
# model_link: str,
|
| 137 |
+
# team_name: str,
|
| 138 |
+
# contact_email: str,
|
| 139 |
+
# access_type: str,
|
| 140 |
+
# model_publish: str,
|
| 141 |
+
# model_resolution: str,
|
| 142 |
+
# model_fps: str,
|
| 143 |
+
# model_frame: str,
|
| 144 |
+
# model_video_length: str,
|
| 145 |
+
# model_checkpoint: str,
|
| 146 |
+
# model_commit_id: str,
|
| 147 |
+
# model_video_format: str
|
| 148 |
+
# ):
|
| 149 |
+
# COLNAME2KEY={
|
| 150 |
+
# "Video-Text Camera Motion":"camera_motion",
|
| 151 |
+
# "Video-Image Subject Consistency": "i2v_subject",
|
| 152 |
+
# "Video-Image Background Consistency": "i2v_background",
|
| 153 |
+
# "Subject Consistency": "subject_consistency",
|
| 154 |
+
# "Background Consistency": "background_consistency",
|
| 155 |
+
# "Motion Smoothness": "motion_smoothness",
|
| 156 |
+
# "Dynamic Degree": "dynamic_degree",
|
| 157 |
+
# "Aesthetic Quality": "aesthetic_quality",
|
| 158 |
+
# "Imaging Quality": "imaging_quality",
|
| 159 |
+
# "Temporal Flickering": "temporal_flickering"
|
| 160 |
+
# }
|
| 161 |
+
# if input_file is None:
|
| 162 |
+
# return "Error! Empty file!"
|
| 163 |
+
# if model_link == '' or model_name_textbox == '' or contact_email == '':
|
| 164 |
+
# return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
|
| 165 |
|
| 166 |
+
# upload_content = input_file
|
| 167 |
+
# submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
|
| 168 |
+
# submission_repo.git_pull()
|
| 169 |
+
# filename = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 170 |
|
| 171 |
+
# now = datetime.datetime.now()
|
| 172 |
+
# update_time = now.strftime("%Y-%m-%d") # Capture update time
|
| 173 |
+
# with open(f'{SUBMISSION_NAME}/{filename}.zip','wb') as f:
|
| 174 |
+
# f.write(input_file)
|
| 175 |
+
# # shutil.copyfile(CSV_DIR, os.path.join(SUBMISSION_NAME, f"{input_file}"))
|
| 176 |
+
|
| 177 |
+
# csv_data = pd.read_csv(I2V_DIR)
|
| 178 |
+
|
| 179 |
+
# if revision_name_textbox == '':
|
| 180 |
+
# col = csv_data.shape[0]
|
| 181 |
+
# model_name = model_name_textbox.replace(',',' ')
|
| 182 |
+
# else:
|
| 183 |
+
# model_name = revision_name_textbox.replace(',',' ')
|
| 184 |
+
# model_name_list = csv_data['Model Name (clickable)']
|
| 185 |
+
# name_list = [name.split(']')[0][1:] for name in model_name_list]
|
| 186 |
+
# if revision_name_textbox not in name_list:
|
| 187 |
+
# col = csv_data.shape[0]
|
| 188 |
+
# else:
|
| 189 |
+
# col = name_list.index(revision_name_textbox)
|
| 190 |
+
# if model_link == '':
|
| 191 |
+
# model_name = model_name # no url
|
| 192 |
+
# else:
|
| 193 |
+
# model_name = '[' + model_name + '](' + model_link + ')'
|
| 194 |
+
|
| 195 |
+
# os.makedirs(filename, exist_ok=True)
|
| 196 |
+
# with zipfile.ZipFile(io.BytesIO(input_file), 'r') as zip_ref:
|
| 197 |
+
# zip_ref.extractall(filename)
|
| 198 |
+
|
| 199 |
+
# upload_data = {}
|
| 200 |
+
# for file in os.listdir(filename):
|
| 201 |
+
# if file.startswith('.') or file.startswith('__'):
|
| 202 |
+
# print(f"Skip the file: {file}")
|
| 203 |
+
# continue
|
| 204 |
+
# cur_file = os.path.join(filename, file)
|
| 205 |
+
# if os.path.isdir(cur_file):
|
| 206 |
+
# for subfile in os.listdir(cur_file):
|
| 207 |
+
# if subfile.endswith(".json"):
|
| 208 |
+
# with open(os.path.join(cur_file, subfile)) as ff:
|
| 209 |
+
# cur_json = json.load(ff)
|
| 210 |
+
# print(file, type(cur_json))
|
| 211 |
+
# if isinstance(cur_json, dict):
|
| 212 |
+
# print(cur_json.keys())
|
| 213 |
+
# for key in cur_json:
|
| 214 |
+
# upload_data[key] = cur_json[key][0]
|
| 215 |
+
# print(f"{key}:{cur_json[key][0]}")
|
| 216 |
+
# elif cur_file.endswith('json'):
|
| 217 |
+
# with open(cur_file) as ff:
|
| 218 |
+
# cur_json = json.load(ff)
|
| 219 |
+
# print(file, type(cur_json))
|
| 220 |
+
# if isinstance(cur_json, dict):
|
| 221 |
+
# print(cur_json.keys())
|
| 222 |
+
# for key in cur_json:
|
| 223 |
+
# upload_data[key] = cur_json[key][0]
|
| 224 |
+
# print(f"{key}:{cur_json[key][0]}")
|
| 225 |
+
# # add new data
|
| 226 |
+
# new_data = [model_name]
|
| 227 |
+
# print('upload_data:', upload_data)
|
| 228 |
+
# I2V_HEAD= ["Video-Text Camera Motion",
|
| 229 |
+
# "Video-Image Subject Consistency",
|
| 230 |
+
# "Video-Image Background Consistency",
|
| 231 |
+
# "Subject Consistency",
|
| 232 |
+
# "Background Consistency",
|
| 233 |
+
# "Temporal Flickering",
|
| 234 |
+
# "Motion Smoothness",
|
| 235 |
+
# "Dynamic Degree",
|
| 236 |
+
# "Aesthetic Quality",
|
| 237 |
+
# "Imaging Quality" ]
|
| 238 |
+
# for key in I2V_HEAD :
|
| 239 |
+
# sub_key = COLNAME2KEY[key]
|
| 240 |
+
# if sub_key in upload_data:
|
| 241 |
+
# new_data.append(upload_data[sub_key])
|
| 242 |
+
# else:
|
| 243 |
+
# new_data.append(0)
|
| 244 |
+
# if team_name =='' or 'vbench' in team_name.lower():
|
| 245 |
+
# new_data.append("User Upload")
|
| 246 |
+
# else:
|
| 247 |
+
# new_data.append(team_name)
|
| 248 |
+
|
| 249 |
+
# new_data.append(contact_email.replace(',',' and ')) # Add contact email [private]
|
| 250 |
+
# new_data.append(update_time) # Add the update time
|
| 251 |
+
# new_data.append(team_name)
|
| 252 |
+
# new_data.append(access_type)
|
| 253 |
+
|
| 254 |
+
# csv_data.loc[col] = new_data
|
| 255 |
+
# csv_data = csv_data.to_csv(I2V_DIR , index=False)
|
| 256 |
+
# with open(INFO_DIR,'a') as f:
|
| 257 |
+
# 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")
|
| 258 |
+
# submission_repo.push_to_hub()
|
| 259 |
+
# print("success update", model_name)
|
| 260 |
+
# return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
| 261 |
|
| 262 |
def get_normalized_df(df):
|
| 263 |
# final_score = df.drop('name', axis=1).sum(axis=1)
|