Delete app.py
Browse files
app.py
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from preprocessing import preprocess_text
|
3 |
-
from model import load_model,predict
|
4 |
-
from streamlit_lottie import st_lottie
|
5 |
-
import requests
|
6 |
-
|
7 |
-
|
8 |
-
def load_lottieurl(url:str):
|
9 |
-
r = requests.get(url)
|
10 |
-
if r.status_code != 200:
|
11 |
-
return new_func()
|
12 |
-
return r.json()
|
13 |
-
|
14 |
-
def load_lottiefile(filepath:str):
|
15 |
-
with open(filepath,encoding="utf8") as f:
|
16 |
-
data =json.load(f)
|
17 |
-
return data
|
18 |
-
|
19 |
-
# Load the model and tokenizer
|
20 |
-
model_path = 'Model/bert_classifier.h5'
|
21 |
-
model, tokenizer = load_model(model_path)
|
22 |
-
|
23 |
-
lottie_coding = load_lottieurl("https://lottie.host/05d8286a-86bb-483e-a845-5715aca4241e/hrUyVR89oh.json")
|
24 |
-
lottie_coding2 = load_lottieurl("https://lottie.host/5735c629-79f5-4312-b4e4-268709e0eaab/D4OjpsayFs.json")
|
25 |
-
|
26 |
-
# Streamlit UI
|
27 |
-
st.set_page_config(layout="wide",page_title="Hate-speech-Detection",page_icon=":computer:")
|
28 |
-
st.markdown("<h1 style='text-align:center;color:white;'>Welcome To Our Website !</h1>", unsafe_allow_html=True)
|
29 |
-
#---Main Section---
|
30 |
-
with st.container():
|
31 |
-
st.header('Automated Hate Speech Detection')
|
32 |
-
input_text = st.text_area('Enter text to analyze', '')
|
33 |
-
if st.button('Analyze'):
|
34 |
-
preprocessed_text = preprocess_text(input_text)
|
35 |
-
classification = predict(preprocessed_text, model, tokenizer)
|
36 |
-
st.write("Classification:", classification)
|
37 |
-
st.write("---")
|
38 |
-
#---Header Section---
|
39 |
-
with st.container():
|
40 |
-
left_column,right_column=st.columns(2)
|
41 |
-
with left_column:
|
42 |
-
st.header("ABOUT")
|
43 |
-
st.write(
|
44 |
-
"""
|
45 |
-
This website employs an automated system to detect and manage harmful content that incites hatred, violence, or discrimination against individuals or groups based on characteristics such as race, ethnicity, gender, sexual orientation, or religion. By using machine learning algorithms and natural language processing, the system analyzes user-generated comments and posts on the Reddit platform to identify and flag potentially offensive or harmful language
|
46 |
-
"""
|
47 |
-
)
|
48 |
-
with right_column:
|
49 |
-
st_lottie(lottie_coding, height=400, key="coding")
|
50 |
-
# --- FORM SECTION ---
|
51 |
-
with st.container():
|
52 |
-
st.write("---")
|
53 |
-
st.header("Get In Touch With Me!")
|
54 |
-
contact_form = """
|
55 |
-
<form action="https://formsubmit.co/[email protected]" method="POST">
|
56 |
-
<input type="hidden" name="_captcha" value="false">
|
57 |
-
<input type="text" name="name" placeholder="Your name" required>
|
58 |
-
<input type="email" name="email" placeholder="Your email" required>
|
59 |
-
<textarea name="message" placeholder="Your message here" required></textarea>
|
60 |
-
<button type="submit">Send</button>
|
61 |
-
</form>
|
62 |
-
"""
|
63 |
-
def local_css(file_name):
|
64 |
-
with open(file_name) as f:
|
65 |
-
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
66 |
-
local_css("AutomatedHateSpeech/form.css")
|
67 |
-
|
68 |
-
left_column, right_column = st.columns(2)
|
69 |
-
with left_column:
|
70 |
-
st.markdown(contact_form, unsafe_allow_html=True)
|
71 |
-
with right_column:
|
72 |
-
st_lottie(lottie_coding2, height=300,key="anime")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|