madani commited on
Commit
718c1da
1 Parent(s): 51d5233

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -2,12 +2,15 @@ import streamlit as st
2
  from transformers import pipeline
3
 
4
  # Create a Streamlit app
5
- st.title("BERT Text Classification : sentiment analysis")
6
 
7
  # Get user input
8
  text = st.text_input("Enter some text to classify:")
9
 
10
- classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
 
11
 
12
- if st.button('Click me'):
13
- st.write(classifier(text)[0]['label'],' avec un score ', classifier(text)[0]['score'])
 
 
 
2
  from transformers import pipeline
3
 
4
  # Create a Streamlit app
5
+ st.title("Text Classification with Hugginface: sentiment analysis case")
6
 
7
  # Get user input
8
  text = st.text_input("Enter some text to classify:")
9
 
10
+ #pipeline for sentiment analysis
11
+ sentiment = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
12
 
13
+ #Print the sentiment and the corresponding score when the button is clicked
14
+ if st.button('Click to get the sentiment'):
15
+ output = sentiment(text)
16
+ st.write(output[0]['label'],' avec un score ', output[0]['score'])