From d55ebaed72372d8e6c67e1e606a50ca4e6e5cd01 Mon Sep 17 00:00:00 2001 From: Robin Cole Date: Fri, 18 Dec 2020 14:36:33 +0000 Subject: [PATCH] fix displayed confidences --- app/deepstack-ui.py | 26 +++++++++++++------------- app/utils.py | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/deepstack-ui.py b/app/deepstack-ui.py index 0663a5e..a365386 100644 --- a/app/deepstack-ui.py +++ b/app/deepstack-ui.py @@ -9,14 +9,7 @@ import deepstack.core as ds import utils import const -## 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", 20)) -DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None) - -DEFAULT_CONFIDENCE_THRESHOLD = 45 # percent +DEFAULT_CONFIDENCE_THRESHOLD = 0.45 TEST_IMAGE = "street.jpg" DEFAULT_ROI_Y_MIN = 0.0 @@ -30,6 +23,16 @@ DEFAULT_ROI = ( 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", 20)) +DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None) +DEEPSTACK_MIN_CONFIDENCE = os.getenv( + "DEEPSTACK_MIN_CONFIDENCE", DEFAULT_CONFIDENCE_THRESHOLD +) + predictions = None @@ -52,7 +55,7 @@ img_file_buffer = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg" st.sidebar.title("Parameters") st.text("Adjust parameters to select what is displayed") CONFIDENCE_THRESHOLD = st.sidebar.slider( - "Confidence threshold", 0, 100, DEFAULT_CONFIDENCE_THRESHOLD, 1 + "Confidence threshold", DEEPSTACK_MIN_CONFIDENCE, 1.0 ) if not DEEPSTACK_CUSTOM_MODEL: @@ -117,7 +120,7 @@ for obj in objects: name = obj["name"] confidence = obj["confidence"] box = obj["bounding_box"] - box_label = f"{name}: {confidence:.1f}%" + box_label = f"{name}" utils.draw_box( draw, @@ -154,6 +157,3 @@ for obj_type in obj_types: st.subheader("All filtered objects") st.write(objects) - -st.subheader("Deepstack raw response") -st.write(predictions) diff --git a/app/utils.py b/app/utils.py index 0a3b902..9346b61 100644 --- a/app/utils.py +++ b/app/utils.py @@ -49,7 +49,7 @@ def get_objects(predictions: list, img_width: int, img_height: int): "y": round(box["y_min"] + (box["height"] / 2), decimal_places), } name = pred["label"] - confidence = round(pred["confidence"] * 100, decimal_places) + confidence = pred["confidence"] objects.append( {