Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Create a pipeline for text classification
|
| 5 |
+
pipe = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
|
| 6 |
+
|
| 7 |
+
# Streamlit app structure
|
| 8 |
+
st.title("Text Classification App")
|
| 9 |
+
st.write("Enter some text and the model will predict its sentiment:")
|
| 10 |
+
|
| 11 |
+
# Input text from the user
|
| 12 |
+
user_input = st.text_input("Input Text:")
|
| 13 |
+
|
| 14 |
+
# When the button is clicked, classify the input
|
| 15 |
+
if st.button("Classify"):
|
| 16 |
+
if user_input:
|
| 17 |
+
result = pipe(user_input)
|
| 18 |
+
st.write(result)
|
| 19 |
+
else:
|
| 20 |
+
st.write("Please enter some text.")
|