Files changed (1) hide show
  1. app.py +150 -14
app.py CHANGED
@@ -1,3 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import sys
2
  from pathlib import Path
3
  import os
@@ -8,14 +57,73 @@ import streamlit as st
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
@@ -26,10 +134,10 @@ def download_model():
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
 
@@ -37,11 +145,39 @@ def download_model():
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.")
 
 
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
 
57
  st.set_page_config(
58
  page_title="TrueCheck - Fake News Detection",
59
  page_icon="📰",
60
+ layout="wide",
61
+ initial_sidebar_state="expanded"
62
  )
63
 
64
+ # Custom CSS for modern styling
65
+ st.markdown("""
66
+ <style>
67
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');
68
+
69
+ body {
70
+ font-family: 'Poppins', sans-serif;
71
+ background-color: #FFFFFF;
72
+ color: #333333;
73
+ }
74
+
75
+ .sidebar .sidebar-content {
76
+ background-color: #F4F7FA;
77
+ padding: 1rem;
78
+ }
79
+
80
+ .stButton>button {
81
+ background-color: #4B5EAA;
82
+ color: white;
83
+ border-radius: 8px;
84
+ padding: 0.5rem 1rem;
85
+ font-weight: 600;
86
+ transition: background-color 0.3s;
87
+ }
88
+
89
+ .stButton>button:hover {
90
+ background-color: #3A4A8C;
91
+ }
92
+
93
+ .stTextArea textarea {
94
+ border: 1px solid #E0E0E0;
95
+ border-radius: 8px;
96
+ padding: 1rem;
97
+ }
98
+
99
+ .hero-section {
100
+ background-color: #F4F7FA;
101
+ padding: 2rem;
102
+ border-radius: 12px;
103
+ margin-bottom: 2rem;
104
+ }
105
+
106
+ .flash-message {
107
+ padding: 1rem;
108
+ border-radius: 8px;
109
+ margin-bottom: 1rem;
110
+ font-weight: 600;
111
+ }
112
+
113
+ .success-message {
114
+ background-color: #E6F4EA;
115
+ color: #2E7D32;
116
+ }
117
+
118
+ .error-message {
119
+ background-color: #FEE2E2;
120
+ color: #B71C1C;
121
+ }
122
+ </style>
123
+ """, unsafe_allow_html=True)
124
+
125
  MODEL_PATH = "models/saved/final_model.pt"
126
+ GOOGLE_DRIVE_FILE_ID = "1xhYKuC5_Yri3mm3Ejt-SpB2WAVUTJvc_"
 
 
 
127
  GOOGLE_DRIVE_URL = f"https://drive.google.com/uc?id={GOOGLE_DRIVE_FILE_ID}"
128
 
129
  @st.cache_resource
 
134
  with st.spinner("Downloading model from Google Drive..."):
135
  try:
136
  gdown.download(GOOGLE_DRIVE_URL, MODEL_PATH, quiet=False)
137
+ st.markdown('<div class="flash-message success-message">Model downloaded successfully!</div>', unsafe_allow_html=True)
138
  except Exception as e:
139
+ st.markdown(f'<div class="flash-message error-message">Failed to download model: {str(e)}</div>', unsafe_allow_html=True)
140
+ st.markdown('<div class="flash-message error-message">Please check your Google Drive link and make sure the file is publicly accessible.</div>', unsafe_allow_html=True)
141
  return False
142
  return True
143
 
 
145
  src_path = Path(__file__).parent / "src"
146
  sys.path.append(str(src_path))
147
 
148
+ # Sidebar navigation
149
+ st.sidebar.title("TrueCheck")
150
+ st.sidebar.markdown("---")
151
+ page = st.sidebar.radio(
152
+ "Navigate",
153
+ ["Home", "Team", "About", "Terms of Use", "Privacy Policy"],
154
+ label_visibility="collapsed"
155
+ )
156
+
157
+ # SVG icon for sidebar
158
+ st.sidebar.markdown("""
159
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#4B5EAA" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-bottom: 1rem;">
160
+ <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
161
+ <polyline points="9 22 9 12 15 12 15 22"></polyline>
162
+ </svg>
163
+ """, unsafe_allow_html=True)
164
+
165
  if __name__ == "__main__":
166
+ if page == "Home":
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 page == "Team":
173
+ from src.team import main
174
+ main()
175
+ elif page == "About":
176
+ from src.about import main
177
+ main()
178
+ elif page == "Terms of Use":
179
+ from src.terms_of_use import main
180
  main()
181
+ elif page == "Privacy Policy":
182
+ from src.privacy_policy import main
183
+ main()