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.") | |