Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
def predict(
|
7 |
-
predictions = pipeline(
|
8 |
-
|
9 |
-
)
|
10 |
-
return predictions
|
11 |
|
|
|
12 |
gradio_app = gr.Interface(
|
13 |
predict,
|
14 |
-
inputs=gr.Textbox(label="Write a text")
|
15 |
-
outputs=gr.
|
16 |
-
title="
|
17 |
)
|
18 |
|
|
|
19 |
if __name__ == "__main__":
|
20 |
gradio_app.launch()
|
|
|
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): # Corrected argument name
|
8 |
+
predictions = pipeline(input_text, threshold=0.5, return_scores=False)
|
9 |
+
return predictions[0] # Extract the first prediction
|
|
|
|
|
10 |
|
11 |
+
# Define the Gradio interface
|
12 |
gradio_app = gr.Interface(
|
13 |
predict,
|
14 |
+
inputs=gr.Textbox(label="Write a text"),
|
15 |
+
outputs=gr.Textbox(label="Predicted Sentiment"), # More descriptive label
|
16 |
+
title="Financial Sentiment Analysis", # More specific title
|
17 |
)
|
18 |
|
19 |
+
# Launch the Gradio interface
|
20 |
if __name__ == "__main__":
|
21 |
gradio_app.launch()
|