Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load a pre-trained sentiment-analysis pipeline
|
5 |
+
classifier = pipeline("sentiment-analysis")
|
6 |
+
|
7 |
+
# Streamlit app
|
8 |
+
st.title("Sentiment Analysis with Hugging Face Transformers")
|
9 |
+
|
10 |
+
st.write("Enter text below to analyze sentiment:")
|
11 |
+
|
12 |
+
# Text input
|
13 |
+
user_input = st.text_area("Text Input", "Enter your text here...")
|
14 |
+
|
15 |
+
if st.button("Analyze"):
|
16 |
+
# Perform sentiment analysis
|
17 |
+
results = classifier(user_input)
|
18 |
+
sentiment = results[0]['label']
|
19 |
+
score = results[0]['score']
|
20 |
+
|
21 |
+
# Display results
|
22 |
+
st.write(f"Sentiment: {sentiment}")
|
23 |
+
st.write(f"Confidence Score: {score:.2f}")
|