Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,19 @@
|
|
1 |
-
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
|
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 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
-
# Define the Gradio interface
|
12 |
gradio_app = gr.Interface(
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
gr.Label(label="Negative: {:.2f}".format(predictions[0]["score"][2])),
|
20 |
-
],
|
21 |
-
title="Financial Sentiment Analysis",
|
22 |
)
|
23 |
|
24 |
-
|
25 |
-
if __name__ == "__main__":
|
26 |
-
gradio_app.launch()
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
pipeline = pipeline("text-classification" , model = "ProsusAI/finbert")
|
|
|
|
|
3 |
|
4 |
def predict(input_text):
|
5 |
+
predictions = pipeline(input_text )
|
6 |
+
print(predictions)
|
7 |
+
return predictions[0]
|
8 |
+
|
9 |
|
|
|
10 |
gradio_app = gr.Interface(
|
11 |
+
predict,
|
12 |
+
inputs=gr.Textbox(label="Write a text"),
|
13 |
+
outputs=gr.Textbox(label="output a text"),
|
14 |
+
title="Financial Sentiment Analysis",
|
15 |
+
live=True,
|
16 |
+
allow_flagging="never",
|
|
|
|
|
|
|
17 |
)
|
18 |
|
19 |
+
gradio_app.launch()
|
|
|
|