From c83d99be4e9519ac067c171aace31f6d4a56fb44 Mon Sep 17 00:00:00 2001 From: Heiru Wu Date: Mon, 9 Sep 2024 23:56:45 +0800 Subject: [PATCH] fix(ray): fix bounding box output type --- instill/helpers/init-templates/Dockerfile | 2 +- instill/helpers/ray_io.py | 32 +++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/instill/helpers/init-templates/Dockerfile b/instill/helpers/init-templates/Dockerfile index eaeb9c1..de6ac7d 100644 --- a/instill/helpers/init-templates/Dockerfile +++ b/instill/helpers/init-templates/Dockerfile @@ -15,7 +15,7 @@ RUN for package in ${SYSTEM_PACKAGES}; do \ ARG PACKAGES RUN for package in ${PACKAGES}; do \ - pip install --default-timeout=1000 --no-cache-dir $package; \ + pip install --default-timeout=1000 $package; \ done; COPY --chown=ray:users --exclude=model.py . . diff --git a/instill/helpers/ray_io.py b/instill/helpers/ray_io.py index 98c92ff..ab98137 100644 --- a/instill/helpers/ray_io.py +++ b/instill/helpers/ray_io.py @@ -158,10 +158,10 @@ def construct_task_detection_output( objects = [] for cat, sc, bb in zip(category, score, bbox): bb_dict = { - "top": bb[1], - "left": bb[0], - "width": bb[2], - "height": bb[3], + "top": float(bb[1]), + "left": float(bb[0]), + "width": float(bb[2]), + "height": float(bb[3]), } objects.append( {"category": str(cat), "score": float(sc), "bounding-box": bb_dict} @@ -210,10 +210,10 @@ def construct_task_ocr_output( objects = [] for txt, sc, bb in zip(text, score, bbox): bb_dict = { - "top": bb[1], - "left": bb[0], - "width": bb[2], - "height": bb[3], + "top": float(bb[1]), + "left": float(bb[0]), + "width": float(bb[2]), + "height": float(bb[3]), } objects.append( {"text": str(txt), "score": float(sc), "bounding-box": bb_dict} @@ -264,10 +264,10 @@ def construct_task_instance_segmentation_output( objects = [] for r, cat, sc, bb in zip(rle, category, score, bbox): bb_dict = { - "top": bb[1], - "left": bb[0], - "width": bb[2], - "height": bb[3], + "top": float(bb[1]), + "left": float(bb[0]), + "width": float(bb[2]), + "height": float(bb[3]), } objects.append( { @@ -369,10 +369,10 @@ def construct_task_keypoint_output( point_list.append({"x": kp[0], "y": kp[1], "v": kp[2]}) bb_dict = { - "top": bb[1], - "left": bb[0], - "width": bb[2], - "height": bb[3], + "top": float(bb[1]), + "left": float(bb[0]), + "width": float(bb[2]), + "height": float(bb[3]), } objects.append( {"keypoints": point_list, "score": float(sc), "bounding-box": bb_dict}