Spaces:
Sleeping
Sleeping
Update app.py (#15)
Browse files- Update app.py (84ba156c4250e9eb6a5e1535e25ec39a19bc42e7)
Co-authored-by: Muhammad Khaqan Nasir <[email protected]>
app.py
CHANGED
@@ -1,52 +1,3 @@
|
|
1 |
-
# import sys
|
2 |
-
# from pathlib import Path
|
3 |
-
# import os
|
4 |
-
# import gdown
|
5 |
-
# import streamlit as st
|
6 |
-
|
7 |
-
# # Set page config - must be first Streamlit command
|
8 |
-
# st.set_page_config(
|
9 |
-
# page_title="TrueCheck - Fake News Detection",
|
10 |
-
# page_icon="π°",
|
11 |
-
# layout="wide"
|
12 |
-
# )
|
13 |
-
|
14 |
-
# MODEL_PATH = "models/saved/final_model.pt"
|
15 |
-
# # You need to replace this with the direct download link of your model file
|
16 |
-
# # To get the direct link: Right-click your model file in Google Drive -> Get link -> Make sure it's set to "Anyone with the link can view"
|
17 |
-
# # Then replace the file ID in the URL below
|
18 |
-
# GOOGLE_DRIVE_FILE_ID = "1xhYKuC5_Yri3mm3Ejt-SpB2WAVUTJvc_" # Replace with your actual file ID
|
19 |
-
# GOOGLE_DRIVE_URL = f"https://drive.google.com/uc?id={GOOGLE_DRIVE_FILE_ID}"
|
20 |
-
|
21 |
-
# @st.cache_resource
|
22 |
-
# def download_model():
|
23 |
-
# """Download model from Google Drive if not exists."""
|
24 |
-
# if not os.path.exists(MODEL_PATH):
|
25 |
-
# os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True)
|
26 |
-
# with st.spinner("Downloading model from Google Drive..."):
|
27 |
-
# try:
|
28 |
-
# gdown.download(GOOGLE_DRIVE_URL, MODEL_PATH, quiet=False)
|
29 |
-
# st.success("Model downloaded successfully!")
|
30 |
-
# except Exception as e:
|
31 |
-
# st.error(f"Failed to download model: {str(e)}")
|
32 |
-
# st.error("Please check your Google Drive link and make sure the file is publicly accessible.")
|
33 |
-
# return False
|
34 |
-
# return True
|
35 |
-
|
36 |
-
# # Add src directory to Python path
|
37 |
-
# src_path = Path(__file__).parent / "src"
|
38 |
-
# sys.path.append(str(src_path))
|
39 |
-
|
40 |
-
# if __name__ == "__main__":
|
41 |
-
# # Download model first
|
42 |
-
# if download_model():
|
43 |
-
# # Import and run the main app
|
44 |
-
# from src.app import main
|
45 |
-
# main()
|
46 |
-
# else:
|
47 |
-
# st.error("Cannot start the application without the model file.")
|
48 |
-
|
49 |
-
|
50 |
import sys
|
51 |
from pathlib import Path
|
52 |
import os
|
@@ -55,8 +6,8 @@ import streamlit as st
|
|
55 |
|
56 |
# Set page config - must be first Streamlit command
|
57 |
st.set_page_config(
|
58 |
-
page_title="
|
59 |
-
page_icon="
|
60 |
layout="wide",
|
61 |
initial_sidebar_state="expanded"
|
62 |
)
|
@@ -119,6 +70,29 @@ st.markdown("""
|
|
119 |
background-color: #FEE2E2;
|
120 |
color: #B71C1C;
|
121 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
</style>
|
123 |
""", unsafe_allow_html=True)
|
124 |
|
@@ -145,38 +119,74 @@ def download_model():
|
|
145 |
src_path = Path(__file__).parent / "src"
|
146 |
sys.path.append(str(src_path))
|
147 |
|
148 |
-
# Sidebar navigation
|
149 |
-
st.sidebar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
st.sidebar.markdown("---")
|
|
|
|
|
151 |
page = st.sidebar.radio(
|
152 |
"Navigate",
|
153 |
-
[
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
)
|
156 |
|
157 |
-
#
|
|
|
158 |
st.sidebar.markdown("""
|
159 |
-
<
|
160 |
-
<
|
161 |
-
<
|
162 |
-
|
|
|
|
|
163 |
""", unsafe_allow_html=True)
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
if __name__ == "__main__":
|
166 |
-
if
|
167 |
if download_model():
|
168 |
from src.app import main
|
169 |
main()
|
170 |
else:
|
171 |
st.markdown('<div class="flash-message error-message">Cannot start the application without the model file.</div>', unsafe_allow_html=True)
|
172 |
-
elif
|
173 |
from src.about import main
|
174 |
main()
|
175 |
-
elif
|
176 |
from src.terms_of_use import main
|
177 |
main()
|
178 |
-
elif
|
179 |
from src.privacy_policy import main
|
180 |
-
|
181 |
-
|
|
|
182 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import sys
|
2 |
from pathlib import Path
|
3 |
import os
|
|
|
6 |
|
7 |
# Set page config - must be first Streamlit command
|
8 |
st.set_page_config(
|
9 |
+
page_title="TruthCheck - Advanced Fake News Detector",
|
10 |
+
page_icon="π‘οΈ",
|
11 |
layout="wide",
|
12 |
initial_sidebar_state="expanded"
|
13 |
)
|
|
|
70 |
background-color: #FEE2E2;
|
71 |
color: #B71C1C;
|
72 |
}
|
73 |
+
|
74 |
+
/* Enhanced sidebar styling */
|
75 |
+
.stRadio > div {
|
76 |
+
gap: 0.5rem;
|
77 |
+
}
|
78 |
+
|
79 |
+
.stRadio > div > label {
|
80 |
+
padding: 0.5rem 1rem;
|
81 |
+
border-radius: 8px;
|
82 |
+
transition: all 0.3s ease;
|
83 |
+
cursor: pointer;
|
84 |
+
font-weight: 500;
|
85 |
+
}
|
86 |
+
|
87 |
+
.stRadio > div > label:hover {
|
88 |
+
background-color: #E8F0FE;
|
89 |
+
transform: translateX(5px);
|
90 |
+
}
|
91 |
+
|
92 |
+
.stRadio > div > label[data-checked="true"] {
|
93 |
+
background-color: #4B5EAA;
|
94 |
+
color: white;
|
95 |
+
}
|
96 |
</style>
|
97 |
""", unsafe_allow_html=True)
|
98 |
|
|
|
119 |
src_path = Path(__file__).parent / "src"
|
120 |
sys.path.append(str(src_path))
|
121 |
|
122 |
+
# Enhanced Sidebar navigation with icons
|
123 |
+
st.sidebar.markdown("""
|
124 |
+
<div style="text-align: center; margin-bottom: 2rem;">
|
125 |
+
<div style="font-size: 2.5rem; margin-bottom: 0.5rem;">π‘οΈ</div>
|
126 |
+
<h1 style="color: #4B5EAA; font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; line-height: 1.2;">
|
127 |
+
TruthCheck
|
128 |
+
</h1>
|
129 |
+
<p style="color: #666; font-size: 0.9rem; margin: 0; font-weight: 300; line-height: 1.3;">
|
130 |
+
Advanced Fake News Detector
|
131 |
+
</p>
|
132 |
+
</div>
|
133 |
+
""", unsafe_allow_html=True)
|
134 |
+
|
135 |
st.sidebar.markdown("---")
|
136 |
+
|
137 |
+
# Navigation with icons
|
138 |
page = st.sidebar.radio(
|
139 |
"Navigate",
|
140 |
+
[
|
141 |
+
"π Home",
|
142 |
+
"βΉοΈ About",
|
143 |
+
"π Terms of Use",
|
144 |
+
"π Privacy Policy",
|
145 |
+
"π₯ Team"
|
146 |
+
],
|
147 |
+
label_visibility="collapsed",
|
148 |
+
key="navigation"
|
149 |
)
|
150 |
|
151 |
+
# Add some spacing and additional info
|
152 |
+
st.sidebar.markdown("---")
|
153 |
st.sidebar.markdown("""
|
154 |
+
<div style="text-align: center; padding: 1.5rem; background: linear-gradient(135deg, #F8F9FA 0%, #E8F0FE 100%); border-radius: 12px; margin-top: 1rem; border: 1px solid #E0E7FF;">
|
155 |
+
<div style="font-size: 2rem; margin-bottom: 0.8rem;">π</div>
|
156 |
+
<p style="font-size: 0.85rem; color: #4B5EAA; margin: 0; font-weight: 500; line-height: 1.4;">
|
157 |
+
Protecting you from misinformation with AI-powered detection
|
158 |
+
</p>
|
159 |
+
</div>
|
160 |
""", unsafe_allow_html=True)
|
161 |
|
162 |
+
# Add footer info
|
163 |
+
st.sidebar.markdown("""
|
164 |
+
<div style="position: fixed; bottom: 1rem; left: 1rem; right: 1rem; text-align: center; padding: 0.5rem; background-color: rgba(255,255,255,0.9); border-radius: 8px; border-top: 1px solid #E0E0E0;">
|
165 |
+
<p style="font-size: 0.7rem; color: #888; margin: 0;">
|
166 |
+
Β© 2025 TruthCheck | AI-Powered
|
167 |
+
</p>
|
168 |
+
</div>
|
169 |
+
""", unsafe_allow_html=True)
|
170 |
+
|
171 |
+
# Clean up the page variable to remove icons for the conditional logic
|
172 |
+
page_clean = page.split(" ", 1)[1] if " " in page else page
|
173 |
+
|
174 |
if __name__ == "__main__":
|
175 |
+
if page_clean == "Home":
|
176 |
if download_model():
|
177 |
from src.app import main
|
178 |
main()
|
179 |
else:
|
180 |
st.markdown('<div class="flash-message error-message">Cannot start the application without the model file.</div>', unsafe_allow_html=True)
|
181 |
+
elif page_clean == "About":
|
182 |
from src.about import main
|
183 |
main()
|
184 |
+
elif page_clean == "Terms of Use":
|
185 |
from src.terms_of_use import main
|
186 |
main()
|
187 |
+
elif page_clean == "Privacy Policy":
|
188 |
from src.privacy_policy import main
|
189 |
+
main()
|
190 |
+
elif page_clean == "Team":
|
191 |
+
from src.team import main
|
192 |
main()
|