daiqi commited on
Commit
8a6f9bb
·
verified ·
1 Parent(s): e9a96db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -88
app.py CHANGED
@@ -153,10 +153,12 @@ with demo:
153
 
154
  link_input = gr.Textbox(label="Link (str)", placeholder="请输入链接")
155
 
156
- submit_button = gr.Button("Submit One Eval")
157
- submit_all_button = gr.Button("Submit All")
 
 
158
 
159
- submission_result = gr.Markdown("## Submited results")
160
 
161
  def submit_eval(score, name, base_model, env, target_research, subset, link):
162
  # 处理单条数据提交
@@ -171,13 +173,15 @@ with demo:
171
  "State": "Checking"
172
  }
173
  # 将结果添加到全局变量中
 
174
  all_submissions.append(result)
175
  # 更新页面展示
176
- display_text = "\n".join([json.dumps(submission) for submission in all_submissions])
177
- return display_text
178
 
179
  def submit_all():
180
  # 将所有结果一次性上传
 
181
  out_path = "test-output.json"
182
  with open(out_path, "w") as f:
183
  f.write(json.dumps(all_submissions))
@@ -191,8 +195,13 @@ with demo:
191
  commit_message=f"Add submissions to checking queue",
192
  )
193
  all_submissions = []
194
- return "All submissions uploaded successfully!"
195
-
 
 
 
 
 
196
  # 单条数据提交按钮点击事件
197
  submit_button.click(
198
  submit_eval,
@@ -205,88 +214,13 @@ with demo:
205
  submit_all,
206
  inputs=[],
207
  outputs=submission_result
208
- )
209
- # with gr.Column():
210
- # with gr.Accordion(
211
- # f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
212
- # open=False,
213
- # ):
214
- # with gr.Row():
215
- # finished_eval_table = gr.components.Dataframe(
216
- # value=finished_eval_queue_df,
217
- # headers=EVAL_COLS,
218
- # datatype=EVAL_TYPES,
219
- # row_count=5,
220
- # )
221
- # with gr.Accordion(
222
- # f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
223
- # open=False,
224
- # ):
225
- # with gr.Row():
226
- # running_eval_table = gr.components.Dataframe(
227
- # value=running_eval_queue_df,
228
- # headers=EVAL_COLS,
229
- # datatype=EVAL_TYPES,
230
- # row_count=5,
231
- # )
232
-
233
- # with gr.Accordion(
234
- # f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
235
- # open=False,
236
- # ):
237
- # with gr.Row():
238
- # pending_eval_table = gr.components.Dataframe(
239
- # value=pending_eval_queue_df,
240
- # headers=EVAL_COLS,
241
- # datatype=EVAL_TYPES,
242
- # row_count=5,
243
- # )
244
- # with gr.Row():
245
- # gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
246
-
247
- # with gr.Row():
248
- # with gr.Column():
249
- # model_name_textbox = gr.Textbox(label="Model name")
250
- # revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
251
- # model_type = gr.Dropdown(
252
- # choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
253
- # label="Model type",
254
- # multiselect=False,
255
- # value=None,
256
- # interactive=True,
257
- # )
258
-
259
- # with gr.Column():
260
- # precision = gr.Dropdown(
261
- # choices=[i.value.name for i in Precision if i != Precision.Unknown],
262
- # label="Precision",
263
- # multiselect=False,
264
- # value="float16",
265
- # interactive=True,
266
- # )
267
- # weight_type = gr.Dropdown(
268
- # choices=[i.value.name for i in WeightType],
269
- # label="Weights type",
270
- # multiselect=False,
271
- # value="Original",
272
- # interactive=True,
273
- # )
274
- # base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
275
 
276
- # submit_button = gr.Button("Submit Eval")
277
- # submission_result = gr.Markdown()
278
- # submit_button.click(
279
- # add_new_eval,
280
- # [
281
- # model_name_textbox,
282
- # base_model_name_textbox,
283
- # revision_name_textbox,
284
- # precision,
285
- # weight_type,
286
- # model_type,
287
- # ],
288
- # submission_result,
289
- # )
290
 
291
  with gr.Row():
292
  with gr.Accordion("📙 Citation", open=False):
 
153
 
154
  link_input = gr.Textbox(label="Link (str)", placeholder="请输入链接")
155
 
156
+ submit_button = gr.Button("Upload One Eval")
157
+ with gr.Row():
158
+ clear_button = gr.Button("Clear Uploads")
159
+ submit_all_button = gr.Button("Submit All")
160
 
161
+ submission_result = gr.Markdown("## Uploaded results")
162
 
163
  def submit_eval(score, name, base_model, env, target_research, subset, link):
164
  # 处理单条数据提交
 
173
  "State": "Checking"
174
  }
175
  # 将结果添加到全局变量中
176
+ global all_submissions
177
  all_submissions.append(result)
178
  # 更新页面展示
179
+ display_text = "\n".join([json.dumps(submission) for submission in all_submissions])
180
+ return gr.Markdown("## Uploaded results\n\n"+display_text)
181
 
182
  def submit_all():
183
  # 将所有结果一次性上传
184
+ global all_submissions
185
  out_path = "test-output.json"
186
  with open(out_path, "w") as f:
187
  f.write(json.dumps(all_submissions))
 
195
  commit_message=f"Add submissions to checking queue",
196
  )
197
  all_submissions = []
198
+ return gr.Markdown("## All submissions uploaded successfully! \nThis will re-start the space...")
199
+
200
+ def clear():
201
+ global all_submissions
202
+ all_submissions = []
203
+ return gr.Markdown("## Uploaded results")
204
+
205
  # 单条数据提交按钮点击事件
206
  submit_button.click(
207
  submit_eval,
 
214
  submit_all,
215
  inputs=[],
216
  outputs=submission_result
217
+ )
218
+ clear_button.click(
219
+ clear,
220
+ [],
221
+ submission_result
222
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
  with gr.Row():
226
  with gr.Accordion("📙 Citation", open=False):