parass13 commited on
Commit
5a53f13
Β·
verified Β·
1 Parent(s): b3b3474

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +4 -15
dashboard.py CHANGED
@@ -94,7 +94,7 @@ def login_user(email, password):
94
  return bcrypt.checkpw(password.encode(), stored_hash.encode())
95
  return False
96
 
97
- # --- UI Constants ---
98
  HOME_TAB_NAME = "🏠 Home"
99
  LOGIN_TAB_NAME = "πŸ” Login"
100
  DETECT_TAB_NAME = "πŸ§ͺ Detect Deepfake"
@@ -102,12 +102,10 @@ ABOUT_TAB_NAME = "ℹ️ About"
102
  COMMUNITY_TAB_NAME = "🌐 Community"
103
  GUIDE_TAB_NAME = "πŸ“˜ User Guide"
104
 
105
- # --- UI ---
106
- with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", initial_tab=HOME_TAB_NAME) as demo:
107
  is_logged_in = gr.State(False)
108
 
109
  with gr.Tabs(selected=HOME_TAB_NAME) as tabs:
110
- # --- Home Tab ---
111
  with gr.Tab(HOME_TAB_NAME) as home_tab:
112
  with gr.Row():
113
  with gr.Column():
@@ -120,7 +118,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", ini
120
  </div>
121
  """, elem_id="home-markdown")
122
 
123
- # --- Login Tab ---
124
  with gr.Tab(LOGIN_TAB_NAME) as login_tab:
125
  with gr.Row():
126
  with gr.Column(scale=1):
@@ -139,7 +136,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", ini
139
  password_signup = gr.Textbox(label="Create Password", type="password")
140
  signup_btn = gr.Button("Sign Up")
141
 
142
- # --- Detect Tab ---
143
  with gr.Tab(DETECT_TAB_NAME, visible=False) as detect_tab:
144
  with gr.Row():
145
  gr.Markdown("## Deepfake Detector")
@@ -150,12 +146,10 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", ini
150
  result = gr.Textbox(label="Prediction Result", interactive=False)
151
  predict_btn = gr.Button("Predict", variant="primary")
152
 
153
- # --- Other Tabs ---
154
  with gr.Tab(ABOUT_TAB_NAME): about.layout()
155
  with gr.Tab(COMMUNITY_TAB_NAME): community.layout()
156
  with gr.Tab(GUIDE_TAB_NAME): user_guide.layout()
157
 
158
- # --- CSS Styling ---
159
  gr.HTML("""
160
  <style>
161
  #home-markdown {
@@ -168,7 +162,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", ini
168
  </style>
169
  """)
170
 
171
- # --- Handlers ---
172
  def update_ui_on_auth_change(logged_in_status):
173
  if logged_in_status:
174
  return (
@@ -201,15 +194,11 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector", ini
201
  else:
202
  return gr.update(value=msg, visible=True), name, phone, email, gender, password, gr.update(open=True)
203
 
204
- # --- Bind Actions ---
205
  login_btn.click(fn=handle_login, inputs=[email_login, password_login], outputs=[is_logged_in, message_output])
206
  logout_btn.click(fn=handle_logout, inputs=[], outputs=[is_logged_in, email_login, password_login])
207
  is_logged_in.change(fn=update_ui_on_auth_change, inputs=is_logged_in, outputs=[login_tab, detect_tab, tabs, message_output])
208
- signup_btn.click(
209
- fn=handle_signup,
210
- inputs=[name_signup, phone_signup, email_signup, gender_signup, password_signup],
211
- outputs=[message_output, name_signup, phone_signup, email_signup, gender_signup, password_signup, signup_accordion]
212
- )
213
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
214
 
215
  if __name__ == "__main__":
 
94
  return bcrypt.checkpw(password.encode(), stored_hash.encode())
95
  return False
96
 
97
+ # --- UI ---
98
  HOME_TAB_NAME = "🏠 Home"
99
  LOGIN_TAB_NAME = "πŸ” Login"
100
  DETECT_TAB_NAME = "πŸ§ͺ Detect Deepfake"
 
102
  COMMUNITY_TAB_NAME = "🌐 Community"
103
  GUIDE_TAB_NAME = "πŸ“˜ User Guide"
104
 
105
+ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector") as demo:
 
106
  is_logged_in = gr.State(False)
107
 
108
  with gr.Tabs(selected=HOME_TAB_NAME) as tabs:
 
109
  with gr.Tab(HOME_TAB_NAME) as home_tab:
110
  with gr.Row():
111
  with gr.Column():
 
118
  </div>
119
  """, elem_id="home-markdown")
120
 
 
121
  with gr.Tab(LOGIN_TAB_NAME) as login_tab:
122
  with gr.Row():
123
  with gr.Column(scale=1):
 
136
  password_signup = gr.Textbox(label="Create Password", type="password")
137
  signup_btn = gr.Button("Sign Up")
138
 
 
139
  with gr.Tab(DETECT_TAB_NAME, visible=False) as detect_tab:
140
  with gr.Row():
141
  gr.Markdown("## Deepfake Detector")
 
146
  result = gr.Textbox(label="Prediction Result", interactive=False)
147
  predict_btn = gr.Button("Predict", variant="primary")
148
 
 
149
  with gr.Tab(ABOUT_TAB_NAME): about.layout()
150
  with gr.Tab(COMMUNITY_TAB_NAME): community.layout()
151
  with gr.Tab(GUIDE_TAB_NAME): user_guide.layout()
152
 
 
153
  gr.HTML("""
154
  <style>
155
  #home-markdown {
 
162
  </style>
163
  """)
164
 
 
165
  def update_ui_on_auth_change(logged_in_status):
166
  if logged_in_status:
167
  return (
 
194
  else:
195
  return gr.update(value=msg, visible=True), name, phone, email, gender, password, gr.update(open=True)
196
 
 
197
  login_btn.click(fn=handle_login, inputs=[email_login, password_login], outputs=[is_logged_in, message_output])
198
  logout_btn.click(fn=handle_logout, inputs=[], outputs=[is_logged_in, email_login, password_login])
199
  is_logged_in.change(fn=update_ui_on_auth_change, inputs=is_logged_in, outputs=[login_tab, detect_tab, tabs, message_output])
200
+ signup_btn.click(fn=handle_signup, inputs=[name_signup, phone_signup, email_signup, gender_signup, password_signup],
201
+ outputs=[message_output, name_signup, phone_signup, email_signup, gender_signup, password_signup, signup_accordion])
 
 
 
202
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
203
 
204
  if __name__ == "__main__":