Spaces:
Sleeping
Sleeping
Commit
Β·
e88230c
1
Parent(s):
10ceb34
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,24 @@ from transformers import BertTokenizer, BertForSequenceClassification
|
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
finbert = BertForSequenceClassification.from_pretrained('rpratap2102/The_Misfits', num_labels=3)
|
6 |
tokenizer = BertTokenizer.from_pretrained('rpratap2102/The_Misfits')
|
7 |
|
8 |
nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
|
9 |
|
10 |
c_labels = {
|
11 |
-
'Negative': {'text': 'This does not look good for the Market', 'emoji': 'π'},
|
12 |
-
'Positive': {'text': 'This seems to be good news for the market', 'emoji': 'π'},
|
13 |
-
'Neutral': {'text': "This is normal in the market", 'emoji': 'π'}
|
14 |
}
|
15 |
|
16 |
def predict_sentiment(text):
|
@@ -20,10 +29,8 @@ def predict_sentiment(text):
|
|
20 |
|
21 |
label_text = c_labels[sentiment_label]['text']
|
22 |
emoji = c_labels[sentiment_label]['emoji']
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
return f"{emoji} {output_text}"
|
27 |
|
28 |
iface = gr.Interface(
|
29 |
fn=predict_sentiment,
|
|
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
+
finbert = BertForSequenceClassification.from_pretrained('rpratap2102/The_Misfits', num_labels=3)
|
6 |
+
tokenizer = BertTokenizer.from_pretrained('rpratap2102/The_Misfits')
|
7 |
+
|
8 |
+
nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
|
9 |
+
|
10 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
11 |
+
from transformers import pipeline
|
12 |
+
|
13 |
+
|
14 |
finbert = BertForSequenceClassification.from_pretrained('rpratap2102/The_Misfits', num_labels=3)
|
15 |
tokenizer = BertTokenizer.from_pretrained('rpratap2102/The_Misfits')
|
16 |
|
17 |
nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
|
18 |
|
19 |
c_labels = {
|
20 |
+
'Negative': {'text': 'This does not look good for the Market.', 'emoji': 'π'},
|
21 |
+
'Positive': {'text': 'This seems to be good news for the market.', 'emoji': 'π'},
|
22 |
+
'Neutral': {'text': "This is normal in the market.", 'emoji': 'π'}
|
23 |
}
|
24 |
|
25 |
def predict_sentiment(text):
|
|
|
29 |
|
30 |
label_text = c_labels[sentiment_label]['text']
|
31 |
emoji = c_labels[sentiment_label]['emoji']
|
32 |
+
|
33 |
+
return f"{label_text} {emoji} (Model Predicted it as {sentiment_label} with a confidence score of {confidence_score:.2f})"
|
|
|
|
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
fn=predict_sentiment,
|