Skip to content

[Sync] merge to main for 3.0.3 release - #3567

Merged
MMathisLab merged 67 commits into
mainfrom
dev
Nov 14, 2026
Merged

MMathisLab merged 67 commits into
mainfrom
dev

Conversation

@Ayskin

@Ayskin Ayskin commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

DeepLabCut 3.0.3

DeepLabCut 3.0.3 is a patch release with better handling of undetected poses along inference and security-related dependency bumps, as well as adding more flexibility to PyTorch data loading.

Highlights

Important changes

Train settings: dataloader_kwargs (#3550, #3576)

TrainSettingsConfig now has a dataloader_kwargs field for forwarding additional parameters to the PyTorch DataLoader (e.g. persistent_workers, prefetch_factor).
Please see related documentation.

Note

pytorch_config.yaml only contains dataloader_kwargs when set manually. Configurations that leave it unset can still be used in <=3.0.2; configurations that did set it cannot, unless the field is removed.

Features and enhancements

Bug fixes and tests

Dependencies and security

Code removal

juan-cobos and others added 30 commits August 3, 2026 13:57
Replace random test inputs with deterministic fixtures and stable pytest ids across the pose-estimation PyTorch tests. This avoids run-after-discovery desync, which makes the tests impossible to run in e.g. the VSCode pytest extension
Assign per-case RNG seeds to the PyTorch pose estimation tests and replace a few random samples with fixed edge-case parameters. This keeps test IDs stable while covering a wider range of augmentation, batch size, and input-size combinations.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
The GUI updater was invoking `uv pip install -U ...`, which can upgrade the wrong packages when requirements include extras. This patch strips extras from package specs and uses `--upgrade-package` with the canonical distribution names, preserving the requested package set while keeping the pip fallback intact. It also adds regression coverage for the uv-only and uv-then-pip command-building paths.
The function had no callers and could not run (tqdm.tqdm on the tqdm class).
Per maintainer discussion in #3532 it is removed rather than fixed. Also
drops the numpy, tqdm and deeplabcut imports that only it used.
…tings

Training on small datasets over hundreds of epochs respawns DataLoader
workers every epoch (persistent_workers=False) with a fixed prefetch depth
of 2, leaving GPU utilization on the table for CPU-heavy pipelines. These
knobs existed in PyTorch but were not reachable through TrainSettingsConfig,
pytorch_config.yaml, or pytorch_cfg_updates (strict schema rejects them).

- TrainSettingsConfig: add dataloader_persistent_workers (default False)
  and dataloader_prefetch_factor (default None = PyTorch default 2,
  validated >= 1).
- train(): forward both to the training DataLoader when
  dataloader_workers > 0; warn and ignore them for single-process loading
  (PyTorch requires workers for both options). .get() with defaults keeps
  old persisted configs without the keys working.
- base.yaml / base_detector.yaml defaults + pytorch_config.md docs.

Adds config roundtrip/validation tests and train() DataLoader-kwarg tests.

Addresses #3547
This change adds a Contributing section to AGENTS.md documenting new human review disclosure, issue/PR checks, dev setup commands, and testing expectations for DeepLabCut contributions.
…ment

Fix wrong multi-animal tracking when ellipse fit fails on one animal
…-state-dict

Add missing RunnerConfig field
…data-to-new-project

Remove unused `adapt_labeled_data_to_new_project` from `deeplabcut.utils`
…ckage

Fix uv package upgrades in GUI updater
Bumps [soupsieve](https://github.com/facelessuser/soupsieve) from 2.8.4 to 2.9.
- [Release notes](https://github.com/facelessuser/soupsieve/releases)
- [Commits](facelessuser/soupsieve@2.8.4...2.9)

---
updated-dependencies:
- dependency-name: soupsieve
  dependency-version: '2.9'
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
deruyter92 and others added 2 commits October 23, 2026 17:09
…for zero-detections and unreadable video handling (#3488)

* fix _generate_output_data crash on empty predictions

Handle the valid case where PyTorch video inference returns zero predictions.

* Allow create_df_from_prediction() to handle an empty predictions list.

videos with zero
detections would fail after serialization on `np.stack([])`

Return an
empty DataFrame with the expected DLC column schema instead and add a
regression test for the empty-output case.

* Treat zero predictions as a distinct warning case in `video_inference()`

* Don't write dataframe for empty predictions

- add informative warning
- add guard in dataframe export: raise ValueError if no predictions

* update test_videos: pop `"PAFinds"` before comparison

* update test_videos: assert no DF is written for empty predictions

* Return empty-detection inference results

Ensure inference emits results for images whenever a prediction exists, even when no detections are produced and thus no queue item is generated. This avoids dropping frames with valid predictions but empty detection outputs.

* Use CTD predictions for video output

Fixes a mismatch in `analyze_videos` where the DataFrame export step still used `predictions` instead of `ctd_predictions`. This ensures saved video analysis results use the corrected prediction set from the current processing path.

* Handle empty prediction outputs gracefully

When a video produces no pose predictions, analysis now writes all-NaN placeholder predictions so downstream HDF5 export and filtering can continue instead of failing on an empty result set. The DataFrame export path was adjusted to handle these fallback frames correctly and raises clearer errors only for genuinely invalid empty input. FMPOSE 3D inference now also raises a clear RuntimeError when no 2D poses are detected for a video.

* Reuse shared frame key width helper

Move frame key zero-padding logic into `runners.shelving.frame_key_width` and use it from both video output generation and shelf writing. This keeps frame key formatting consistent across full-data exports and on-the-fly shelving, while preserving the default width when the frame count is unknown.

* Clarify video inference warnings

Refines `video_inference` logging so empty results distinguish unreadable videos from detector misses, and keeps re-encoding guidance for partial reads. Expands tests to cover zero-prediction, partial-prediction, and shelf-writer cases.

* Go back to ValueError for empty predictions

* Remove NaN fallback for empty video predictions

Simplifies `analyze_videos` by always passing the inference `predictions` directly to `create_df_from_prediction` when `save_as_df` is enabled, and removes the special-case branch that generated all-NaN placeholder rows when no predictions were produced. The unused `_nan_predictions` helper and its warning/error handling were also deleted.

* Fix CTD export guard for empty predictions

Use the CTD prediction list when deciding whether to write the dataframe, so `.h5` export still happens based on the converted CTD results instead of an unrelated variable. The warning now also explains that the CTD pickle had no frames when export is skipped.

* Clarify empty CTD prediction handling

Add an explanatory comment in `analyze_videos` documenting why `ctd_predictions` can be empty, and why the code warns and skips dataframe creation instead of raising. This captures edge cases like zero-frame pickle output and `save_as_df=False`.

* Centralize test fakes

* Add test for async with no images

* Clarify async inference test comment

Refines the test docstring in `test_runners_inference.py` to describe the async behavior more clearly by comparing it to the sequential path without implying a regression pin.

* Use shared frame key width helper

ShelfWriter now always derives its frame key width through `frame_key_width()` instead of keeping a separate default. This removes duplicated fallback logic and keeps frame index formatting consistent with the shared helper.

* Don't write pickle for unreadable video

All readable frames yield a prediction. An empty list of predictions means the video  could not be read, and no pickle should be saved: it would be detected as analyzed.

* Video inference: update warning for empty predictions

since #3488, all readable frames yield a prediction (even when no animal was detectied) an empty predictions means no readable frames.

* InferenceRunner: don't emit results for producer exceptions

* update code comment

* fix ShelfWriter: report zero framens when empty

* Skip unreadable videos with shelf writer + improve docstring and log message

* Fix  warning typo + update tests

* Remove unreachable CTD empty-export branch and reword FMPose error

---------

Co-authored-by: C-Achard <[email protected]>
Bumps [pillow](https://github.com/python-pillow/Pillow) from 12.2.0 to 12.3.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](python-pillow/Pillow@12.2.0...12.3.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-version: 12.3.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@Ayskin Ayskin added the sync to main For dev -> main merges requiring approval label Oct 26, 2026
@C-Achard

Copy link
Copy Markdown
Member

Dev docs failure is being fixed in #3568

C-Achard and others added 3 commits October 27, 2026 11:23
Bump the dev docs workflow python version to 3.12 to avoid failure on 3.10 inompcatible pymdown/mkdocstrings pair being installed in CI.

Code is parsed, not imported, so this would not hide failures from using old python patterns or 3.13+ only-patterns (other jobs would catch it ideally), so there should be no immediate downside to the bump.

Co-authored-by: Jaap de Ruyter van Steveninck <[email protected]>
@MMathisLab

Copy link
Copy Markdown
Member

Let's be sure it's fully backwards compatible; otherwise it's not a 3.0.3 but a major release bump ;)

Should be a fix for this; check version, delete row, etc:

PR adds an extra field in pytorch_config.yaml. Model training configurations created in 3.0.3 can not be used in <=3.0.2 without removing that field.

@MMathisLab MMathisLab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ayskin and others added 6 commits November 3, 2026 10:41
- Combines dependabot security updates #3572, #3573, #3574 and #3575, rebuilt on dev
Bump pyasn1, oauthlib, gitpython and filelock
…e forward compatibility (#3576)

* add model_serializer for TrainSettingsConfig.dataloader_kwargs

omit dataloader_kwargs in the .to_dict, .to_yaml and to_commented_map views when the field is not configured (empty or None)

This keeps forward compatibility in older deeplabcut versions

* dataset_kwargs: Use pydantic 2.11 `exclude_if` instead of model serializer

* update pyproject.toml + uv lock: require pydantic 2.11

* Update pyproject.toml

* update uv.lock
* Run trajectory plots after analysis completes

Store plotting options before starting the worker and defer `plot_trajectories(showfigures=True)` to a main-thread finished slot. The analysis pipeline now always runs with `showfigures=False`, only opens trajectory plots when analysis succeeds, and centralizes button/progress-bar reset in the completion handler.

* Fix trajectory plot timing with deferred timer

Refactor post-analysis trajectory plot display to use a single-shot QTimer, ensuring the UI (button re-enable, progress bar hide) fully updates before plots are shown. Also fixes the `_handle_analysis_error` slot signature to accept the error argument, and adds error handling around trajectory plot display.

* Avoid duplicate trajectory plotting in GUI

Update the Analyze Videos tab so `deeplabcut.plot_trajectories(...)` only runs when `plot_trajectories` is enabled and `show_trajectory_plots` is not. This prevents triggering the plotting routine in cases where trajectory plots are already being shown through the separate display flow.

* Refactor pending plot cleanup logic

Extract repeated None-assignment into `_clear_pending_trajectory_plots()` helper. Also move the button re-enable and progress bar hide after the plot timer/clear logic to ensure UI updates happen regardless of plot path.

* Refactor: Each batch now saves its trajectory plots to disk as it finishes

---------

Co-authored-by: Jaap de Ruyter van Steveninck <[email protected]>
Co-authored-by: Mackenzie Weygandt Mathis <[email protected]>
* Add Cookbook recipe: fish swimming kinematics from DeepLabCut

Adds a post-processing recipe showing how to derive swimming-kinematics
metrics (tail-beat frequency, swimming speed, body curvature, diel index)
from single-animal DeepLabCut pose tracks, and how to use the
Spearman-Brown reliability index to choose a reliable observation
duration. Registers the page in the docs table of contents.

Adapted from Hwang et al. 2026, Ecological Informatics 95, 103760.

* move fish kinematics recipe to dlc-utils community contributions

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Mackenzie Weygandt Mathis <[email protected]>
Co-authored-by: Jaap de Ruyter van Steveninck <[email protected]>
@deruyter92

Copy link
Copy Markdown
Collaborator

Let's be sure it's fully backwards compatible

@MMathisLab agreed, thanks. This is now fixed in #3576, and merged into this PR.

For complete reference:
#3576 fixes the original PR #3550 - The new field dataloader_kwargs is now left out of saved configs to ensure forwards compatibility: DeepLabCut <= 3.0.2 can run with configs from newer versions. (Users who deliberately set dataloader_kwargs in their config can still opt-in to the new feature in DLC >= 3.0.3)

@deruyter92
deruyter92 added this pull request to stack #3584 November 11, 2026 17:30
@MMathisLab
MMathisLab merged commit 209f0d5 into main Nov 14, 2026
155 of 181 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0.3 sync to main For dev -> main merges requiring approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants