Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
sentiment_pipeline = pipeline( | |
"sentiment-analysis", | |
model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis" | |
) | |
def analyze(text): | |
result = sentiment_pipeline(text)[0] | |
return f"{result['label']} (Confidence: {result['score']:.2f})" | |
# Explicitly define the Gradio interface with API support | |
gr.Interface( | |
fn=analyze, | |
inputs="text", | |
outputs="text", | |
title="Crypto News Sentiment Analysis", | |
allow_flagging="never" | |
).launch( | |
server_name="0.0.0.0", | |
server_port=7860, | |
share=True # Generates a public URL | |
) |