Spaces:
Running
Running
Update models/hsd_tr.py
Browse files- models/hsd_tr.py +14 -9
models/hsd_tr.py
CHANGED
@@ -2,8 +2,8 @@ import streamlit as st
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Turkish
|
5 |
-
sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech-detection") # "gritli/bert-sentiment-analyses-imdb"
|
6 |
-
sentiment_pipeline_tr_test = pipeline(task = "text-classification", model = "SoDehghan/test")
|
7 |
strength_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech-strength-prediction")
|
8 |
|
9 |
def write():
|
@@ -18,10 +18,10 @@ def write():
|
|
18 |
if st.button("Model prediction", key="tr_predict"):
|
19 |
st.write(" ")
|
20 |
with st.spinner('Generating predictions...'):
|
21 |
-
result_sentiment_tr = sentiment_pipeline_tr(tr_input)
|
22 |
-
sentiment_tr = result_sentiment_tr[0]["label"]
|
23 |
-
label_dict_sentiment = {'LABEL_1': 'Detection: Hate β', 'LABEL_0': 'Detection: Non-hate β
'}
|
24 |
-
sentiment_tr = label_dict_sentiment[sentiment_tr]
|
25 |
|
26 |
#result_sentiment_tr_test = sentiment_pipeline_tr_test(tr_input)
|
27 |
#sentiment_tr_test = result_sentiment_tr_test[0]["label"]
|
@@ -30,12 +30,17 @@ def write():
|
|
30 |
|
31 |
result_strength_tr = strength_pipeline_tr(tr_input)
|
32 |
strength_tr = result_strength_tr[0]["label"]
|
33 |
-
label_dict_strength = {'LABEL_0': 'Strength: 0', 'LABEL_1': 'Strength: 1', 'LABEL_2': 'Strength: 2
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
strength_tr = label_dict_strength[strength_tr]
|
35 |
st.write(sentiment_tr)
|
36 |
-
#st.write(sentiment_tr_test)
|
37 |
st.write(strength_tr)
|
38 |
-
|
39 |
#st.success(sentiment_tr)
|
40 |
#st.success(strength_tr)
|
41 |
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Turkish
|
5 |
+
#sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech-detection") # "gritli/bert-sentiment-analyses-imdb"
|
6 |
+
#sentiment_pipeline_tr_test = pipeline(task = "text-classification", model = "SoDehghan/test")
|
7 |
strength_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech-strength-prediction")
|
8 |
|
9 |
def write():
|
|
|
18 |
if st.button("Model prediction", key="tr_predict"):
|
19 |
st.write(" ")
|
20 |
with st.spinner('Generating predictions...'):
|
21 |
+
#result_sentiment_tr = sentiment_pipeline_tr(tr_input)
|
22 |
+
#sentiment_tr = result_sentiment_tr[0]["label"]
|
23 |
+
#label_dict_sentiment = {'LABEL_1': 'Detection: Hate β', 'LABEL_0': 'Detection: Non-hate β
'}
|
24 |
+
#sentiment_tr = label_dict_sentiment[sentiment_tr]
|
25 |
|
26 |
#result_sentiment_tr_test = sentiment_pipeline_tr_test(tr_input)
|
27 |
#sentiment_tr_test = result_sentiment_tr_test[0]["label"]
|
|
|
30 |
|
31 |
result_strength_tr = strength_pipeline_tr(tr_input)
|
32 |
strength_tr = result_strength_tr[0]["label"]
|
33 |
+
label_dict_strength = {'LABEL_0': 'Strength: 0 (No-hate)', 'LABEL_1': 'Strength: 1 (Insult)', 'LABEL_2': 'Strength: 2 (Exclusion)',
|
34 |
+
'LABEL_3': 'Strength: 3 (Wishing harm)', 'LABEL_4': 'Strength: 4 (Threatening harm)'}
|
35 |
+
|
36 |
+
label_dict_sentiment = {'LABEL_0': 'Detection: No-hate β
', 'LABEL_1': 'Detection: Hate β', 'LABEL_2': 'Detection: Hate β',
|
37 |
+
'LABEL_3': 'Detection: Hate β', 'LABEL_4': 'Detection: Hate β',}
|
38 |
+
|
39 |
+
sentiment_tr = label_dict_sentiment[strength_tr]
|
40 |
strength_tr = label_dict_strength[strength_tr]
|
41 |
st.write(sentiment_tr)
|
|
|
42 |
st.write(strength_tr)
|
43 |
+
#st.write(sentiment_tr_test)
|
44 |
#st.success(sentiment_tr)
|
45 |
#st.success(strength_tr)
|
46 |
|