-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
71 lines (56 loc) · 2.04 KB
/
app.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import streamlit as st
import pandas as pd
import tensorflow as tf
from preprocess import clean
import webbrowser
import os
import zipfile
if not os.path.exists("./saved_model"):
zfile = zipfile.ZipFile("saved_model.zip")
zfile.extractall()
zfile.close()
# some bullons and texts
dataset_url1 = "https://www.kaggle.com/competitions/fake-news/code"
notebook_url = "https://github.com/tikendraw/fake_news_classifier/blob/main/fake_news_classifier.ipynb"
git_profile = "https://github.com/tikendraw"
col1, col2, col3 = st.columns([1, 1, 1])
with col1:
if st.button("Dataset"):
webbrowser.open_new_tab(dataset_url1)
with col2:
if st.button("Code/Notebook"):
webbrowser.open_new_tab(notebook_url)
with col3:
if st.button("Profile"):
webbrowser.open_new_tab(git_profile)
st.title("Fake News Classifier 📰")
st.markdown("A System to identify unreliable News articles")
input_title = st.text_area("Heading")
input_text = st.text_area("Body")
with st.spinner(
"Fill the boxes while we load the model... Predict button will be visible after model gets loaded"
):
model = tf.keras.models.load_model("./saved_model/fake_news_classifier.tf")
st.success("Model Loaded!")
submit = st.button("Predict")
if submit:
with st.spinner("Predicting..."):
data = pd.DataFrame(
[[clean(input_title), clean(input_text)]], columns=["title", "text"]
)
x = [data["title"].values, data["text"].values]
ypred = tf.squeeze(tf.round(model.predict(x)))
if ypred.numpy() > 0.5:
st.error("It is a Fake News")
else:
st.success("Not a Fake news")
st.markdown("## Model Stats")
st.write(
"We achieved Great results on testing and validation results. Various Deep Learning Model. Here we are using **Model3: bigLSTM**"
)
st.image("./model_results1.png")
st.write(
"""**Note:** Incase our model mistakes to classify your article. It is probably
\n1. The data may have been outdated
\n2. Article contains alot of the words that our model hasn't been trained on """
)