added u7 evaluation
Browse files4 unmodified lines56789104 unmodified lines15161718192016 unmodified lines3738394041424344451 unmodified line474849505152535455565797 unmodified lines15515615715815916016116216327 unmodified lines1911921931941951961971981992002012022031 unmodified line2052062072082092102112122132142152162172182192202212222232242252262274 unmodified linesimport reimport pandas as pdfrom huggingface_hub import ModelCarddef pass_emoji(passed):4 unmodified linesreturn passedapi = HfApi()def get_user_models(hf_username, task):16 unmodified linesdataset_specific_models = []if dataset == "":return user_model_idselse:for model in user_model_ids:meta = get_metadata(model)if meta is None:1 unmodified linetry:if meta["datasets"] == [dataset]:dataset_specific_models.append(model)except:continuereturn dataset_specific_modelsdef 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,"best_result": 0,"best_model_id": "","passed_": False27 unmodified linescase "text-to-speech":try:user_tts_models = get_user_models(hf_username, task = "text-to-speech")if user_tts_models:unit["best_result"] = 0unit["best_model_id"] = user_tts_models[0]unit["passed_"] = Trueunit["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 _:print("Unknown task")1 unmodified linedf = pd.DataFrame(results_certification)df = df[['passed', 'unit', 'task', 'baseline_metric', 'best_result', 'best_model_id']]return dfwith 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)""")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))check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)demo.launch()4 unmodified lines5678910114 unmodified lines16171819202122232416 unmodified lines4142434445464748491 unmodified line5152535455565758596097 unmodified lines15815916016116216316416516627 unmodified lines1941951961971981992002012022032042052062072082092102112121 unmodified line2142152162172182192202212222232242252262272282292302312322332342352362372384 unmodified linesimport reimport pandas as pdfrom huggingface_hub import ModelCardimport osdef pass_emoji(passed):4 unmodified linesreturn passedapi = 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 linesdataset_specific_models = []if dataset == "":return user_model_idselse:for model in user_model_ids:meta = get_metadata(model)if meta is None:1 unmodified linetry:if meta["datasets"] == [dataset]:dataset_specific_models.append(model)except:continuereturn dataset_specific_modelsdef calculate_best_result(user_models, task):"""Calculate the best results of a unit for a given task97 unmodified lines"passed_": False},{"unit": "Unit 7: Audio applications","task": "demo","baseline_metric": 0,"best_result": 0,"best_model_id": "","passed_": False27 unmodified linescase "text-to-speech":try:user_tts_models = get_user_models(hf_username, task = "text-to-speech")if user_tts_models:unit["best_result"] = 0unit["best_model_id"] = user_tts_models[0]unit["passed_"] = Trueunit["passed"] = pass_emoji(unit["passed_"])except: print("Either no relevant models found, or no metrics in the model card for automatic speech recognition")case "demo":u7_users = pd.read_csv(U7_USERNAMES)if hf_username in u7_users['username']:unit["best_result"] = 0unit["best_model_id"] = "Demo check passed, no model id"unit["passed_"] = Trueunit["passed"] = pass_emoji(unit["passed_"])case _:print("Unknown task")1 unmodified linedf = pd.DataFrame(results_certification)df = df[['passed', 'unit', 'task', 'baseline_metric', 'best_result', 'best_model_id']]return dfwith 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**.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-assessmentMake 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))check_progress_button.click(fn=certification, inputs=hf_username, outputs=output)demo.launch()
app.py+28-17