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)