File size: 1,045 Bytes
4c3876c
 
 
62fb805
 
 
 
4c3876c
62fb805
4c3876c
 
62fb805
4c3876c
 
 
 
 
 
 
 
 
62fb805
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)