sahiba12 commited on
Commit
bf54ac5
·
1 Parent(s): ca04c19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -22
app.py CHANGED
@@ -1,23 +1,14 @@
1
- import os
2
- import gradio as gr
3
- from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
4
-
5
- HF_TOKEN = os.environ.get('HF_TOKEN')
6
-
7
- model_checkpoint = "besijar/dspa_review_classification"
8
- tokeniser = AutoTokenizer.from_pretrained(model_checkpoint, use_auth_token=HF_TOKEN)
9
- model = TFAutoModelForSequenceClassification.from_pretrained(model_checkpoint, use_auth_token=HF_TOKEN)
10
-
11
- example_review = "Tully's House Blend is the perfect K-Cup for me. Sure, I occasionally enjoy the special flavors.....Mocha, Italian roast, French vanilla, but my favorite 'go-to'coffee is House Blend. Wakes me up in the morning with it's coffee house full hearty taste."
12
-
13
- def review_classify(review):
14
- review = tokeniser.encode(review)
15
- review = model.predict([review])
16
- return int(review.logits.argmax())
17
-
18
- iface = gr.Interface(review_classify,
19
- title="Review Classification using DistilRoBERTa",
20
- inputs=[gr.Text(label="Review")],
21
- outputs=[gr.Number(label="Rating", precision=0)],
22
- examples=[example_review])
23
  iface.launch()
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ sentiment = pipeline('sentiment-analysis')
4
+ def get_sentiment(input_text):
5
+ return sentiment (input_text)
6
+ iface = gr.Interface(fn = get_sentiment,
7
+ inputs = 'text',
8
+ outputs = ['text'],
9
+ title = 'Sentiment Analysis',
10
+ examples = ['The movie was very bad', 'Every day is a new opportunity.'],
11
+ article = 'This project is for software engineering with team members Aditya Jadhav, Sujal Kuthe, Sujal Wakalkar, and Adesh Ingle. We developed a web application for sentiment analysis that takes text data as input and classifies whether it is positive or negative.',
12
+ thumbnail = '/content/sentiment-analysis.png',
13
+ theme = gr.themes.Soft())
 
 
 
 
 
 
 
 
 
14
  iface.launch()