File size: 4,098 Bytes
b291470
 
 
 
7047b28
b291470
 
47a2e1b
 
b291470
 
a1d0b3c
 
 
7047b28
a1d0b3c
 
 
 
b291470
a1d0b3c
 
 
 
 
b291470
a1d0b3c
 
 
 
b291470
a1d0b3c
b291470
 
 
 
 
a1d0b3c
 
 
 
 
 
 
 
 
 
 
 
64b7e2b
a1d0b3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b291470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1d0b3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import streamlit as st
import transformers
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from predict_function import detect_fake_news

# Load the model and tokenizer
model_name = AutoModelForSequenceClassification.from_pretrained("ikoghoemmanuell/finetuned_fake_news_roberta")
tokenizer_name = AutoTokenizer.from_pretrained("ikoghoemmanuell/finetuned_fake_news_roberta")


# Loading GIF
gif_url = "https://raw.githubusercontent.com/Gilbert-B/Forecasting-Sales/main/app/salesgif.gif"
"https://docs.gato.txst.edu/78660/w/2000/a_1dzGZrL3bG/fake-fact.jpg"

# Set up sidebar
st.sidebar.header('Navigation')
menu = ['Home', 'About']
choice = st.sidebar.selectbox("Select an option", menu)

# Define the function for detecting fake news
@st.cache_resource
def detect_fake_news(text):
    # Load the pipeline.
    pipeline = transformers.pipeline("text-classification", model=model_name, tokenizer=tokenizer_name)

    # Predict the sentiment.
    prediction = pipeline(text)
    sentiment = prediction[0]["label"]
    score = prediction[0]["score"]

    return sentiment, score


# Get user input
text = st.text_input("Enter some text here:")


        
# Home section
if choice == 'Home':
    st.image(gif_url, 
             use_column_width=True,
            width=400)
    st.markdown("<h1 style='text-align: center;'>Welcome</h1>", unsafe_allow_html=True)
    st.markdown("<p style='text-align: center;'>This is a Fake News Detection App.</p>", unsafe_allow_html=True)
    
    # Set Page Title
    st.title('TRUTH- A fake news detection app')
    st.markdown("Enter some text and we'll tell you if it's likely to be fake news or not!")
    
    
    if st.button('Predict'):
        # Show fake news detection output
        if text:
            with st.spinner('Checking if news is Fake...'):
                label, score = detect_fake_news(text)
                print(label, score)
                if label == "LABEL_1":
                    st.error(f"The text is likely to be fake news with a confidence score of {score*100:.2f}%!")
                else:
                    st.success(f"The text is likely to be genuine with a confidence score of {score*100:.2f}%!")
        else:
            with st.spinner('Checking if news is Fake...'):
                sales_data = pd.DataFrame({})
                try:
                    st.success(f"")
                except ValueError as e:
                    st.error(str(e))






        





                    
# Setting the page configurations
st.set_page_config(page_title="Fake News Detection App", page_icon="fas fa-exclamation-triangle", layout="wide", initial_sidebar_state="auto")

# Define the CSS style for the app
st.markdown(
"""
<style>
body {
    background-color: #f5f5f5;
}
h1 {
    color: #4e79a7;
}
</style>
""",
unsafe_allow_html=True
)

# About section
elif choice == 'About':
    # Load the banner image
    banner_image_url = "https://raw.githubusercontent.com/Gilbert-B/Forecasting-Sales/0d7b869515bniVmJZZxhyQ8Fee6m6SCLi64M8Ba72c/app/seer.png"
    banner_image = Image.open(requests.get(banner_image_url, stream=True).raw)
 
   # Display the banner image
    st.image(banner_image, use_column_width=True)
    st.markdown('''
            <p style='font-size: 20px; font-style: italic;font-style: bold;'>
                    TRUTH is a cutting-edge application specifically designed to combat the spread of fake news. 
                    Using state-of-the-art algorithms and advanced deep learning techniques, 
                    our app empowers users to detect and verify the authenticity of news articles. 
                    TRUTH provides accurate assessments of the reliability of news content. 
                    With its user-friendly interface and intuitive design, 
                    the app enables users to easily navigate and obtain trustworthy information in real-time. 
                    With TRUTH, you can take control of the news you consume and make informed decisions based on verified facts.
            </p>
            ''', unsafe_allow_html=True)