Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| # Cargar modelo de Hugging Face | |
| sentiment_pipeline = pipeline( | |
| "sentiment-analysis", | |
| model="distilbert-base-uncased-finetuned-sst-2-english" | |
| ) | |
| def sentiment_analysis(text: str) -> dict: | |
| result = sentiment_pipeline(text)[0] | |
| return { | |
| "sentiment": result["label"], | |
| "confidence": round(result["score"], 4) | |
| } | |
| demo = gr.Interface( | |
| fn=sentiment_analysis, | |
| inputs=gr.Textbox(placeholder="Enter text..."), | |
| outputs=gr.JSON(), | |
| title="LLM-based Sentiment Analysis" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(mcp_server=True) |