Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -186,9 +186,27 @@ with gr.Blocks(title="SecureFace ID – Privacy-First Recognition") as demo:
|
|
| 186 |
status = gr.Markdown()
|
| 187 |
btn.click(enroll_person, [name_in, img_in], status)
|
| 188 |
|
| 189 |
-
|
| 190 |
-
gr.Markdown(
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
demo.launch()
|
|
|
|
| 186 |
status = gr.Markdown()
|
| 187 |
btn.click(enroll_person, [name_in, img_in], status)
|
| 188 |
|
| 189 |
+
with gr.Tab("Database"):
|
| 190 |
+
gr.Markdown("### Registered People (live view)")
|
| 191 |
+
|
| 192 |
+
# This component will be refreshed every time someone enrolls
|
| 193 |
+
people_list = gr.Markdown()
|
| 194 |
+
|
| 195 |
+
def refresh_database():
|
| 196 |
+
if not os.path.exists(KNOWN_EMBS_PATH):
|
| 197 |
+
return "### Empty database\nAdd someone using the Enroll tab →"
|
| 198 |
+
current_names = np.load(KNOWN_NAMES_PATH, allow_pickle=True).tolist()
|
| 199 |
+
if len(current_names) == 0:
|
| 200 |
+
return "### Empty database"
|
| 201 |
+
text = f"**{len(current_names)} people in database:**\n\n"
|
| 202 |
+
for i, name in enumerate(sorted(current_names), 1):
|
| 203 |
+
text += f"{i}. **{name}**\n"
|
| 204 |
+
return text
|
| 205 |
+
|
| 206 |
+
# Show list on first load
|
| 207 |
+
demo.load(refresh_database, outputs=people_list)
|
| 208 |
+
|
| 209 |
+
# Refresh list every time someone clicks Enroll
|
| 210 |
+
btn.click(refresh_database, outputs=people_list)
|
| 211 |
|
| 212 |
demo.launch()
|