Sasiraj01 commited on
Commit
dfd9031
·
verified ·
1 Parent(s): 6068e77

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the pretrained model pipeline
5
+ pipe = pipeline("text-classification", model="ahmedrachid/FinancialBERT-Sentiment-Analysis")
6
+
7
+ # Footer content
8
+ footer = """
9
+ ---
10
+ ### Sasiraj Shanmugasundaram
11
+ #### Machine Learning Deployment Project
12
+ """
13
+ # Function for prediction
14
+ def predict_sentiment(news_text):
15
+ result = pipe(news_text)[0]
16
+ return result['label']
17
+
18
+ # Create the Gradio interface
19
+ iface = gr.Interface(
20
+ fn=predict_sentiment,
21
+ inputs=gr.Textbox(lines=4, placeholder="Type your financial news here..."),
22
+ outputs="text",
23
+ title="Financial Sentiment Analysis",
24
+ description="Enter financial news and get sentiment analysis based on FinancialBERT."
25
+ )
26
+ # Add footer using Markdown
27
+ # Add footer using Markdown
28
+ gr.Markdown(footer)
29
+
30
+
31
+ # Launch the app
32
+ iface.launch()