From e5c0ceded0e18f87380c9efbe84da553a571775b Mon Sep 17 00:00:00 2001 From: Robin Cole Date: Thu, 21 Jan 2021 04:28:58 +0000 Subject: [PATCH] add debug mode --- README.md | 1 + app/deepstack-ui.py | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fa8ff44..cf09162 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The `deepstack-ui` is designed to be run in a docker container. The UI picks up - DEEPSTACK_API_KEY : the API key of your deepstack instance, if you have set one - DEEPSTACK_TIMEOUT : the timeout to wait for deepstack, default 30 seconds - DEEPSTACK_CUSTOM_MODEL : the name of a custom model, if you wish to use one +- DEEPSTACK_UI_DEBUG_MODE : options `True` or `False` (default). Lowers the minimum confidence threshold to 1% ``` From the root dir, build the deepstack-ui container from source and then run the UI, passing the `DEEPSTACK_IP` environment variable: diff --git a/app/deepstack-ui.py b/app/deepstack-ui.py index 07e489e..240bce6 100644 --- a/app/deepstack-ui.py +++ b/app/deepstack-ui.py @@ -9,9 +9,21 @@ import utils import const -DEFAULT_CONFIDENCE_THRESHOLD = 0.45 -MIN_CONFIDENCE_THRESHOLD = 0.1 +## Depstack setup +DEEPSTACK_IP = os.getenv("DEEPSTACK_IP", "localhost") +DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 80) +DEEPSTACK_API_KEY = os.getenv("DEEPSTACK_API_KEY", "") +DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 30)) +DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None) +DEEPSTACK_UI_DEBUG_MODE = bool(os.getenv("DEEPSTACK_UI_DEBUG_MODE", False)) + +if DEEPSTACK_UI_DEBUG_MODE: + st.title("IN DEEPSTACK_UI_DEBUG_MODE") + MIN_CONFIDENCE_THRESHOLD = 0.01 +else: + MIN_CONFIDENCE_THRESHOLD = 0.1 MAX_CONFIDENCE_THRESHOLD = 1.0 +DEFAULT_CONFIDENCE_THRESHOLD = 0.45 OBJECT_TEST_IMAGE = "street.jpg" FACE_TEST_IMAGE = "faces.jpg" FACE = "Face" @@ -28,12 +40,6 @@ DEFAULT_ROI_X_MAX, ) -## Depstack setup -DEEPSTACK_IP = os.getenv("DEEPSTACK_IP", "localhost") -DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 80) -DEEPSTACK_API_KEY = os.getenv("DEEPSTACK_API_KEY", "") -DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 30)) -DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None) predictions = None @@ -64,7 +70,7 @@ def process_image_face(pil_image, dsface): ) if deepstack_mode == FACE: - st.title("Deepstack Face recogntion") + st.title("Deepstack Face recognition") img_file_buffer = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"]) ## Process image @@ -249,3 +255,7 @@ def process_image_face(pil_image, dsface): st.subheader("All filtered objects") st.write(objects) + +if DEEPSTACK_UI_DEBUG_MODE: + st.subheader("All predictions data from Deepstack") + st.write(predictions)