AI_Voyagers / app.py
vivekdhaiya's picture
Create app.py
1fd1539
raw history blame
No virus
655 Bytes
import gradio as gr
from transformers import pipeline
# Replace 'bert-base-uncased' with the name of the model you want to use
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')
iface.launch(inline=False)