vivekdhaiya commited on
Commit
1fd1539
1 Parent(s): b67e64f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Replace 'bert-base-uncased' with the name of the model you want to use
5
+ sentiment = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")
6
+
7
+ def get_sentiment(input_text):
8
+ result=sentiment(input_text)
9
+ if result[0]['label']=="positive":
10
+ face = "\U0001f642"
11
+ elif result[0]['label']=="negative":
12
+ face = "\U0001f641"
13
+ else:
14
+ face = "\U0001f610"
15
+ return (result,face)
16
+
17
+ iface = gr.Interface(fn=get_sentiment, inputs="text", outputs=['text','text'], title='Financial Sentiment Analysis')
18
+
19
+ iface.launch(inline=False)