MariaK commited on
Commit
8685a73
β€’
1 Parent(s): b3439f4

added u7 evaluation

Browse files
Files changed (1) hide show
  1. app.py +28 -17
app.py CHANGED
@@ -5,6 +5,7 @@ import requests
5
  import re
6
  import pandas as pd
7
  from huggingface_hub import ModelCard
 
8
 
9
 
10
  def pass_emoji(passed):
@@ -15,6 +16,9 @@ def pass_emoji(passed):
15
  return passed
16
 
17
  api = HfApi()
 
 
 
18
 
19
 
20
  def get_user_models(hf_username, task):
@@ -37,9 +41,9 @@ def get_user_models(hf_username, task):
37
 
38
  dataset_specific_models = []
39
 
40
- if dataset == "":
41
  return user_model_ids
42
- else:
43
  for model in user_model_ids:
44
  meta = get_metadata(model)
45
  if meta is None:
@@ -47,11 +51,10 @@ def get_user_models(hf_username, task):
47
  try:
48
  if meta["datasets"] == [dataset]:
49
  dataset_specific_models.append(model)
50
- except:
51
  continue
52
  return dataset_specific_models
53
 
54
-
55
  def calculate_best_result(user_models, task):
56
  """
57
  Calculate the best results of a unit for a given task
@@ -155,9 +158,9 @@ def certification(hf_username):
155
  "passed_": False
156
  },
157
  {
158
- "unit": "Unit 7: TBD",
159
- "task": "TBD",
160
- "baseline_metric": 0.99,
161
  "best_result": 0,
162
  "best_model_id": "",
163
  "passed_": False
@@ -191,13 +194,19 @@ def certification(hf_username):
191
  case "text-to-speech":
192
  try:
193
  user_tts_models = get_user_models(hf_username, task = "text-to-speech")
194
- if user_tts_models:
195
  unit["best_result"] = 0
196
  unit["best_model_id"] = user_tts_models[0]
197
  unit["passed_"] = True
198
  unit["passed"] = pass_emoji(unit["passed_"])
199
  except: print("Either no relevant models found, or no metrics in the model card for automatic speech recognition")
200
- print("Evaluation for this unit is work in progress")
 
 
 
 
 
 
201
  case _:
202
  print("Unknown task")
203
 
@@ -205,23 +214,25 @@ def certification(hf_username):
205
 
206
  df = pd.DataFrame(results_certification)
207
  df = df[['passed', 'unit', 'task', 'baseline_metric', 'best_result', 'best_model_id']]
208
- return df
209
-
210
  with gr.Blocks() as demo:
211
  gr.Markdown(f"""
212
  # πŸ† Check your progress in the Audio Course πŸ†
213
-
214
  - To get a certificate of completion, you must **pass 3 out of 4 assignments before July 31st 2023**.
215
  - To get an honors certificate, you must **pass 4 out of 4 assignments before July 31st 2023**.
216
 
217
- To pass an assignment, your model's metric should be equal to or higher than the baseline metric.
218
-
219
- Make sure that you have uploaded your model(s) to Hub and type your Hugging Face Username here to check if you pass (in my case MariaK)
 
 
220
  """)
221
-
222
  hf_username = gr.Textbox(placeholder="MariaK", label="Your Hugging Face Username")
223
  check_progress_button = gr.Button(value="Check my progress")
224
- output = gr.components.Dataframe(value=certification(hf_username))
225
  check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)
226
 
227
  demo.launch()
 
5
  import re
6
  import pandas as pd
7
  from huggingface_hub import ModelCard
8
+ import os
9
 
10
 
11
  def pass_emoji(passed):
 
16
  return passed
17
 
18
  api = HfApi()
19
+ USERNAMES_DATASET_ID = "huggingface-course/audio-course-u7-hands-on"
20
+ HF_TOKEN = os.environ.get("HF_TOKEN")
21
+ U7_USERNAMES = hf_hub_download(USERNAMES_DATASET_ID, repo_type = "dataset", filename="usernames.csv", token=HF_TOKEN)
22
 
23
 
24
  def get_user_models(hf_username, task):
 
41
 
42
  dataset_specific_models = []
43
 
44
+ if dataset == "":
45
  return user_model_ids
46
+ else:
47
  for model in user_model_ids:
48
  meta = get_metadata(model)
49
  if meta is None:
 
51
  try:
52
  if meta["datasets"] == [dataset]:
53
  dataset_specific_models.append(model)
54
+ except:
55
  continue
56
  return dataset_specific_models
57
 
 
58
  def calculate_best_result(user_models, task):
59
  """
60
  Calculate the best results of a unit for a given task
 
158
  "passed_": False
159
  },
160
  {
161
+ "unit": "Unit 7: Audio applications",
162
+ "task": "demo",
163
+ "baseline_metric": 0,
164
  "best_result": 0,
165
  "best_model_id": "",
166
  "passed_": False
 
194
  case "text-to-speech":
195
  try:
196
  user_tts_models = get_user_models(hf_username, task = "text-to-speech")
197
+ if user_tts_models:
198
  unit["best_result"] = 0
199
  unit["best_model_id"] = user_tts_models[0]
200
  unit["passed_"] = True
201
  unit["passed"] = pass_emoji(unit["passed_"])
202
  except: print("Either no relevant models found, or no metrics in the model card for automatic speech recognition")
203
+ case "demo":
204
+ u7_users = pd.read_csv(U7_USERNAMES)
205
+ if hf_username in u7_users['username']:
206
+ unit["best_result"] = 0
207
+ unit["best_model_id"] = "Demo check passed, no model id"
208
+ unit["passed_"] = True
209
+ unit["passed"] = pass_emoji(unit["passed_"])
210
  case _:
211
  print("Unknown task")
212
 
 
214
 
215
  df = pd.DataFrame(results_certification)
216
  df = df[['passed', 'unit', 'task', 'baseline_metric', 'best_result', 'best_model_id']]
217
+ return df
218
+
219
  with gr.Blocks() as demo:
220
  gr.Markdown(f"""
221
  # πŸ† Check your progress in the Audio Course πŸ†
222
+
223
  - To get a certificate of completion, you must **pass 3 out of 4 assignments before July 31st 2023**.
224
  - To get an honors certificate, you must **pass 4 out of 4 assignments before July 31st 2023**.
225
 
226
+ For the assignments where you have to train a model, your model's metric should be equal to or better than the baseline metric.
227
+ For the Unit 7 assignment, first, check your demo with Unit 7 assessment Space: https://huggingface.co/spaces/huggingface-course/audio-course-u7-assessment
228
+
229
+ Make sure that you have uploaded your model(s) to Hub, and that your Unit 7 demo is public.
230
+ To check your progress, type your Hugging Face Username here (in my case MariaK)
231
  """)
232
+
233
  hf_username = gr.Textbox(placeholder="MariaK", label="Your Hugging Face Username")
234
  check_progress_button = gr.Button(value="Check my progress")
235
+ output = gr.components.Dataframe(value=certification(hf_username))
236
  check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)
237
 
238
  demo.launch()