tal11 commited on
Commit
f9a3817
1 Parent(s): 1b1e40b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the models
5
+ model1 = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")
6
+ model2 = pipeline("sentiment-analysis", model="mr8488/distilroberta-finetuned-financial-news-sentiment-analysis")
7
+
8
+ # Define the function to generate responses
9
+ def analyze_sentiment(input_text):
10
+ result1 = model1(input_text)[0]
11
+ result2 = model2(input_text)[0]
12
+ return {"mrm8488": f"{result1['label']} ({result1['score']:.2f})",
13
+ "mr8488": f"{result2['label']} ({result2['score']:.2f})"}
14
+
15
+ # Create the Gradio interface
16
+ iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Financial Sentiment Analysis", description="Enter a sentence to analyze its sentiment using two different models.")
17
+
18
+ # Launch the interface
19
+ iface.launch()