engrharis commited on
Commit
27b2983
·
verified ·
1 Parent(s): 2e1b615

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Title and Introduction
5
+ st.title("Sentiment Analysis App")
6
+ st.write("""
7
+ This app uses a Hugging Face model to analyze the sentiment of your text.
8
+ Type something below and click "Analyze Sentiment" to get started!
9
+ """)
10
+
11
+ # Text Input
12
+ user_input = st.text_area("Enter your text here:")
13
+
14
+ # Perform Sentiment Analysis
15
+ if st.button("Analyze Sentiment"):
16
+ if user_input.strip() == "":
17
+ st.warning("Please enter some text to analyze.")
18
+ else:
19
+ # Load the sentiment analysis pipeline
20
+ sentiment_pipeline = pipeline("sentiment-analysis")
21
+ result = sentiment_pipeline(user_input)
22
+
23
+ # Extract and display results
24
+ sentiment = result[0]['label']
25
+ confidence = result[0]['score']
26
+ st.write(f"**Sentiment:** {sentiment}")
27
+ st.write(f"**Confidence Score:** {confidence:.2f}")