Download app.py from abdullahzunorain/Text_Classification_App: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/abdullahzunorain/Text_Classification_App/resolve/main/app.py
- Command line
-
hf download hf://spaces/abdullahzunorain/Text_Classification_App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/abdullahzunorain/Text_Classification_App/resolve/main/app.py
620 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| # Create a pipeline for text classification | |
| pipe = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english") | |
| # Streamlit app structure | |
| st.title("Text Classification App") | |
| st.write("Enter some text and the model will predict its sentiment:") | |
| # Input text from the user | |
| user_input = st.text_input("Input Text:") | |
| # When the button is clicked, classify the input | |
| if st.button("Classify"): | |
| if user_input: | |
| result = pipe(user_input) | |
| st.write(result) | |
| else: | |
| st.write("Please enter some text.") | |