Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
b57d849
add code of hrnet + coam backbone
LucZot Feb 2, 2024
0690899
refactor and finish hrnet+coam integration
LucZot Feb 2, 2024
c6e6668
add ctd configs
LucZot Feb 2, 2024
78ebb57
initial work on generative sampling
n-poulsen Feb 14, 2024
4503b87
buctd cont I
LucZot Mar 21, 2024
ec4aa87
prepare dataloader for loading cond pose with gen sampling
LucZot Mar 21, 2024
6c0cf37
adapt hrnet-coam output to hrnet code
LucZot Mar 21, 2024
704a0c6
put kpt encoders into modules
LucZot Mar 21, 2024
a53ba27
add kpt encoder to hrnet_coam
LucZot Mar 21, 2024
964dd5c
small additions
LucZot Mar 22, 2024
3e85fd1
init CTD inference
LucZot Mar 22, 2024
8c94c7b
test CTD training - I
LucZot Mar 22, 2024
107ea70
buctd training!
LucZot Mar 26, 2024
f8b7fa9
remove one for loop in _get_condition_matrix
LucZot Mar 27, 2024
9bb4ae6
optim trials for cond kpt encoding
LucZot Mar 28, 2024
ac29688
add ctd evaluation based on loaded bu predictions
LucZot Apr 7, 2024
bb31cc1
use only overlapping individuals for swapping error
LucZot Apr 8, 2024
ee7918f
add marmoset bu path
LucZot Apr 22, 2024
b83e8ec
Merge branch 'main' into lucas/buctd_integration
LucZot Apr 22, 2024
e769277
scale cond_kpts in collate
LucZot Apr 22, 2024
006b13a
switch back to original function for creating conditional matrix
LucZot Apr 24, 2024
1ccf705
update benchmark scripts
LucZot May 22, 2024
a4973c9
add hflip to internal benchmark script
LucZot May 22, 2024
304f9c2
pad with black pixels instead of context for CTD + add margin for BU-…
LucZot May 22, 2024
0b4be31
add script for testing ctd performance with coco api
LucZot May 22, 2024
c93c1bd
make CTD test inference compatible with previous code
LucZot May 23, 2024
9c9ef50
add bu name to output path names for CTD test inference
LucZot May 23, 2024
4de92f9
add bu name to output path names for CTD test inference - fix
LucZot May 23, 2024
fbbaf13
update BUCTD training with new TD developments
LucZot May 30, 2024
5a432b5
merged main
n-poulsen Jun 24, 2024
783cf79
Merge branch 'pytorch_dlc' into lucas/buctd_integration
n-poulsen Dec 9, 2024
8f3b82d
finish merge w main -> works as before
LucZot Jun 27, 2024
e930274
get_pose_inference_runner for CTD
n-poulsen Dec 9, 2024
0773924
lastest buctd devs
LucZot Jan 15, 2025
0609cc4
Merge branch 'pytorch_dlc' into lucas/buctd_v2
n-poulsen Jan 15, 2025
e432b9f
import fix
n-poulsen Jan 15, 2025
699a25f
func name fix
n-poulsen Jan 15, 2025
c792c9c
bug fix: pose postprocessor not built
n-poulsen Jan 15, 2025
1b723c2
bug fix: evaluate and inference
n-poulsen Jan 17, 2025
7cd1203
fix cropped_size variable and hacky test loading
LucZot Jan 17, 2025
8153c08
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Jan 17, 2025
c012941
Fixes to evaluation/inference on empty conditions
n-poulsen Feb 6, 2025
0be7e2e
added expected format
n-poulsen Feb 6, 2025
dd52784
Merge branch 'pytorch_dlc' into lucas/buctd_v2
n-poulsen Feb 6, 2025
46c213c
black for CoAM module
n-poulsen Feb 7, 2025
a521ff3
add conditional prenet draft
LucZot Mar 18, 2025
b0dcefd
add config files for hrnet+prenet
LucZot Mar 19, 2025
86724c4
add draft stacked keypoint enc
LucZot Mar 19, 2025
c58ddbe
updated code for CrowdPose/COCO OKS sigma
n-poulsen Mar 19, 2025
14b3eae
fix prenet details
LucZot Mar 20, 2025
a1aff5c
unfreeze bn stats of prenet+hrnet
LucZot Mar 20, 2025
77ee4cf
fix stacked keypoint encoding
LucZot Mar 24, 2025
c5d271a
Merge branch 'public' into lucas/buctd_v2
n-poulsen Mar 25, 2025
d4ed35c
improved loading conditions from files
n-poulsen Mar 26, 2025
dc7f1f0
removed debug prints
n-poulsen Mar 26, 2025
2c9a1b9
removed some debug comments
n-poulsen Mar 26, 2025
e095950
small clean up ctd configs
LucZot Mar 26, 2025
b6d99fe
improved loading conditions
n-poulsen Mar 26, 2025
4460b63
add config for rtmpose+prenet
LucZot Mar 27, 2025
a26d015
add img_size to hrnet_coam config
LucZot Mar 27, 2025
369048d
First implementation CTDInferenceRunner
n-poulsen Mar 27, 2025
583cfb2
Merge branch 'public' into lucas/buctd_v2
n-poulsen Mar 27, 2025
a9ea341
clean cond enc; extend ctd configs; add ctd related funcs to data loa…
LucZot Mar 27, 2025
6045f1a
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 27, 2025
cf424ba
add config for humans and fix rtmpose ctd config
LucZot Mar 27, 2025
3fa99cb
fix config human
LucZot Mar 27, 2025
e568ca5
small fixes
LucZot Mar 27, 2025
7b100ce
improved CTD model config code
n-poulsen Mar 28, 2025
4ef5b47
implement re-scoring for CTD
n-poulsen Mar 28, 2025
d34aece
add TD aug for CTD models
n-poulsen Mar 28, 2025
e80bb5b
fix evaluation and debug print
n-poulsen Mar 28, 2025
19a3258
fixes to video inference
n-poulsen Mar 28, 2025
5ebcbdc
add gen sampling params for crowdpose
LucZot Mar 28, 2025
4815020
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
86b6704
small fix config human ctd
LucZot Mar 28, 2025
6f55b9f
bug fix: dataset idv IDs
n-poulsen Mar 28, 2025
38b1a26
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
5a3f227
bug fix: dataset idv IDs
n-poulsen Mar 28, 2025
2b1205f
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
edbc25a
fix bug when no keypoints are visible
n-poulsen Mar 28, 2025
eee62d7
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
ab75ce9
fix dataloader: trim area and bboxes
n-poulsen Mar 28, 2025
0120285
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
29d9663
implemented CTD inference
n-poulsen Mar 28, 2025
9e157bf
add coam config for crowdpose
LucZot Mar 28, 2025
24c6db5
Merge branch 'lucas/buctd_v2' of github.com:AlexEMG/DLCdev into lucas…
LucZot Mar 28, 2025
43bda99
First implementation of CTD tracking
n-poulsen Apr 1, 2025
24b06ba
Add `ctd_conditions` argument to `deeplabcut.create_training_dataset(…
maximpavliv Apr 1, 2025
2453441
implement user-friendly CTD inference (#268)
n-poulsen Apr 9, 2025
cb65d69
bug fixes and improvements to default configs
n-poulsen Apr 10, 2025
63c6ce2
update LR for CTD models
n-poulsen Apr 10, 2025
8cbf38a
rename Task.CTD to Task.COND_TOP_DOWN (#270)
n-poulsen Apr 10, 2025
e5d2d28
remove unused code
n-poulsen Apr 10, 2025
12cf3fa
remove unused code
n-poulsen Apr 10, 2025
8140467
add link to COLAB in maDLC_UserGuide
n-poulsen Apr 11, 2025
2a43052
Merge branch 'main' into lucas/buctd_v2
n-poulsen Apr 11, 2025
f54cc47
update BUCTD colab
n-poulsen Apr 11, 2025
4ff3d95
fix COLAB rendering
n-poulsen Apr 11, 2025
bd2d14d
fix COLAB rendering
n-poulsen Apr 11, 2025
28ff47f
fix COLAB rendering
n-poulsen Apr 11, 2025
a04a9bd
fix pip install in COLAB
n-poulsen Apr 11, 2025
c42fe22
skip notebooks for codespell
n-poulsen Apr 11, 2025
1d92522
install deeplabcut with --pre in colab
n-poulsen Apr 11, 2025
b0dae22
fix tests
n-poulsen Apr 11, 2025
9696a4b
Merge branch 'main' into lucas/buctd_v2
MMathisLab Apr 11, 2025
9eec042
fix failing tests on windows
n-poulsen Apr 11, 2025
a42c61d
fix tests windows
n-poulsen Apr 11, 2025
1d67089
Update architectures.md
AlexEMG Apr 14, 2025
d6b3f74
deal with absolute windows paths
n-poulsen Apr 14, 2025
0fc92a0
Version update
AlexEMG Apr 14, 2025
6a1e0a9
fix when paths are converted to windows
n-poulsen Apr 14, 2025
3900605
Merge branch 'main' into lucas/buctd_v2
n-poulsen Apr 14, 2025
fb7c647
fix windows tests
n-poulsen Apr 14, 2025
44a54fb
Merge branch 'main' into lucas/buctd_v2
MMathisLab Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,*.pdf,*.svg,deeplabcut/pose_estimation_tensorflow/models/pretrained
skip = .git,*.pdf,*.svg,*.ipynb,deeplabcut/pose_estimation_tensorflow/models/pretrained
# MOT,SIE - legit acronyms
# tThe - for \tThe. codespell is not good detecting those yet
ignore-words-list = mot,sie,tthe,assertin,bu,td,ctd,wither
2 changes: 1 addition & 1 deletion conda-environments/DEEPLABCUT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ dependencies:
- pip:
- torch
- torchvision
- deeplabcut[gui,modelzoo,wandb]==3.0.0rc7
- deeplabcut[gui,modelzoo,wandb]==3.0.0rc8
3 changes: 3 additions & 0 deletions deeplabcut/core/inferenceutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,9 @@ def calc_object_keypoint_similarity(

k_squared = (2 * sigma) ** 2
denom = 2 * scale_squared * k_squared
if isinstance(sigma, np.ndarray):
denom = denom[visible_gt]

if symmetric_kpts is None:
pred = xy_pred[visible_gt]
pred[np.isnan(pred)] = np.inf
Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/core/metrics/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def compute_metrics(
unique_bodypart_poses: dict[str, np.ndarray] | None = None,
pcutoff: float = -1,
oks_bbox_margin: int = 0,
oks_sigma: float = 0.1,
oks_sigma: float | np.ndarray = 0.1,
per_keypoint_rmse: bool = False,
compute_detection_rmse: bool = True,
) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions deeplabcut/core/metrics/distance_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def compute_oks_matrix(
ground_truth: np.ndarray,
predictions: np.ndarray,
oks_sigma: float,
oks_sigma: float | np.ndarray,
oks_bbox_margin: float = 0.0,
) -> np.ndarray:
"""Computes the OKS score for each (prediction, gt) pair in an image
Expand Down Expand Up @@ -53,7 +53,7 @@ def compute_oks_matrix(
def compute_oks(
data: list[tuple[np.ndarray, np.ndarray]],
oks_bbox_margin: float = 0.0,
oks_sigma: float = 0.1,
oks_sigma: float | np.ndarray = 0.1,
oks_thresholds: np.ndarray | None = None,
oks_recall_thresholds: np.ndarray | None = None,
) -> dict[str, float]:
Expand Down
1 change: 1 addition & 0 deletions deeplabcut/core/trackingutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

TRACK_METHODS = {
"box": "_bx",
"ctd": "_ctd",
"skeleton": "_sk",
"ellipse": "_el",
"transformer": "_tr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def create_multianimaltraining_dataset(
userfeedback: bool = True,
weight_init: WeightInitialization | None = None,
engine: Engine | None = None,
ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] | None = None,
):
"""
Creates a training dataset for multi-animal datasets. Labels from all the extracted
Expand Down Expand Up @@ -158,17 +159,38 @@ def create_multianimaltraining_dataset(
* ``efficientnet-b6``
PyTorch (call ``deeplabcut.pose_estimation_pytorch.available_models()`` for
a complete list)
* ``resnet_50``
* ``resnet_101``
* ``animaltokenpose_base``
* ``cspnext_m``
* ``cspnext_s``
* ``cspnext_x``
* ``ctd_coam_w32``
* ``ctd_coam_w48``
* ``ctd_prenet_hrnet_w32``
* ``ctd_prenet_hrnet_w48``
* ``ctd_prenet_rtmpose_m``
* ``ctd_prenet_rtmpose_x``
* ``ctd_prenet_rtmpose_x_human``
* ``dekr_w18``
* ``dekr_w32``
* ``dekr_w48``
* ``top_down_resnet_50``
* ``top_down_resnet_101``
* ``dlcrnet_stride16_ms5``
* ``dlcrnet_stride32_ms5``
* ``hrnet_w18``
* ``hrnet_w32``
* ``hrnet_w48``
* ``resnet_101``
* ``resnet_50``
* ``rtmpose_m``
* ``rtmpose_s``
* ``rtmpose_x``
* ``top_down_cspnext_m``
* ``top_down_cspnext_s``
* ``top_down_cspnext_x``
* ``top_down_hrnet_w18``
* ``top_down_hrnet_w32``
* ``top_down_hrnet_w48``
* ``animaltokenpose_base``
* ``top_down_resnet_101``
* ``top_down_resnet_50``

detector_type: string, optional, default=None
Only for the PyTorch engine.
Expand Down Expand Up @@ -233,6 +255,14 @@ def create_multianimaltraining_dataset(
the value specified in the project configuration file. If no engine is specified
for the project, defaults to ``deeplabcut.compat.DEFAULT_ENGINE``.

ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] , optional, default = None,
If using a conditional-top-down (CTD) net_type, this argument needs to be specified.
It defines the conditions that will be used with the CTD model.
It can be either:
* A shuffle number (ctd_conditions: int), which must correspond to a bottom-up (BU) network type.
* A predictions file path (ctd_conditions: string | Path), which must correspond to a .json or .h5 predictions file.
* A shuffle number and a particular snapshot (ctd_conditions: tuple[int, str] | tuple[int, int]), which respectively correspond to a bottom-up (BU) network type and a particular snapshot name or index.

Example
--------
>>> deeplabcut.create_multianimaltraining_dataset('/analysis/project/reaching-task/config.yaml',num_shuffles=1)
Expand Down Expand Up @@ -596,6 +626,7 @@ def create_multianimaltraining_dataset(
detector_type=detector_type,
weight_init=weight_init,
save=True,
ctd_conditions=ctd_conditions,
)

make_pytorch_test_config(pytorch_cfg, path_test_config, save=True)
Expand Down
69 changes: 60 additions & 9 deletions deeplabcut/generate_training_dataset/trainingsetmanipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def create_training_dataset(
superanimal_name="",
weight_init: WeightInitialization | None = None,
engine: Engine | None = None,
ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] | None = None,
):
"""Creates a training dataset.

Expand Down Expand Up @@ -841,20 +842,41 @@ def create_training_dataset(
* ``efficientnet-b6``
PyTorch (call ``deeplabcut.pose_estimation_pytorch.available_models()`` for
a complete list)
* ``resnet_50``
* ``resnet_101``
* ``hrnet_w18``
* ``hrnet_w32``
* ``hrnet_w48``
* ``animaltokenpose_base``
* ``cspnext_m``
* ``cspnext_s``
* ``cspnext_x``
* ``ctd_coam_w32``
* ``ctd_coam_w48``
* ``ctd_prenet_cspnext_m``
* ``ctd_prenet_cspnext_x``
* ``ctd_prenet_rtmpose_x_human``
* ``ctd_prenet_hrnet_w32``
* ``ctd_prenet_hrnet_w48``
* ``ctd_prenet_rtmpose_m``
* ``ctd_prenet_rtmpose_x``
* ``ctd_prenet_rtmpose_x_human``
* ``dekr_w18``
* ``dekr_w32``
* ``dekr_w48``
* ``top_down_resnet_50``
* ``top_down_resnet_101``
* ``dlcrnet_stride16_ms5``
* ``dlcrnet_stride32_ms5``
* ``hrnet_w18``
* ``hrnet_w32``
* ``hrnet_w48``
* ``resnet_101``
* ``resnet_50``
* ``rtmpose_m``
* ``rtmpose_s``
* ``rtmpose_x``
* ``top_down_cspnext_m``
* ``top_down_cspnext_s``
* ``top_down_cspnext_x``
* ``top_down_hrnet_w18``
* ``top_down_hrnet_w32``
* ``top_down_hrnet_w48``
* ``animaltokenpose_base``
* ``top_down_resnet_101``
* ``top_down_resnet_50``

detector_type: string, optional, default=None
Only for the PyTorch engine.
Expand Down Expand Up @@ -900,6 +922,19 @@ def create_training_dataset(
the value specified in the project configuration file. If no engine is specified
for the project, defaults to ``deeplabcut.compat.DEFAULT_ENGINE``.

ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] | None, default = None,
If using a conditional-top-down (CTD) net_type, this argument should be
specified. It defines the conditions that will be used with the CTD model.
It can be either:
* A shuffle number (ctd_conditions: int), which must correspond to a
bottom-up (BU) network type.
* A predictions file path (ctd_conditions: string | Path), which must
correspond to a .json or .h5 predictions file.
* A shuffle number and a particular snapshot
(ctd_conditions: tuple[int, str] | tuple[int, int]), which respectively
correspond to a bottom-up (BU) network type and a particular snapshot
name or index.

Returns
-------
list(tuple) or None
Expand Down Expand Up @@ -985,6 +1020,7 @@ def create_training_dataset(
userfeedback=userfeedback,
engine=engine,
weight_init=weight_init,
ctd_conditions=ctd_conditions,
)
else:
scorer = cfg["scorer"]
Expand Down Expand Up @@ -1088,7 +1124,6 @@ def create_training_dataset(

Shuffles = validate_shuffles(cfg, Shuffles, num_shuffles, userfeedback)

# print(trainIndices,testIndices, Shuffles, augmenter_type,net_type)
if trainIndices is None and testIndices is None:
splits = [
(
Expand Down Expand Up @@ -1305,6 +1340,7 @@ def create_training_dataset(
detector_type=detector_type,
weight_init=weight_init,
save=True,
ctd_conditions=ctd_conditions,
)

make_pytorch_test_config(pytorch_cfg, path_test_config, save=True)
Expand Down Expand Up @@ -1599,6 +1635,7 @@ def create_training_dataset_from_existing_split(
net_type: str | None = None,
detector_type: str | None = None,
augmenter_type: str | None = None,
ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] | None = None,
posecfg_template: dict | None = None,
superanimal_name: str = "",
weight_init: WeightInitialization | None = None,
Expand Down Expand Up @@ -1683,6 +1720,19 @@ def create_training_dataset_from_existing_split(
engine is specified for the project, defaults to
``deeplabcut.compat.DEFAULT_ENGINE``.

ctd_conditions: int | str | Path | tuple[int, str] | tuple[int, int] | None, default = None,
If using a conditional-top-down (CTD) net_type, this argument should be
specified. It defines the conditions that will be used with the CTD model.
It can be either:
* A shuffle number (ctd_conditions: int), which must correspond to a
bottom-up (BU) network type.
* A predictions file path (ctd_conditions: string | Path), which must
correspond to a .json or .h5 predictions file.
* A shuffle number and a particular snapshot
(ctd_conditions: tuple[int, str] | tuple[int, int]), which
respectively correspond to a bottom-up (BU) network type and a
particular snapshot name or index.

Returns:
If training dataset was successfully created, a list of tuples is returned.
The first two elements in each tuple represent the training fraction and the
Expand Down Expand Up @@ -1734,6 +1784,7 @@ def create_training_dataset_from_existing_split(
superanimal_name=superanimal_name,
weight_init=weight_init,
engine=engine,
ctd_conditions=ctd_conditions,
)


Expand Down
4 changes: 4 additions & 0 deletions deeplabcut/pose_estimation_pytorch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@
COCOLoader,
COLLATE_FUNCTIONS,
DLCLoader,
GenerativeSampler,
GenSamplingConfig,
list_snapshots,
Loader,
PoseDataset,
PoseDatasetParameters,
Snapshot,
)
from deeplabcut.pose_estimation_pytorch.runners import (
build_inference_runner,
Expand Down
Loading