Spaces:
Build error
Build error
Download app.py from ywanguj/classification1: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/spaces/ywanguj/classification1/resolve/main/app.py
- Command line
-
hf download hf://spaces/ywanguj/classification1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ywanguj/classification1/resolve/main/app.py
688 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| classifier = pipeline("text-classification", model="isom5240/bert-base-uncased-emotion") | |
| st.title("Text Classification for you") | |
| st.write("Classification for 6 emotions: sadness, joy, love, anger, fear, surprice") | |
| text = st.text_area("Enter the text to classify", "") | |
| if st.button("Classify"): | |
| results = classifier(text)[0] | |
| max_score = float("-inf") | |
| max_label = "" | |
| for result in results: | |
| if result['score'] > max_score: | |
| max_score = result['score'] | |
| max_label = result['label'] | |
| st.write("Text:", text) | |
| st.write("Label:", max_label) | |
| st.write("Score:", max_score) | |