Jainesh212 commited on
Commit
214f718
1 Parent(s): ede77af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,19 +4,19 @@ import matplotlib.pyplot as plt
4
  import seaborn as sns
5
  import transformers
6
 
7
- # Define sentiment analysis models
8
  models = {
9
  "DistilBERT": transformers.pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english"),
10
  "RoBERTa": transformers.pipeline("sentiment-analysis", model="roberta-base-openai-detector"),
11
  }
12
 
13
- # Define function to analyze sentiment using selected model
14
  def analyze_sentiment(text, model_name):
15
  model = models[model_name]
16
  result = model(text)[0]
17
  return result['label'], result['score']
18
 
19
- # Define Streamlit app
20
  def app():
21
  st.title("Sentiment Analysis App")
22
 
@@ -43,6 +43,6 @@ def app():
43
  ax.set_title("Sentiment Analysis Results")
44
  st.pyplot(fig)
45
 
46
- # Run Streamlit app
47
  if __name__ == "__main__":
48
  app()
 
4
  import seaborn as sns
5
  import transformers
6
 
7
+
8
  models = {
9
  "DistilBERT": transformers.pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english"),
10
  "RoBERTa": transformers.pipeline("sentiment-analysis", model="roberta-base-openai-detector"),
11
  }
12
 
13
+
14
  def analyze_sentiment(text, model_name):
15
  model = models[model_name]
16
  result = model(text)[0]
17
  return result['label'], result['score']
18
 
19
+
20
  def app():
21
  st.title("Sentiment Analysis App")
22
 
 
43
  ax.set_title("Sentiment Analysis Results")
44
  st.pyplot(fig)
45
 
46
+
47
  if __name__ == "__main__":
48
  app()