Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| def load_pipe(): | |
| pipe = pipeline(task="text-classification", model="cnicu/tweet_emotions_classifier") | |
| return pipe | |
| def classify_emotion(text: str, pipe: pipeline) -> str: | |
| prediction = pipe(text) | |
| return prediction | |
| st.title("Tweet emotions classification") | |
| text = st.text_area("Tweet to classify", label_visibility='hidden') | |
| if st.button("Classify tweet", disabled= text == ''): | |
| with st.spinner("In progress..."): | |
| prediction = classify_emotion(text, load_pipe()) | |
| st.success(f"Tweet's emotion: **{prediction[0]['label']}**") |