added u7 evaluation
Browse files4 unmodified lines5678910114 unmodified lines16171819202122232416 unmodified lines41424340444542464748491 unmodified line51525350545556575458596097 unmodified lines15815916015815916016116216316416516627 unmodified lines1941951961941971981992002012022002032042052062072082092102112121 unmodified line2142152162082092172182192202212132222232242252172182192262272282292302312212322332342242352362372384 unmodified linesimport reimport pandas as pdfrom huggingface_hub import ModelCardimport os
def pass_emoji(passed):4 unmodified lines return passed
api = HfApi()USERNAMES_DATASET_ID = "huggingface-course/audio-course-u7-hands-on"HF_TOKEN = os.environ.get("HF_TOKEN")U7_USERNAMES = hf_hub_download(USERNAMES_DATASET_ID, repo_type = "dataset", filename="usernames.csv", token=HF_TOKEN)
def get_user_models(hf_username, task):16 unmodified lines
dataset_specific_models = []
if dataset == "": if dataset == "": return user_model_ids else: else: for model in user_model_ids: meta = get_metadata(model) if meta is None:1 unmodified line try: if meta["datasets"] == [dataset]: dataset_specific_models.append(model) except: except: continue return dataset_specific_models
def calculate_best_result(user_models, task): """ Calculate the best results of a unit for a given task97 unmodified lines "passed_": False }, { "unit": "Unit 7: TBD", "task": "TBD", "baseline_metric": 0.99, "unit": "Unit 7: Audio applications", "task": "demo", "baseline_metric": 0, "best_result": 0, "best_model_id": "", "passed_": False27 unmodified lines case "text-to-speech": try: user_tts_models = get_user_models(hf_username, task = "text-to-speech") if user_tts_models: if user_tts_models: unit["best_result"] = 0 unit["best_model_id"] = user_tts_models[0] unit["passed_"] = True unit["passed"] = pass_emoji(unit["passed_"]) except: print("Either no relevant models found, or no metrics in the model card for automatic speech recognition") print("Evaluation for this unit is work in progress") case "demo": u7_users = pd.read_csv(U7_USERNAMES) if hf_username in u7_users['username']: unit["best_result"] = 0 unit["best_model_id"] = "Demo check passed, no model id" unit["passed_"] = True unit["passed"] = pass_emoji(unit["passed_"]) case _: print("Unknown task")
1 unmodified line
df = pd.DataFrame(results_certification) df = df[['passed', 'unit', 'task', 'baseline_metric', 'best_result', 'best_model_id']] return df return df
with gr.Blocks() as demo: gr.Markdown(f""" # 🏆 Check your progress in the Audio Course 🏆
- To get a certificate of completion, you must **pass 3 out of 4 assignments before July 31st 2023**. - To get an honors certificate, you must **pass 4 out of 4 assignments before July 31st 2023**.
To pass an assignment, your model's metric should be equal to or higher than the baseline metric. 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) For the assignments where you have to train a model, your model's metric should be equal to or better than the baseline metric. For the Unit 7 assignment, first, check your demo with Unit 7 assessment Space: https://huggingface.co/spaces/huggingface-course/audio-course-u7-assessment
Make sure that you have uploaded your model(s) to Hub, and that your Unit 7 demo is public. To check your progress, type your Hugging Face Username here (in my case MariaK) """)
hf_username = gr.Textbox(placeholder="MariaK", label="Your Hugging Face Username") check_progress_button = gr.Button(value="Check my progress") output = gr.components.Dataframe(value=certification(hf_username)) output = gr.components.Dataframe(value=certification(hf_username)) check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)
demo.launch()app.py+28-17