File size: 871 Bytes
eb09a70
 
 
 
 
 
 
d0c6cde
e1c5bc7
d0c6cde
3695726
eb09a70
75871a8
0bc5053
75871a8
 
 
10baaf4
75871a8
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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")
label_dict = {'LABEL_0': 'Hate', 'LABEL_1': 'Non-hate'}


#st.title("Hate Speech Detection in Turkish with HuggingFace Spaces")
#st.write("Enter a Turkish sentence here:")
#user_input = st.text_input(" ")

user_input = st.text_input("Enter your text here:",)

#if user_input:
if st.button("Click for predictions!"):
    with st.spinner('Generating predictions...'):
        result = sentiment_pipeline(user_input)
        sentiment = result[0]["label"]
        label_dict = {'LABEL_0': 'Hate', 'LABEL_1': 'Non-hate'}
        sentiment = label_dict[sentiment]
        #st.write(f"Detection: {sentiment}")
        #st.success(sentiment)