Spaces:
Sleeping
Sleeping
File size: 879 Bytes
1bef306 132be2f 1bef306 28349db 132be2f 1bef306 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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() |