Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
model = pipeline("text-classification", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis") | |
def input_text_fn(text): | |
result = model(text) | |
label = result[0]['label'] | |
confidence = result[0]['score'] | |
return f"Label: {label}, Confidence: {confidence:.2f}" | |
interface = gr.Interface( | |
fn=input_text_fn, | |
inputs="text", | |
outputs="text", | |
title="Financial Data Sentiment Analysis", | |
description="Enter financial text to classify it as positive, neutral or negative sentiment.", | |
examples=["Our company’s revenue grew by 15% in the last quarter, driven by strong performance in our core markets.", "This year has been challenging due to supply chain disruptions and increased operating expenses. Our profit margins have decreased"] | |
) | |
# Launch the app | |
interface.launch() |