Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
-
import cv2
|
| 4 |
-
import numpy as np
|
| 5 |
-
from utils import load_model, preprocess, verify_identity
|
| 6 |
-
|
| 7 |
-
model = load_model("
|
| 8 |
-
registration_dir = "registered_users"
|
| 9 |
-
|
| 10 |
-
def register_user(name, image):
|
| 11 |
-
user_path = os.path.join(registration_dir, name)
|
| 12 |
-
os.makedirs(user_path, exist_ok=True)
|
| 13 |
-
image.save(os.path.join(user_path, f"{name}_1.jpg"))
|
| 14 |
-
return f"User {name} registered successfully."
|
| 15 |
-
|
| 16 |
-
def verify(image):
|
| 17 |
-
result = verify_identity(model, image, registration_dir)
|
| 18 |
-
return result
|
| 19 |
-
|
| 20 |
-
with gr.Blocks() as demo:
|
| 21 |
-
gr.Markdown("## 🧠 Siamese Face Verification")
|
| 22 |
-
with gr.Tab("Register"):
|
| 23 |
-
name = gr.Textbox(label="Enter Your Name")
|
| 24 |
-
reg_img = gr.Image(source="webcam", label="Click Your Photo", shape=(105,105))
|
| 25 |
-
reg_btn = gr.Button("Register")
|
| 26 |
-
reg_output = gr.Textbox()
|
| 27 |
-
reg_btn.click(fn=register_user, inputs=[name, reg_img], outputs=reg_output)
|
| 28 |
-
|
| 29 |
-
with gr.Tab("Verify"):
|
| 30 |
-
ver_img = gr.Image(source="webcam", label="Click Your Photo", shape=(105,105))
|
| 31 |
-
ver_btn = gr.Button("Verify")
|
| 32 |
-
ver_output = gr.Textbox()
|
| 33 |
-
ver_btn.click(fn=verify, inputs=ver_img, outputs=ver_output)
|
| 34 |
-
|
| 35 |
-
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import cv2
|
| 4 |
+
import numpy as np
|
| 5 |
+
from utils import load_model, preprocess, verify_identity
|
| 6 |
+
|
| 7 |
+
model = load_model("siamese_model.h5")
|
| 8 |
+
registration_dir = "registered_users"
|
| 9 |
+
|
| 10 |
+
def register_user(name, image):
|
| 11 |
+
user_path = os.path.join(registration_dir, name)
|
| 12 |
+
os.makedirs(user_path, exist_ok=True)
|
| 13 |
+
image.save(os.path.join(user_path, f"{name}_1.jpg"))
|
| 14 |
+
return f"User {name} registered successfully."
|
| 15 |
+
|
| 16 |
+
def verify(image):
|
| 17 |
+
result = verify_identity(model, image, registration_dir)
|
| 18 |
+
return result
|
| 19 |
+
|
| 20 |
+
with gr.Blocks() as demo:
|
| 21 |
+
gr.Markdown("## 🧠 Siamese Face Verification")
|
| 22 |
+
with gr.Tab("Register"):
|
| 23 |
+
name = gr.Textbox(label="Enter Your Name")
|
| 24 |
+
reg_img = gr.Image(source="webcam", label="Click Your Photo", shape=(105,105))
|
| 25 |
+
reg_btn = gr.Button("Register")
|
| 26 |
+
reg_output = gr.Textbox()
|
| 27 |
+
reg_btn.click(fn=register_user, inputs=[name, reg_img], outputs=reg_output)
|
| 28 |
+
|
| 29 |
+
with gr.Tab("Verify"):
|
| 30 |
+
ver_img = gr.Image(source="webcam", label="Click Your Photo", shape=(105,105))
|
| 31 |
+
ver_btn = gr.Button("Verify")
|
| 32 |
+
ver_output = gr.Textbox()
|
| 33 |
+
ver_btn.click(fn=verify, inputs=ver_img, outputs=ver_output)
|
| 34 |
+
|
| 35 |
+
demo.launch()
|