fitsblb commited on
Commit
e9aa866
·
verified ·
1 Parent(s): f49954c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment pipeline
5
+ sentiment_pipeline = pipeline("sentiment-analysis", model="fitsblb/YelpReviewsAnalyzer")
6
+
7
+ def map_sentiment_label(label):
8
+ return {
9
+ "LABEL_0": "❌ Negative",
10
+ "LABEL_1": "⚖️ Neutral",
11
+ "LABEL_2": "✅ Positive"
12
+ }.get(label, "🤷 Unknown")
13
+
14
+ st.set_page_config(page_title="Yelp Sentiment Analyzer", layout="centered")
15
+ st.title("🍽️ Yelp Sentiment Analyzer")
16
+ st.markdown("Enter a restaurant review and see the model's sentiment prediction:")
17
+
18
+ example = "The food was amazing but the wait was long."
19
+ review = st.text_area("Review", example)
20
+
21
+ if st.button("Analyze Sentiment"):
22
+ if review.strip() == "":
23
+ st.warning("Please enter a review.")
24
+ else:
25
+ with st.spinner("Analyzing..."):
26
+ result = sentiment_pipeline(review)[0]
27
+ label = result["label"]
28
+ confidence = round(result["score"], 3)
29
+ st.success(f"**Sentiment:** {map_sentiment_label(label)}\n\n**Confidence:** {confidence}")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ transformers
3
+ torch