ynhe commited on
Commit
0448dbd
1 Parent(s): c7eaeae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -26,10 +26,12 @@ def add_new_eval(
26
  model_name_textbox: str,
27
  revision_name_textbox: str,
28
  model_link: str,
 
29
  ):
30
  if input_file is None:
31
  return "Error! Empty file!"
32
-
 
33
  # upload_data=json.loads(input_file)
34
  upload_content = input_file
35
  submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
@@ -53,7 +55,6 @@ def add_new_eval(
53
  col = csv_data.shape[0]
54
  else:
55
  col = name_list.index(revision_name_textbox)
56
-
57
  if model_link == '':
58
  model_name = model_name # no url
59
  else:
@@ -97,18 +98,19 @@ def add_new_eval(
97
  new_data.append(upload_data[key])
98
  else:
99
  new_data.append(0)
100
- new_data.append("User Upload.")
 
101
  csv_data.loc[col] = new_data
102
  csv_data = csv_data.to_csv(CSV_DIR, index=False)
103
  submission_repo.push_to_hub()
104
  print("success update", model_name)
105
- return gr.update(visible=False), gr.update(visible=True)
106
 
107
  def get_normalized_df(df):
108
  # final_score = df.drop('name', axis=1).sum(axis=1)
109
  # df.insert(1, 'Overall Score', final_score)
110
  normalize_df = df.copy().fillna(0.0)
111
- for column in normalize_df.columns[1:-1]:
112
  min_val = NORMALIZE_DIC[column]['Min']
113
  max_val = NORMALIZE_DIC[column]['Max']
114
  normalize_df[column] = (normalize_df[column] - min_val) / (max_val - min_val)
@@ -505,15 +507,18 @@ with block:
505
  with gr.Row():
506
  with gr.Column():
507
  model_name_textbox = gr.Textbox(
508
- label="Model name", placeholder="LaVie"
509
  )
510
  revision_name_textbox = gr.Textbox(
511
- label="Revision Model Name", placeholder="LaVie"
512
  )
513
 
514
  with gr.Column():
515
  model_link = gr.Textbox(
516
- label="Model Link", placeholder="https://huggingface.co/decapoda-research/llama-7b-hf"
 
 
 
517
  )
518
 
519
 
@@ -521,7 +526,8 @@ with block:
521
 
522
  input_file = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
523
  submit_button = gr.Button("Submit Eval")
524
- submit_succ_button = gr.Button("Submit Success! Please press refresh and return to LeaderBoard!", visible=False, interactive=False)
 
525
 
526
 
527
  submission_result = gr.Markdown()
@@ -532,8 +538,9 @@ with block:
532
  model_name_textbox,
533
  revision_name_textbox,
534
  model_link,
 
535
  ],
536
- outputs=[submit_button, submit_succ_button]
537
  )
538
 
539
 
 
26
  model_name_textbox: str,
27
  revision_name_textbox: str,
28
  model_link: str,
29
+ contact_email: str
30
  ):
31
  if input_file is None:
32
  return "Error! Empty file!"
33
+ if model_link == '' or model_name == '' or contact_email == '':
34
+ return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
35
  # upload_data=json.loads(input_file)
36
  upload_content = input_file
37
  submission_repo = Repository(local_dir=SUBMISSION_NAME, clone_from=SUBMISSION_URL, use_auth_token=HF_TOKEN, repo_type="dataset")
 
55
  col = csv_data.shape[0]
56
  else:
57
  col = name_list.index(revision_name_textbox)
 
58
  if model_link == '':
59
  model_name = model_name # no url
60
  else:
 
98
  new_data.append(upload_data[key])
99
  else:
100
  new_data.append(0)
101
+ new_data.append("User Upload")
102
+ new_data.append(contact_email)
103
  csv_data.loc[col] = new_data
104
  csv_data = csv_data.to_csv(CSV_DIR, index=False)
105
  submission_repo.push_to_hub()
106
  print("success update", model_name)
107
+ return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
108
 
109
  def get_normalized_df(df):
110
  # final_score = df.drop('name', axis=1).sum(axis=1)
111
  # df.insert(1, 'Overall Score', final_score)
112
  normalize_df = df.copy().fillna(0.0)
113
+ for column in normalize_df.columns[1:-2]:
114
  min_val = NORMALIZE_DIC[column]['Min']
115
  max_val = NORMALIZE_DIC[column]['Max']
116
  normalize_df[column] = (normalize_df[column] - min_val) / (max_val - min_val)
 
507
  with gr.Row():
508
  with gr.Column():
509
  model_name_textbox = gr.Textbox(
510
+ label="**Model name**", placeholder="Required field"
511
  )
512
  revision_name_textbox = gr.Textbox(
513
+ label="Revision Model Name(Optional)", placeholder="LaVie"
514
  )
515
 
516
  with gr.Column():
517
  model_link = gr.Textbox(
518
+ label="**Project Page/Paper Link**", placeholder="Required field"
519
+ )
520
+ contact_email = gr.Textbox(
521
+ label="E-Mail(**Will not be displayed**)", placeholder="Required field"
522
  )
523
 
524
 
 
526
 
527
  input_file = gr.components.File(label = "Click to Upload a ZIP File", file_count="single", type='binary')
528
  submit_button = gr.Button("Submit Eval")
529
+ submit_succ_button = gr.Markdown("Submit Success! Please press refresh and return to LeaderBoard!", visible=False)
530
+ 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)
531
 
532
 
533
  submission_result = gr.Markdown()
 
538
  model_name_textbox,
539
  revision_name_textbox,
540
  model_link,
541
+ contact_email
542
  ],
543
+ outputs=[submit_button, submit_succ_button, fail_textbox]
544
  )
545
 
546