cychristophercyc commited on
Commit
f94dcf8
1 Parent(s): 2b40697

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ def main():
5
+ sentiment_pipeline = pipeline(model="dstefa/roberta-base_topic_classification_nyt_news")
6
+
7
+ st.title("Sentiment Analysis with HuggingFace Spaces")
8
+ st.write("Enter a sentence to analyze its sentiment:")
9
+
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
+
16
+ st.write(f"Sentiment: {sentiment}")
17
+ st.write(f"Confidence: {confidence:.2f}")
18
+
19
+ if __name__ == "__main__":
20
+ main()