Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- 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 = "
|
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 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
""
|
114 |
-
|
115 |
-
|
|
|
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"
|
121 |
-
with gr.Column(
|
122 |
result = gr.Textbox(label="Prediction Result", interactive=False)
|
123 |
predict_btn = gr.Button("Predict", variant="primary")
|
124 |
|
125 |
-
|
126 |
-
with gr.Tab(
|
127 |
-
with gr.Tab(
|
|
|
128 |
|
129 |
-
# --- CSS
|
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 |
-
|
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__":
|