toxic-commets / app.py
cesarmayta's picture
Update app.py
3b10565 verified
Raw History Blame Contribute Delete
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
# ==============================
@st.cache_resource
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")