new_space_nlp / pages /toxic.py
Teery's picture
Update pages/toxic.py
62fb805
import streamlit as st
import requests
import streamlit as st
import requests
from transformers import pipeline
pipe = pipeline("text-classification", model="cointegrated/rubert-tiny-toxicity")
text = st.text_input("Введите комментарий")
if text:
output = pipe(text)[0].get('label')
if output == 'dangerous':
st.markdown('<p style="color:red;">ОПАСНЫЙ КОММЕНТАРИЙ</p>', unsafe_allow_html=True)
elif output == 'non-toxic':
st.markdown('<p style="color:white;">Нормальный комментарий</p>', unsafe_allow_html=True)
elif output == 'insult':
st.markdown('<p style="color:green;">Оскорбительный комментарий</p>', unsafe_allow_html=True)
elif output == 'threat':
st.markdown('<p style="color:red;">Угрожающий комментарий</p>', unsafe_allow_html=True)
elif output == 'obscenity':
st.markdown('<p style="color:pink;">ууу, непристойности</p>', unsafe_allow_html=True)