From 19a1d2934c7466bd60512f29773b2c753cac790c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=C6=B0=E1=BB=9Dng=20Giang?= Date: Fri, 26 Jul 2024 14:29:55 +0700 Subject: [PATCH] feat: update example with if __name__==__main__: in the main script --- src/main.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main.py b/src/main.py index f66f2d4..186833a 100644 --- a/src/main.py +++ b/src/main.py @@ -10,20 +10,10 @@ from pathlib import Path from demo.faces import detect_faces, recognize_face, train_face_recognizer - logging.basicConfig(level=logging.DEBUG) training_data_folder = Path("images") -show_capture_dialog = False -capture_image = False -show_add_captured_images_dialog = False - -labeled_faces = [] # Contains rect with label (for UI component) - -captured_image = None -captured_label = "" - def on_action_captured_image(state, id, action, payload): print("Captured image") @@ -93,7 +83,17 @@ def button_retrain_clicked(state): train_face_recognizer(training_data_folder) -webcam_md = """<|toggle|theme|> +if __name__ == "__main__": + show_capture_dialog = False + capture_image = False + show_add_captured_images_dialog = False + + labeled_faces = [] # Contains rect with label (for UI component) + + captured_image = None + captured_label = "" + + webcam_md = """<|toggle|theme|> |> -""" + """ -if __name__ == "__main__": # Create dir where the pictures will be stored if not training_data_folder.exists(): training_data_folder.mkdir() @@ -136,4 +135,4 @@ def button_retrain_clicked(state): gui = Gui(webcam_md) gui.add_library(Webcam()) - gui.run(port=9090) \ No newline at end of file + gui.run(port=9090)