Spaces:
Configuration error
Configuration error
Download app.py from solinsoft/toxic-commets: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/solinsoft/toxic-commets/resolve/main/app.py
- Command line
-
hf download hf://spaces/solinsoft/toxic-commets/app.py
-
curl -L -o app.py https://huggingface.co/spaces/solinsoft/toxic-commets/resolve/main/app.py
1.28 kB
| import streamlit as st | |
| from transformers import pipeline | |
| # ============================== | |
| # CONFIGURACI脫N DE LA APLICACI脫N | |
| # ============================== | |
| st.set_page_config(page_title="Detecci贸n de Toxicidad", page_icon="馃", layout="centered") | |
| st.title("馃 Detecci贸n de Toxicidad en Comentarios") | |
| st.markdown("Modelo fine-tuneado en DistilBERT para detectar lenguaje t贸xico en texto.") | |
| # ============================== | |
| # CARGAR MODELO DESDE HF HUB | |
| # ============================== | |
| def load_model(): | |
| model_id = "solinsoft/distilbert-finetuned-toxic-comments" | |
| clf = pipeline("text-classification", model=model_id) | |
| return clf | |
| clf = load_model() | |
| # ============================== | |
| # INTERFAZ DE USUARIO | |
| # ============================== | |
| texto = st.text_area("Escribe un comentario para analizar:", height=150) | |
| if st.button("Analizar"): | |
| if texto.strip(): | |
| with st.spinner("Analizando el texto..."): | |
| result = clf(texto)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| st.success("**Resultado:**",label,score:.2%) | |
| else: | |
| st.warning("Por favor, escribe un texto antes de analizar.") | |
| st.markdown("---") | |
| st.caption("Desarrollado con 鉂わ笍 usando Hugging Face") | |