Spaces:
Sleeping
Sleeping
| from huggingface_hub import hf_hub_download | |
| from fastai.text.all import * | |
| import gradio as gr | |
| model_path = hf_hub_download( | |
| repo_id="Blevins05/emotions_classifier", | |
| filename="model.pkl" | |
| ) | |
| learn = load_learner(model_path) | |
| def predict(text): | |
| pred_class, pred_idx, probs = learn.predict(text) | |
| labels = learn.dls.categorize.vocab | |
| return {str(label): float(prob) for label, prob in zip(labels, probs)} | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(placeholder="Write a sentence in English..."), | |
| outputs=gr.Label(num_top_classes=6), | |
| title="Emotion Classifier" | |
| ) | |
| demo.launch() |