Skip to content

Commit

Permalink
Fix COCO Dataset Loading for Invisible Keypoints (#2035)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
felipe-parodi authored Dec 6, 2024
1 parent fff8761 commit 51de8cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sleap/io/format/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51de8cb

Please sign in to comment.