File size: 620 Bytes
006e7aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.")