parass13 commited on
Commit
25ce2ec
Β·
verified Β·
1 Parent(s): 81e11bb

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +55 -27
dashboard.py CHANGED
@@ -14,7 +14,7 @@ from pages import about, community, user_guide
14
 
15
  # --- Config ---
16
  SUPABASE_URL = "https://fpbuhzbdtzwomjwytqul.supabase.co"
17
- SUPABASE_API_KEY = "your-api-key"
18
  SUPABASE_TABLE = "user_details"
19
 
20
  headers = {
@@ -92,41 +92,62 @@ def login_user(email, password):
92
  with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector") as demo:
93
  is_logged_in = gr.State(False)
94
 
95
- HOME_TAB_NAME = "🏠 Home"
96
- DETECT_TAB_NAME = "πŸ§ͺ Detect Deepfake"
97
- ABOUT_TAB_NAME = "ℹ️ About"
98
- COMMUNITY_TAB_NAME = "🌐 Community"
99
- GUIDE_TAB_NAME = "πŸ“˜ User Guide"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- with gr.Tabs(selected=HOME_TAB_NAME) as tabs:
102
- # --- Home Tab (Intro Page) ---
103
- with gr.Tab(HOME_TAB_NAME) as home_tab:
104
  with gr.Row():
105
  with gr.Column():
106
- gr.Markdown("""
107
- <div class="home-content">
108
- <h1>πŸ‘οΈβ€πŸ—¨οΈ Welcome to VerifiAI</h1>
109
- <p>Your trusted assistant for detecting deepfakes in images using AI.</p>
110
- <p>πŸ” Upload images, analyze authenticity, and learn how deepfakes work.</p>
111
- <p>πŸ‘‰ Use the tabs above to get started.</p>
112
- </div>
113
- """, elem_id="home-markdown")
114
-
115
- with gr.Tab(DETECT_TAB_NAME, visible=True) as detect_tab:
 
116
  with gr.Row():
117
  gr.Markdown("## Deepfake Detector")
118
  logout_btn = gr.Button("Logout")
119
  with gr.Row():
120
- image_input = gr.Image(type="pil", label="Upload Image", scale=1)
121
- with gr.Column(scale=1):
122
  result = gr.Textbox(label="Prediction Result", interactive=False)
123
  predict_btn = gr.Button("Predict", variant="primary")
124
 
125
- with gr.Tab(ABOUT_TAB_NAME): about.layout()
126
- with gr.Tab(COMMUNITY_TAB_NAME): community.layout()
127
- with gr.Tab(GUIDE_TAB_NAME): user_guide.layout()
 
128
 
129
- # --- CSS Styling ---
130
  gr.HTML("""
131
  <style>
132
  #home-markdown {
@@ -140,11 +161,18 @@ with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector") as
140
  """)
141
 
142
  # --- Callbacks ---
 
 
 
 
143
  def handle_logout():
144
- return False, "", ""
145
 
 
 
 
146
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
147
- logout_btn.click(fn=handle_logout, inputs=[], outputs=[is_logged_in, image_input, result])
148
  demo.load(fn=lambda: False, outputs=is_logged_in)
149
 
150
  if __name__ == "__main__":
 
14
 
15
  # --- Config ---
16
  SUPABASE_URL = "https://fpbuhzbdtzwomjwytqul.supabase.co"
17
+ SUPABASE_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZwYnVoemJkdHp3b21qd3l0cXVsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE5NDk3NzYsImV4cCI6MjA2NzUyNTc3Nn0.oAa2TNNPQMyOGk63AOMZ7XKcwYvy5m-xoSWyvMZd6FY"
18
  SUPABASE_TABLE = "user_details"
19
 
20
  headers = {
 
92
  with gr.Blocks(theme=gr.themes.Soft(), title="VerifiAI - Deepfake Detector") as demo:
93
  is_logged_in = gr.State(False)
94
 
95
+ HOME_TAB = "🏠 Home"
96
+ LOGIN_TAB = "πŸ” Login"
97
+ DETECT_TAB = "πŸ§ͺ Detect Deepfake"
98
+ ABOUT_TAB = "ℹ️ About"
99
+ COMMUNITY_TAB = "🌐 Community"
100
+ GUIDE_TAB = "πŸ“˜ User Guide"
101
+
102
+ with gr.Tabs(selected=HOME_TAB) as tabs:
103
+ # --- Home Tab ---
104
+ with gr.Tab(HOME_TAB):
105
+ gr.Markdown("""
106
+ <div class="home-content">
107
+ <h1>πŸ‘οΈβ€πŸ—¨οΈ Welcome to VerifiAI</h1>
108
+ <p>Your trusted assistant for detecting deepfakes in images using AI.</p>
109
+ <p>πŸ” Upload images, analyze authenticity, and learn how deepfakes work.</p>
110
+ <p>πŸ‘‰ Use the tabs above to get started.</p>
111
+ </div>
112
+ """, elem_id="home-markdown")
113
+
114
+ # --- Login Tab ---
115
+ with gr.Tab(LOGIN_TAB):
116
+ with gr.Row():
117
+ with gr.Column():
118
+ email_input = gr.Textbox(label="Email", placeholder="Enter your email")
119
+ password_input = gr.Textbox(label="Password", type="password", placeholder="Enter your password")
120
+ login_button = gr.Button("Login", variant="primary")
121
+ login_msg = gr.Textbox(label="Login Status", interactive=False)
122
 
 
 
 
123
  with gr.Row():
124
  with gr.Column():
125
+ gr.Markdown("### Or Sign Up")
126
+ name = gr.Textbox(label="Name")
127
+ phone = gr.Textbox(label="Phone (10 digits)")
128
+ email_reg = gr.Textbox(label="Email")
129
+ gender = gr.Radio(["Male", "Female", "Other"], label="Gender")
130
+ password_reg = gr.Textbox(label="Password", type="password")
131
+ register_btn = gr.Button("Register")
132
+ register_msg = gr.Textbox(label="Signup Status", interactive=False)
133
+
134
+ # --- Detection Tab (only usable when logged in) ---
135
+ with gr.Tab(DETECT_TAB) as detect_tab:
136
  with gr.Row():
137
  gr.Markdown("## Deepfake Detector")
138
  logout_btn = gr.Button("Logout")
139
  with gr.Row():
140
+ image_input = gr.Image(type="pil", label="Upload Image")
141
+ with gr.Column():
142
  result = gr.Textbox(label="Prediction Result", interactive=False)
143
  predict_btn = gr.Button("Predict", variant="primary")
144
 
145
+ # --- Static Tabs ---
146
+ with gr.Tab(ABOUT_TAB): about.layout()
147
+ with gr.Tab(COMMUNITY_TAB): community.layout()
148
+ with gr.Tab(GUIDE_TAB): user_guide.layout()
149
 
150
+ # --- CSS for center alignment ---
151
  gr.HTML("""
152
  <style>
153
  #home-markdown {
 
161
  """)
162
 
163
  # --- Callbacks ---
164
+ def handle_login(email, password):
165
+ success = login_user(email, password)
166
+ return (success, "βœ… Login successful!" if success else "❌ Login failed.")
167
+
168
  def handle_logout():
169
+ return False, "", "", ""
170
 
171
+ login_button.click(fn=handle_login, inputs=[email_input, password_input], outputs=[is_logged_in, login_msg])
172
+ register_btn.click(fn=register_user, inputs=[name, phone, email_reg, gender, password_reg], outputs=register_msg)
173
+ logout_btn.click(fn=handle_logout, outputs=[is_logged_in, image_input, result, login_msg])
174
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
175
+
176
  demo.load(fn=lambda: False, outputs=is_logged_in)
177
 
178
  if __name__ == "__main__":