Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,21 @@ from transformers import pipeline
|
|
4 |
# Load the text classification pipeline
|
5 |
pipeline = pipeline("text-classification", model="ProsusAI/finbert", trust_remote_code=True)
|
6 |
|
7 |
-
def predict(input_text):
|
8 |
-
predictions = pipeline(input_text, threshold=0.5, return_scores=
|
9 |
-
return predictions[0]
|
10 |
|
11 |
# Define the Gradio interface
|
12 |
gradio_app = gr.Interface(
|
13 |
predict,
|
14 |
inputs=gr.Textbox(label="Write a text"),
|
15 |
-
outputs=gr.
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
)
|
18 |
|
19 |
# Launch the Gradio interface
|
|
|
4 |
# Load the text classification pipeline
|
5 |
pipeline = pipeline("text-classification", model="ProsusAI/finbert", trust_remote_code=True)
|
6 |
|
7 |
+
def predict(input_text):
|
8 |
+
predictions = pipeline(input_text, threshold=0.5, return_scores=True)
|
9 |
+
return predictions[0]
|
10 |
|
11 |
# Define the Gradio interface
|
12 |
gradio_app = gr.Interface(
|
13 |
predict,
|
14 |
inputs=gr.Textbox(label="Write a text"),
|
15 |
+
outputs=gr.Label(label="Predicted Sentiment Probabilities"),
|
16 |
+
components=[
|
17 |
+
gr.Label(label="Neutral: {:.2f}".format(predictions[0]["score"][0])),
|
18 |
+
gr.Label(label="Positive: {:.2f}".format(predictions[0]["score"][1])),
|
19 |
+
gr.Label(label="Negative: {:.2f}".format(predictions[0]["score"][2])),
|
20 |
+
],
|
21 |
+
title="Financial Sentiment Analysis",
|
22 |
)
|
23 |
|
24 |
# Launch the Gradio interface
|