requirements
Browse files- app.py +16 -2
- requirements.txt +3 -0
app.py
CHANGED
|
@@ -1,4 +1,18 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 5 |
+
|
| 6 |
+
st.title("Sentiment Analysis with HuggingFace Spaces")
|
| 7 |
+
st.write("Enter a sentence to analyze its sentiment:")
|
| 8 |
+
user_input = st.text_input("")
|
| 9 |
+
if user_input:
|
| 10 |
+
result = sentiment_pipeline(user_input)
|
| 11 |
+
sentiment = result[0]["label"]
|
| 12 |
+
confidence = result[0]["score"]
|
| 13 |
+
|
| 14 |
+
st.write(f"Sentiment: {sentiment}")
|
| 15 |
+
st.write(f"Confidence: {confidence:.2f}")
|
| 16 |
+
|
| 17 |
+
# x = st.slider('Select a value')
|
| 18 |
+
# st.write(x, 'squared is', x * x)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers
|
| 3 |
+
torch
|