Skip to content

Add the long labeled-data model - #15

Draft
C-Achard wants to merge 2 commits into
cy/io-wide-readersfrom
cy/io-long-model
Draft

C-Achard wants to merge 2 commits into
cy/io-wide-readersfrom
cy/io-long-model

Conversation

@C-Achard

Copy link
Copy Markdown
Member

LabeledData: one long table, one row per frame and keypoint, that every format converts to and from. It checks columns, dtypes, density and identities when built, and converts to the wide DataFrame and to arrays.

  • Dense: an unlabeled keypoint is a row of NaN, rather than a missing row
  • No individual sentinel: single-animal data has no individual column, as DeepLabCut's three-level header has none.

Its methods only convert to forms that need nothing beyond core dependencies.

@C-Achard C-Achard added io: labeled-data CollectedData and machinelabels files consumer: deeplabcut Needed by or affects DeepLabCut consumer: napari Needed by or affects napari-deeplabcut labels Nov 24, 2026
@C-Achard C-Achard self-assigned this Nov 24, 2026
@C-Achard
C-Achard added this pull request to stack #18 November 24, 2026 16:24
@C-Achard
C-Achard marked this pull request as draft November 24, 2026 16:25
@C-Achard
C-Achard force-pushed the cy/io-long-model branch 2 times, most recently from 211a390 to d15f840 Compare November 24, 2026 16:35

@deruyter92 deruyter92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. A few high-level remarks that we may need to discuss first:

  • I think your LabeledData looks great a a new canonical long-format standard that we can use internally. I agree with the df as primary format with the to_array view that makes it available for training (or napari operations).
  • I think it would be useful to incorporate a single explicit LabeledDataLayout model that can be passed as context object next to the array view as handover to the training code, or anywhere else where arrays are used. I'd suggest a Pydantic model for this, which makes the validation easier.
  • As a final goal, my preference would go to a thinner public API that just offers this canonical LabeledData + read + write helpers. I love to hear your opinion on the feasibility of that. The elaborate wide format model and other public types in my view are mostly super important for the validation of current (legacy) formats that remain supported, but if possible, we can prevent downstream packages to deal with this kind of validation, and only keep that part private for dlccore. e.g. LabeledDataHeader, LabeledDataRowIndex, etc..

Let's discuss in more detail

@C-Achard
C-Achard force-pushed the cy/io-long-model branch 2 times, most recently from 4c491bb to 9286560 Compare November 30, 2026 08:14
@C-Achard C-Achard added this to the I/O - Video, Labeled data milestone Nov 30, 2026
@C-Achard
C-Achard force-pushed the cy/io-long-model branch 2 times, most recently from e83c3cc to 5777096 Compare November 30, 2026 11:07
- Rename the package to dlccore.io and add the dlccore license header
- Remove LabeledData.from_wide_df until the wide-to-long conversion it
  calls is added
- Name DataFrames `df`, never `frame`: LabeledData._frame becomes _df
- State in the docstrings that a format behind an optional extra is
  converted by free functions in its own module, not LabeledData methods
- Reword the LabeledDataArrays summary and note 3D support and NPZ
  export as TODO
@C-Achard

Copy link
Copy Markdown
Member Author
  • As a final goal, my preference would go to a thinner public API that just offers this canonical LabeledData + read + write helpers. I love to hear your opinion on the feasibility of that. The elaborate wide format model and other public types in my view are mostly super important for the validation of current (legacy) formats that remain supported, but if possible, we can prevent downstream packages to deal with this kind of validation, and only keep that part private for dlccore. e.g. LabeledDataHeader, LabeledDataRowIndex, etc..

I fully agree, I've made it private in #41 where I could, sorry, I indeed could have spent more time thinking about visibility, but the goal is an easy API, and hiding any complexity from consumers as relevant. See the new PR.

@C-Achard
C-Achard removed this pull request from stack #18 November 30, 2026 15:16
@C-Achard
C-Achard added this pull request to stack #42 November 30, 2026 15:16
@C-Achard

C-Achard commented Nov 30, 2026 •

Copy link
Copy Markdown
Member Author

I think it would be useful to incorporate a single explicit LabeledDataLayout model that can be passed as context object

Also agree, though if it's okay I'd make annotation the first consumer rather than training? I'll open a new PR with a first proposal. Then I'll work on outputs and frame/time indexed pose

(Mostly because I feel the napari-dlc duplication is the main gain from this)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer: deeplabcut Needed by or affects DeepLabCut consumer: napari Needed by or affects napari-deeplabcut io: labeled-data CollectedData and machinelabels files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants