SoDehghan commited on
Commit
73c2612
·
verified ·
1 Parent(s): 916b7b8

Create hsd_ar.py

Browse files
Files changed (1) hide show
  1. hsd_ar.py +24 -0
hsd_ar.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import awesome_streamlit as ast
2
+ import streamlit as st
3
+ import requests
4
+ import time
5
+ from transformers import pipeline
6
+ import os
7
+
8
+ import streamlit as st
9
+ from transformers import pipeline
10
+
11
+ sentiment_pipeline = pipeline(task = "text-classification", model = "gritli/bert-sentiment-analyses-imdb")
12
+
13
+ st.title("Hate Speech Detection with HuggingFace Spaces")
14
+ st.write("Enter a sentence to detect its hateful:")
15
+
16
+ label_dict = {'LABEL_0': 'Hate', 'LABEL_1': 'Non-hate'}
17
+
18
+ user_input = st.text_input("")
19
+ if user_input:
20
+ result = sentiment_pipeline(user_input)
21
+ sentiment = result[0]["label"]
22
+
23
+ sentiment = label_dict[sentiment]
24
+ st.write(f"Sentiment: {sentiment}")