File size: 925 Bytes
1fd1539
 
 
cf5d480
1fd1539
 
 
 
 
 
 
 
 
 
 
 
80356fe
 
 
7bfd974
de21b1b
1fd1539
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline


sentiment = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")

def get_sentiment(input_text):
    result=sentiment(input_text)
    if result[0]['label']=="positive":
        face = "\U0001f642"
    elif result[0]['label']=="negative":
        face = "\U0001f641"
    else:
        face = "\U0001f610"
    return (result,face)

iface = gr.Interface(fn=get_sentiment, inputs="text", outputs=['text','text'], title='Financial Sentiment Analysis',
                    examples = [["With the launch of Apple Silicon, Apple shares are same"],
                               ["With the launch of Apple Silicon, Apple shares have increased"],
                               ["With the launch of Apple Silicon, Apple shares have decreased"]],
                    theme ='HaleyCH/HaleyCH_Theme')

iface.launch(inline=False)