|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline("text-classification", model="ahmedrachid/FinancialBERT-Sentiment-Analysis") |
|
|
|
|
|
footer = """ |
|
--- |
|
### Sasiraj Shanmugasundaram |
|
#### Machine Learning Deployment Project |
|
""" |
|
|
|
def predict_sentiment(news_text): |
|
result = pipe(news_text)[0] |
|
return result['label'] |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_sentiment, |
|
inputs=gr.Textbox(lines=4, placeholder="Type your financial news here..."), |
|
outputs="text", |
|
title="Financial Sentiment Analysis", |
|
description="Enter financial news and get sentiment analysis based on FinancialBERT." |
|
) |
|
|
|
|
|
gr.Markdown(footer) |
|
|
|
|
|
|
|
iface.launch() |
|
|