File size: 838 Bytes
dfd9031 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from transformers import pipeline
# Load the pretrained model pipeline
pipe = pipeline("text-classification", model="ahmedrachid/FinancialBERT-Sentiment-Analysis")
# Footer content
footer = """
---
### Sasiraj Shanmugasundaram
#### Machine Learning Deployment Project
"""
# Function for prediction
def predict_sentiment(news_text):
result = pipe(news_text)[0]
return result['label']
# Create the Gradio interface
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."
)
# Add footer using Markdown
# Add footer using Markdown
gr.Markdown(footer)
# Launch the app
iface.launch()
|