File size: 621 Bytes
5900be6
 
 
 
 
 
 
8859c67
5900be6
 
 
83179f0
5900be6
 
 
 
 
 
 
 
 
 
8859c67
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import awesome_streamlit as ast
import streamlit as st
import requests
import time 
from transformers import pipeline
import os



sentiment_pipeline = pipeline(task = "text-classification", model = "gritli/bert-sentiment-analyses-imdb")

#st.title("Hate Speech Detection in Arabic with HuggingFace Spaces")
st.write("Enter a sentence to detect its hateful:")

label_dict = {'LABEL_0': 'Hate', 'LABEL_1': 'Non-hate'}

user_input = st.text_input("")
if user_input:
    result = sentiment_pipeline(user_input)
    sentiment = result[0]["label"]

    sentiment = label_dict[sentiment]
    st.write(f"Detection: {sentiment}")