Skip to content

feat(gui): centroid-only models foundation - skeleton template + feature flag (1/2)#2723

Draft
talmo wants to merge 1 commit into
developfrom
centroid-models/01-foundation
Draft

feat(gui): centroid-only models foundation - skeleton template + feature flag (1/2)#2723
talmo wants to merge 1 commit into
developfrom
centroid-models/01-foundation

Conversation

@talmo

@talmo talmo commented May 28, 2026

Copy link
Copy Markdown
Member

Do not merge yet

This is the foundation half (1/2) of a two-PR stack adding centroid-only model training to the SLEAP GUI. It is a draft and should not be merged or marked ready until the stack is reviewed together and the upstream inference work has landed (see below).

Summary

Lays the groundwork for centroid-only model support behind a single, easily-removable feature flag, so default behavior is byte-identical to today.

A "centroid-only" model is a standalone multi-animal centroid detector with a single-node skeleton (one node named centroid), as opposed to centroid being only the first stage of a top-down pipeline.

This PR contains no user-visible behavior on its own — it ships the skeleton template and the feature-flag plumbing that PR 2 builds on.

What's in this PR

  • sleap/skeletons/centroid.json — a single-node skeleton template (one node named centroid, no edges, with an RGBA preview image). The SkeletonDock template chooser auto-populates from this folder, so no code wiring is needed. Shipped verbatim rather than regenerated because the SkeletonEncoder drops edge-less nodes (see companion fix note below).
  • sleap/gui/learning/features.pyis_centroid_models_enabled(), gated on the SLEAP_ENABLE_CENTROID_MODELS environment variable. Default is OFF; truthy values are 1/true/yes/on (case-insensitive). This module is intentionally temporary: it gates UI for a feature whose inference half is still blocked upstream. Remove it and its call sites once centroid-only inference lands.
  • Tests covering the env-var parsing and that the shipped template loads to a single-node, edge-less skeleton with an RGBA preview.

Scope: training only

This stack adds training support only. Centroid-only inference is intentionally deferred — it is still blocked upstream on sleap-nn (epic talmolab/sleap-nn#508 / PR talmolab/sleap-nn#562). Until that lands, users can train and export a centroid-only model but not yet run it from the GUI.

Feature flag (default off)

The entire feature is gated behind one flag, is_centroid_models_enabled() (driven by SLEAP_ENABLE_CENTROID_MODELS, default off). With the flag off, develop is byte-identical for users. The flag and its call sites are designed to be deleted in a single, clean removal once inference lands.

Companion sleap-io fix

There is a companion fix in sleap-io for a SkeletonEncoder bug where edge-less nodes (i.e. a single-node skeleton) get dropped during encoding. Because of that bug, centroid.json is shipped verbatim rather than round-tripped through the encoder.

Stack

This is PR 1 of 2. PR 2 (training pipeline UX) is stacked on top of this branch.

github-actions Bot pushed a commit that referenced this pull request May 28, 2026
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Docs Preview

Preview URL https://docs.sleap.ai/pr/2723/
Commit 8ceb0b27776b8592bf8b789083e67bfe15a8353c

API changes detected - View API Reference

This preview will be removed when the PR is closed.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.71%. Comparing base (1672180) to head (8ceb0b2).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2723   +/-   ##
========================================
  Coverage    66.71%   66.71%           
========================================
  Files           96       97    +1     
  Lines        20686    20691    +5     
========================================
+ Hits         13800    13805    +5     
  Misses        6886     6886           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ure flag (1/2)

Lay the groundwork for centroid-only model support behind a single,
easily-removable feature flag so default behavior is unchanged.

- Add sleap/skeletons/centroid.json: a single-node skeleton template
  with one node named "centroid" and no edges. The SkeletonDock template
  chooser auto-populates from this folder, so no code wiring is needed.
  Copied from a pre-verified candidate (the SkeletonEncoder drops
  edge-less nodes, so the file is shipped verbatim rather than
  regenerated). Includes an RGBA preview image.
- Add sleap/gui/learning/features.py with is_centroid_models_enabled(),
  gated on the SLEAP_ENABLE_CENTROID_MODELS environment variable
  (default: off; truthy: "1"/"true"/"yes"/"on", case-insensitive).
  The helper also honors the "Experimental Features" toggle in the Help
  menu via an experimental_features argument threaded in by the caller;
  the env var remains a developer override. This module is temporary: it
  gates UI for a feature whose inference half is still blocked on
  sleap-nn (epic talmolab/sleap-nn#508 / PR #562). Remove it and its
  call sites once centroid-only inference lands.

Tests cover the flag's env-var parsing, the Experimental Features
toggle, and that the shipped template loads to a single-node, edge-less
skeleton with an RGBA preview.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant