Instructions to use haripriyaram/Text-emotion-Recognizer-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- fastai
How to use haripriyaram/Text-emotion-Recognizer-Model with fastai:
from huggingface_hub import from_pretrained_fastai learn = from_pretrained_fastai("haripriyaram/Text-emotion-Recognizer-Model") - Notebooks
- Google Colab
- Kaggle
File size: 955 Bytes
c3e673c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import gradio as gr
from fastai.text.all import load_learner
# Load FastAI model once
learn = load_learner("emotion_classifier.pkl")
learn.push_to_hub("fastai-emotion-classifier")
learn = load_learner("https://huggingface.co/haripriyaram/fastai-emotion-classifier/resolve/main/export.pkl")
# Prediction function
def predict_emotion(text):
pred_label, _, probs = learn.predict(text)
probs_dict = {label: float(prob) for label, prob in zip(learn.dls.vocab, probs)}
return pred_label, probs_dict
# Gradio UI
iface = gr.Interface(
fn=predict_emotion,
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence..."),
outputs=[
gr.Label(label="Predicted Emotion"),
gr.JSON(label="Confidence Scores")
],
title="🎭 Emotion Classifier (FastAI)",
description="Enter a sentence and the model will predict the corresponding emotion.",
allow_flagging="never"
)
if __name__ == "__main__":
iface.launch()
|