joulammous commited on
Commit
cb50d0f
·
unverified ·
1 Parent(s): c812f64

Add files via upload

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Libraries
3
+
4
+ import streamlit as st
5
+ import tensorflow as tf
6
+ from transformers import pipeline
7
+
8
+ # Milestone 2
9
+
10
+ sentiment_pipeline = pipeline("sentiment-analysis", model = "siebert/sentiment-roberta-large-english")
11
+
12
+ st.title('Sentiment Analysis with Hugging Face')
13
+ st.write('Enter some text and we will predict its sentiment!')
14
+
15
+ # Add a text input box for the user to enter text
16
+ text_input = st.text_input('Enter text here')
17
+
18
+ # When the user submits text, run the sentiment analysis model on it
19
+ if st.button('Submit'):
20
+ # Predict the sentiment of the text using the Hugging Face model
21
+ sentiment = sentiment_pipeline(text_input)[0]['label']
22
+
23
+ # Display the sentiment prediction to the user
24
+ st.write(f'Sentiment: {sentiment}')