Spaces:
Paused
Paused
Download app.py from codigo-g6/toxic-comments: direct link, hf CLI and curl.
- Browser
- Download file 535 Bytes
-
https://huggingface.co/spaces/codigo-g6/toxic-comments/resolve/main/app.py
- Command line
-
hf download hf://spaces/codigo-g6/toxic-comments/app.py
-
curl -L -o app.py https://huggingface.co/spaces/codigo-g6/toxic-comments/resolve/main/app.py
535 Bytes
| from transformers import pipeline | |
| pipe = pipeline("text-classification", model="jazbarr/jazbarr-toxicidad") | |
| def analizar_texto(texto): | |
| resultado = pipe(texto)[0] | |
| label = resultado['label'] | |
| score = resultado['score'] | |
| if label == 'LABEL_1': | |
| return f'This comment is toxic (score: {score})' | |
| else: | |
| return f'This comment is not toxic (score: {score}' | |
| import gradio as gr | |
| demo = gr.Interface( | |
| fn=analizar_texto, | |
| inputs=gr.Textbox(label='write a comment'), | |
| outputs=gr.Textbox(label='result') | |
| ) | |
| demo.launch() |