CoolFace
Apppublic

Karthikbt/Emotion_Classification_Model

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py21 linesDownload Raw Back to root
1import gradio as gr2import joblib3from train_classifier import vectorizer, clf, label_map4from data.preprocess import clean_text5 6def predict_emotion(text):7    text_clean = clean_text(text)8    X_vec = vectorizer.transform([text_clean])9    pred = clf.predict(X_vec)[0]10    return label_map[int(pred)]11 12iface = gr.Interface(13    fn=predict_emotion,14    inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),15    outputs="text",16    title="Emotion Classifier",17    description="Enter a sentence and the model will predict the emotion."18)19 20if __name__ == "__main__":21    iface.launch(share=True)