Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,43 +20,28 @@ st.set_page_config(
|
|
20 |
|
21 |
# Turkish
|
22 |
sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech") # "gritli/bert-sentiment-analyses-imdb"
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
tr_input = st.text_area("Enter your text here:", height=50, key="tr_input") #height=30
|
27 |
-
if st.button("Click for predictions!", key="tr_predict"):
|
28 |
-
with st.spinner('Generating predictions...'):
|
29 |
result_tr = sentiment_pipeline_tr(tr_input)
|
30 |
sentiment_tr = result_tr[0]["label"]
|
31 |
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'} #🚫
|
32 |
sentiment_tr = label_dict[sentiment_tr]
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
# Arabic
|
37 |
-
sentiment_pipeline_ar = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech")
|
38 |
-
header_ar = r"$\textsf{\scriptsize HSD in Arabic}$"
|
39 |
-
st.subheader(header_ar)
|
40 |
|
41 |
-
ar_input = st.text_area("Enter your text here:", height=50 , key="ar_input")
|
42 |
-
if st.button("Click for predictions!", key="ar_predict"):
|
43 |
-
with st.spinner('Generating predictions...'):
|
44 |
-
result_ar = sentiment_pipeline_ar(ar_input)
|
45 |
-
sentiment_ar = result_ar[0]["label"]
|
46 |
-
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'}
|
47 |
-
sentiment_ar = label_dict[sentiment_ar]
|
48 |
-
st.write(f"Detection: {sentiment_ar}")
|
49 |
|
50 |
|
51 |
st.sidebar.title("Hate Speech Detection")
|
52 |
#st.sidebar.write("In this HuggingFace space you can use Hate Speech Detection model built at [VERİM - Center of Excellence in Data Analytics - Sabanci University](https://github.com/verimsu).")
|
53 |
st.sidebar.write('This tool is developed in the context of the EU project "Utilizing Digital Technology for Social Cohesion, Positive Messaging and Peace by Boosting Collaboration, Exchange and Solidarity" (EuropeAid/170389/DD/ACT/Multi) by [Sabanci University Center of Excellence in Data Analytics](https://github.com/verimsu).')
|
54 |
|
55 |
-
iface = gr.Interface(fn=[
|
56 |
-
inputs=gr.inputs.Textbox(lines=2, placeholder=None, label="
|
57 |
outputs=['text'], # a list should match the number of values returned by fn to have one input and 2 putputs.
|
58 |
-
description = "This App translates text from Danish to the English language.",
|
59 |
-
title = "
|
60 |
theme = "peach")
|
61 |
|
62 |
iface.launch(share=False, enable_queue=True)
|
|
|
20 |
|
21 |
# Turkish
|
22 |
sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech") # "gritli/bert-sentiment-analyses-imdb"
|
23 |
+
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'}
|
24 |
+
|
25 |
+
def hsd_turkish:
|
26 |
|
|
|
|
|
|
|
27 |
result_tr = sentiment_pipeline_tr(tr_input)
|
28 |
sentiment_tr = result_tr[0]["label"]
|
29 |
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'} #🚫
|
30 |
sentiment_tr = label_dict[sentiment_tr]
|
31 |
+
return sentiment_tr
|
|
|
32 |
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
st.sidebar.title("Hate Speech Detection")
|
37 |
#st.sidebar.write("In this HuggingFace space you can use Hate Speech Detection model built at [VERİM - Center of Excellence in Data Analytics - Sabanci University](https://github.com/verimsu).")
|
38 |
st.sidebar.write('This tool is developed in the context of the EU project "Utilizing Digital Technology for Social Cohesion, Positive Messaging and Peace by Boosting Collaboration, Exchange and Solidarity" (EuropeAid/170389/DD/ACT/Multi) by [Sabanci University Center of Excellence in Data Analytics](https://github.com/verimsu).')
|
39 |
|
40 |
+
iface = gr.Interface(fn=[hsd_turkish],
|
41 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder=None, label="Enter text here:"),
|
42 |
outputs=['text'], # a list should match the number of values returned by fn to have one input and 2 putputs.
|
43 |
+
#description = "This App translates text from Danish to the English language.",
|
44 |
+
title = "HSD in Turkish",
|
45 |
theme = "peach")
|
46 |
|
47 |
iface.launch(share=False, enable_queue=True)
|