Spaces:
Sleeping
Sleeping
File size: 1,471 Bytes
b154f93 4e73bd2 f81bf96 4e73bd2 b154f93 4e73bd2 fd430b5 4e73bd2 f81bf96 a783e4a ad84234 52eeda6 777fc73 53367b9 71a4d6b 75871a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import streamlit as st
from transformers import pipeline
# Turkish
sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech") # "gritli/bert-sentiment-analyses-imdb"
strength_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech") # "gritli/bert-sentiment-analyses-imdb"
def write():
st.markdown(
"""
# Hate Speech Detection in Turkish
"""
)
tr_input = st.text_area("Enter your text here:", height=50, key="tr_input") #height=30
if st.button("Model prediction", key="tr_predict"):
st.write(" ")
with st.spinner('Generating predictions...'):
result_sentiment_tr = sentiment_pipeline_tr(tr_input)
sentiment_tr = result_sentiment_tr[0]["label"]
label_dict_sentiment = {'LABEL_1': 'Detection: Hate β', 'LABEL_0': 'Detection: Non-hate β
'} #π«
sentiment_tr = label_dict_sentiment[sentiment_tr]
result_strength_tr = strength_pipeline_tr(tr_input)
strength_tr = result_strength_tr[0]["label"]
label_dict_strength = {'LABEL_0': 'Strength: 0', 'LABEL_1': 'Strength: 1', 'LABEL_2': 'Strength: 2','LABEL_3': 'Strength: 3', 'LABEL_4': 'Strength: 4'} #π«
strength_tr = label_dict_strength[strength_tr]
st.write(sentiment_tr)
st.write(strength_tr)
#st.success(sentiment_tr)
#st.success(strength_tr)
|