Spaces:
Runtime error
Runtime error
File size: 717 Bytes
225a9a7 7222a71 225a9a7 7222a71 225a9a7 7222a71 225a9a7 7222a71 225a9a7 7222a71 225a9a7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
# Load the text classification pipeline
pipeline = pipeline("text-classification", model="ProsusAI/finbert", trust_remote_code=True)
def predict(input_text): # Corrected argument name
predictions = pipeline(input_text, threshold=0.5, return_scores=False)
return predictions[0] # Extract the first prediction
# Define the Gradio interface
gradio_app = gr.Interface(
predict,
inputs=gr.Textbox(label="Write a text"),
outputs=gr.Textbox(label="Predicted Sentiment"), # More descriptive label
title="Financial Sentiment Analysis", # More specific title
)
# Launch the Gradio interface
if __name__ == "__main__":
gradio_app.launch() |