SoDehghan's picture
Update app.py
6013867 verified
raw
history blame
2.14 kB
import gradio as gr
import streamlit as st
import requests
import time
from transformers import pipeline
import os
# Set the page configuration
st.set_page_config(
page_title="Hate Speech Detection",
page_icon="📖", #":bar_chart:"
layout='centered'
)
#title = r"$\textsf{\small Hate Speech Detection}$"
#st.title(title)
#st.write("In this HuggingFace space you will be able to use our Hate Speech Detection model built at [VERİM - Center of Excellence in Data Analytics - Sabanci University](https://github.com/verimsu).")
# Turkish
sentiment_pipeline_tr = pipeline(task = "text-classification", model = "SoDehghan/BERTurk-hate-speech") # "gritli/bert-sentiment-analyses-imdb"
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'}
def hsd_turkish(text_in):
result_tr = sentiment_pipeline_tr(tr_input)
sentiment_tr = result_tr[0]["label"]
label_dict = {'LABEL_1': 'Hate ❌', 'LABEL_0': 'Non-hate ✅'} #🚫
sentiment_tr = label_dict[sentiment_tr]
return sentiment_tr
iface = gr.Interface(fn=[hsd_turkish],
inputs=gr.inputs.Textbox(lines=2, placeholder=None, label="Enter text here:"),
outputs=['text'], # a list should match the number of values returned by fn to have one input and 2 putputs.
#description = "This App translates text from Danish to the English language.",
title = "HSD in Turkish",
theme = "peach")
iface.launch(share=False, enable_queue=True)
st.sidebar.title("Hate Speech Detection")
#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).")
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).')