|
|
| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| model_name = "nlptown/bert-base-multilingual-uncased-sentiment" |
| classifier = pipeline("sentiment-analysis", model=model_name) |
|
|
| |
| def interfaz_clasificador(texto): |
| resultado = classifier(texto)[0] |
| return f"Etiqueta: {resultado['label']}, Puntuaci贸n: {resultado['score']:.4f}" |
|
|
| |
| css_custom = """ |
| h1 { color: #215C98 !important; text-align: center; } |
| .gradio-container label span { color: #215C98 !important; font-weight: bold; } |
| button.primary { background: #215C98 !important; background-color: #215C98 !important; color: white !important; border: none; } |
| """ |
|
|
| |
| demo = gr.Interface( |
| fn=interfaz_clasificador, |
| inputs=gr.Textbox(lines=2, placeholder="Escribe un texto aqu铆...", label="Texto a clasificar"), |
| outputs=gr.Textbox(label="Salida"), |
| title="Clasificador de Sentimientos en Espa帽ol", |
| css=css_custom |
| ) |
|
|
| |
| if __name__ == "__main__": |
| demo.launch() |
|
|