VarshithaCh commited on
Commit
e6dec8b
·
1 Parent(s): 8d6d251

Added the streamlit app

Browse files
Files changed (3) hide show
  1. README.md +11 -0
  2. app.py +17 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,3 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
1
  # cs-gy-6613-project
2
 
3
  ## Installation steps
 
1
+ ---
2
+ title: Sentiment Analysis App
3
+ emoji: 💻
4
+ colorFrom: gray
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.17.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
  # cs-gy-6613-project
13
 
14
  ## Installation steps
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import statements
2
+ import streamlit as st
3
+ from transformers import pipeline
4
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
+
6
+ # Get Input
7
+ models = {"Distilbert": "distilbert-base-uncased-finetuned-sst-2-english", "roBERTa" : "cardiffnlp/twitter-roberta-base-sentiment", "Bert" : "finiteautomata/bertweet-base-sentiment-analysis"}
8
+ text = st.text_area('Enter some text!')
9
+ model_name = st.selectbox("What model do you wanna use?", ("Distilbert", "roBERTa", "Bert"))
10
+
11
+ # Default Model - DistilBert
12
+ if text and model_name:
13
+ model = AutoModelForSequenceClassification.from_pretrained(models[model_name])
14
+ tokenizer = AutoTokenizer.from_pretrained(models[model_name])
15
+ classifier = pipeline('sentiment-analysis', model = model, tokenizer = tokenizer)
16
+ out = classifier(text)
17
+ st.json(out)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ torch
3
+ transformers