SHAIKT07 commited on
Commit
2e32991
·
verified ·
1 Parent(s): 35d27bf

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis pipeline
5
+ @st.cache_resource
6
+ def load_pipeline():
7
+ return pipeline("sentiment-analysis", framework="pt")
8
+
9
+ sentiment_analyzer = load_pipeline()
10
+
11
+ # Streamlit app title
12
+ st.title("Sentiment Analysis App")
13
+ st.subheader("Analyze the sentiment of your text statements")
14
+
15
+ # Text input from the user
16
+ text = st.text_area("Enter a statement for sentiment analysis", height=150)
17
+
18
+
19
+ # Analyze sentiment when the button is clicked
20
+ if st.button("Analyze Sentiment"):
21
+ if text.strip():
22
+ result = sentiment_analyzer(text)[0]
23
+ sentiment = result['label']
24
+ confidence = result['score']
25
+
26
+ # Display the results
27
+ st.write("### Results:")
28
+ st.write(f"**Sentiment**: {sentiment}")
29
+ st.write(f"**Confidence**: {confidence:.2f}")
30
+ else:
31
+ st.warning("Please enter a valid statement.")
32
+
33
+
34
+ # Footer
35
+ st.markdown("---")
36
+ st.markdown("Powered by [Hugging Face](https://huggingface.co/) | Developed with ❤️ by [Shaik](https://www.linkedin.com/in/shaik-hidaythulla/)")
37
+
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ transformers
5
+ torch
6
+ torchvision
7
+ tensorflow