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