File size: 621 Bytes
d0d90ca
 
 
4c37e0c
 
 
 
d0d90ca
 
 
228b0be
d0d90ca
cd21d60
228b0be
 
cd21d60
 
 
 
 
 
 
 
 
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

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
)