From 23aba1e2bf86f8039c86b32c17149786311a7848 Mon Sep 17 00:00:00 2001 From: Felipe Parodi <53239931+felipe-parodi@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:36:59 -0500 Subject: [PATCH] Update coco.py # Fix COCO Dataset Loading for Invisible Keypoints ## Issue When loading COCO datasets, keypoints marked as invisible (flag=0) are currently skipped and later placed randomly within the instance's bounding box. However, in COCO format, these keypoints may still have valid coordinate information that should be preserved (see toy_dataset for expected vs. current behavior). ## Changes Modified the COCO dataset loading logic to: - Check if invisible keypoints (flag=0) have non-zero coordinates - If coordinates are (0,0), skip the point (existing behavior) - If coordinates are not (0,0), create the point at those coordinates but mark it as not visible - Maintain existing behavior for visible (flag=2) and labeled --- sleap/io/format/coco.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sleap/io/format/coco.py b/sleap/io/format/coco.py index 25122e4d0..89b3a450c 100644 --- a/sleap/io/format/coco.py +++ b/sleap/io/format/coco.py @@ -180,6 +180,9 @@ def read( if flag == 0: # node not labeled for this instance + if (x, y) != (0, 0): + # If labeled but invisible, place the node at the coord + points[node] = Point(x, y, False) continue is_visible = flag == 2