Spaces:
Sleeping
Sleeping
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() | |