File size: 1,028 Bytes
bc4bc67 5e6aed6 bc4bc67 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from datasets import load_dataset
from transformers import pipeline
from presentation import main_title, examples
model_name= 'hackathon-pln-es/electricidad-small-discriminator-finetuned-clasificacion-comentarios-suicidas'
def clasificar_comentarios(comentario):
cls= pipeline("text-classification", model=model_name)
return cls(comentario)[0]['label']
if __name__ == "__main__":
gr.Interface(
fn=clasificar_comentarios,
inputs=[
gr.inputs.Textbox(
lines=10,
label="Comentario a analizar:",
placeholder="Ingrese el comentario por favor...",
optional=False,
),
],
outputs=[
gr.outputs.HTML(
label="Resultado:"
)
],
description=main_title,
examples=examples,
theme="seafoam",
thumbnail="None",
css="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css",
).launch() |