Visitar URL original
Documentation: format docstrings for dev docs by C-Achard · Pull Request #3353 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
867de4c
Add mdformat hook and update docs scan/exclude
C-Achard Jun 1, 2026
0937706
Use NumPy docstring style and widen line length
C-Achard Jun 1, 2026
1a8d3cf
Format all docstrings
C-Achard Jun 1, 2026
c99aa9d
Format all docs
C-Achard Jun 1, 2026
6125126
Add dev-docs to mdformat
C-Achard Jun 1, 2026
4f32679
Disable mdformat pre-commit hook (broken)
C-Achard Jun 1, 2026
84466b0
Revert "Format all docs"
C-Achard Jun 1, 2026
794619b
use google-style docstrings + remove numpydoc
deruyter92 Jun 2, 2026
640deb2
apply ruff safe fixes all docstrings
deruyter92 Jun 2, 2026
2078850
docs: convert docstrings to Google style (batch A1)
deruyter92 Jun 3, 2026
d59328d
docs: convert docstrings to Google style (batch A2)
deruyter92 Jun 3, 2026
00425f4
docs: convert docstrings to Google style (batch A3)
deruyter92 Jun 3, 2026
0998f8e
docs: convert docstrings to Google style (batch A4)
deruyter92 Jun 3, 2026
944a561
docs: convert docstrings to Google style (batch A5)
deruyter92 Jun 3, 2026
1e33ab0
docs: convert docstrings to Google style (batch B1)
deruyter92 Jun 3, 2026
aede4c4
docs: convert docstrings to Google style (batch B2)
deruyter92 Jun 3, 2026
fd68cb0
docs: convert docstrings to Google style (batch B3)
deruyter92 Jun 3, 2026
741eb42
docs: convert docstrings to Google style (batch B4)
deruyter92 Jun 3, 2026
c046c73
docs: convert docstrings to Google style (batch B5)
deruyter92 Jun 3, 2026
1a50d1c
docs: convert docstrings to Google style (batch B6)
deruyter92 Jun 3, 2026
75046ae
docs: fix existing malformed Google style docstrings (batch C)
deruyter92 Jun 3, 2026
e589365
docs: fix existing outdated Google style docstrings (batch D)
deruyter92 Jun 3, 2026
2580c8b
doc: google docstyle fixes (audit)
deruyter92 Jun 3, 2026
c6d0a46
docs: fix examples in docstrings
deruyter92 Jun 4, 2026
dd04239
Docs: fix cli Args (was Options)
deruyter92 Jun 4, 2026
47a7485
docs: fix docstring exceptions (Raises) prose -> structured
deruyter92 Jun 4, 2026
30a2e36
docs: fix missing function descriptions in docstrings
deruyter92 Jun 4, 2026
4cbef89
docs: fix DLCLoader to_coco docstring
deruyter92 Jun 4, 2026
c949ffc
docs: manually fix incorrect args in docstrings (using griffe)
deruyter92 Jun 4, 2026
0c74661
apply suggestion: adjust comment in modelzoo.py
deruyter92 Jun 5, 2026
4fe31c5
Normalize parameter names in docstrings
C-Achard Jun 9, 2026
3b7e671
Convert doctest examples to plain code
C-Achard Jun 10, 2026
de886e7
Rename videotype to video_extensions and fix docs
C-Achard Jun 10, 2026
583170a
Update analyze_skeleton.py
C-Achard Jun 10, 2026
4eba8c3
Merge remote-tracking branch 'origin/arash/dev_docs' into cy/dev-docs…
C-Achard Jun 10, 2026
7ea3890
Fix pre-commit failures
C-Achard Jun 10, 2026
10f9644
Update uv.lock
C-Achard Jun 10, 2026
2e69e69
auto-detect URLs
deruyter92 Jun 11, 2026
a3871b6
Fix docstrings (examples) in core and create_project
deruyter92 Jun 11, 2026
9887acd
fix docstrings (mostly examples)
deruyter92 Jun 11, 2026
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
Prev Previous commit
fix docstrings (mostly examples)
  • Loading branch information
deruyter92 committed Jun 11, 2026
commit 9887acdbe20fd81abb2b818cb692d045a2d06bf5
2 changes: 1 addition & 1 deletion deeplabcut/generate_training_dataset/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def update_metadata(
if one exists

Raises:
RuntimeError: If ``overwrite`` is False and a shuffle with the same index and
RuntimeError: If ``overwrite`` is ``False`` and a shuffle with the same index and
training fraction already exists.
"""
prefix = cfg["Task"] + cfg["date"]
Expand Down
28 changes: 14 additions & 14 deletions deeplabcut/pose_estimation_pytorch/apis/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,26 +711,26 @@ def evaluate_network(
Examples:
If you want to evaluate on shuffle 1 without plotting predictions.

import deeplabcut
deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml', shuffles=[1],
)
import deeplabcut
deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml', shuffles=[1],
)

If you want to evaluate shuffles 0 and 1 and plot the predictions.

deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml',
shuffles=[0, 1],
plotting=True,
)
deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml',
shuffles=[0, 1],
plotting=True,
)

If you want to plot assemblies for a maDLC project

deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml',
shuffles=[1],
plotting="individual",
)
deeplabcut.evaluate_network(
'/analysis/project/reaching-task/config.yaml',
shuffles=[1],
plotting="individual",
)
"""
cfg = auxiliaryfunctions.read_config(config)

Expand Down
13 changes: 7 additions & 6 deletions deeplabcut/pose_estimation_pytorch/apis/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ def export_model(

Examples:
Export the last stored snapshot for model trained with shuffle 3:
import deeplabcut
deeplabcut.export_model(
"/analysis/project/reaching-task/config.yaml",
shuffle=3,
snapshotindex=-1,
)

import deeplabcut
deeplabcut.export_model(
"/analysis/project/reaching-task/config.yaml",
shuffle=3,
snapshotindex=-1,
)
"""
cfg = af.read_config(str(config))
if iteration is not None:
Expand Down
54 changes: 27 additions & 27 deletions deeplabcut/pose_estimation_pytorch/apis/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,40 +163,40 @@ def video_inference(
Examples:
Bottom-up video analysis:

import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
video_predictions = pep.video_inference("video.mp4", runner)
import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
video_predictions = pep.video_inference("video.mp4", runner)

Top-down video analysis:

import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
d_runner = pep.get_pose_inference_runner(model_cfg, "snapshot-detector.pt")
video_predictions = pep.video_inference("video.mp4", runner, d_runner)
import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
d_runner = pep.get_pose_inference_runner(model_cfg, "snapshot-detector.pt")
video_predictions = pep.video_inference("video.mp4", runner, d_runner)


Top-Down pose estimation with pre-computed bounding boxes:

import numpy as np
import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
video_iterator = pep.VideoIterator("video.mp4")
video_iterator.set_context([
{ # frame 1 context
"bboxes": np.array([[12, 17, 4, 5]]), # format (x0, y0, w, h)
},
{ # frame 1 context
"bboxes": np.array([[12, 17, 4, 5], [18, 92, 54, 32]]),
},
...
])
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
video_predictions = pep.video_inference(video_iterator, runner)
import numpy as np
import deeplabcut.pose_estimation_pytorch as pep
from deeplabcut.core.config import read_config_as_dict
video_iterator = pep.VideoIterator("video.mp4")
video_iterator.set_context([
{ # frame 1 context
"bboxes": np.array([[12, 17, 4, 5]]), # format (x0, y0, w, h)
},
{ # frame 1 context
"bboxes": np.array([[12, 17, 4, 5], [18, 92, 54, 32]]),
},
...
])
model_cfg = read_config_as_dict("pytorch_config.yaml")
runner = pep.get_pose_inference_runner(model_cfg, "snapshot.pt")
video_predictions = pep.video_inference(video_iterator, runner)
"""
if not isinstance(video, VideoIterator):
video = VideoIterator(str(video), cropping=cropping)
Expand Down
66 changes: 33 additions & 33 deletions deeplabcut/pose_estimation_pytorch/config/make_pose_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,41 +305,41 @@ def make_basic_project_config(
`make_pytorch_pose_config`.

Examples:
Creating a `pytorch_config` for a ResNet50 backbone with a part-affinity head (
as multi_animal=True and top_down=False)

import deeplabcut.pose_estimation_pytorch as pep
project_config = pep.config.make_basic_project_config(
dataset_path="/path/coco",
bodyparts=["nose", "left_eye", "right_eye"],
max_individuals=12,
multi_animal=True,
)
model_config = pep.config.make_pytorch_pose_config(
project_config=project_config,
pose_config_path="/path/coco/models/resnet50/pytorch_config.yaml",
net_type="resnet_50",
top_down=False,
save=True,
)
Creating a ``pytorch_config`` for a ResNet50 backbone with a part-affinity head (
``multi_animal=True`` and ``top_down=False``)

import deeplabcut.pose_estimation_pytorch as pep
project_config = pep.config.make_basic_project_config(
dataset_path="/path/coco",
bodyparts=["nose", "left_eye", "right_eye"],
max_individuals=12,
multi_animal=True,
)
model_config = pep.config.make_pytorch_pose_config(
project_config=project_config,
pose_config_path="/path/coco/models/resnet50/pytorch_config.yaml",
net_type="resnet_50",
top_down=False,
save=True,
)

Creating a `pytorch_config` for a ResNet50 backbone with a simple heatmap head
(as the project is single-animal):
Creating a ``pytorch_config`` for a ResNet50 backbone with a simple heatmap head
(the project is single-animal):

import deeplabcut.pose_estimation_pytorch as pep
project_config = pep.config.make_basic_project_config(
dataset_path="/path/coco",
bodyparts=["nose", "left_eye", "right_eye"],
max_individuals=1,
multi_animal=False,
)
model_config = pep.config.make_pytorch_pose_config(
project_config=project_config,
pose_config_path="/path/coco/models/resnet50/pytorch_config.yaml",
net_type="resnet_50",
top_down=False,
save=True,
)
import deeplabcut.pose_estimation_pytorch as pep
project_config = pep.config.make_basic_project_config(
dataset_path="/path/coco",
bodyparts=["nose", "left_eye", "right_eye"],
max_individuals=1,
multi_animal=False,
)
model_config = pep.config.make_pytorch_pose_config(
project_config=project_config,
pose_config_path="/path/coco/models/resnet50/pytorch_config.yaml",
net_type="resnet_50",
top_down=False,
save=True,
)
"""
return dict(
project_path=str(dataset_path),
Expand Down
14 changes: 8 additions & 6 deletions deeplabcut/pose_estimation_pytorch/models/backbones/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
Returns:
torch.Tensor: Output tensor.

Example:
import torch
from deeplabcut.pose_estimation_pytorch.models.backbones import ResNet
backbone = ResNet(model_name="resnet50", pretrained=False)
x = torch.randn(1, 3, 256, 256)
y = backbone(x)
Examples:
Create a ResNet50 backbone and forward a random tensor:

import torch
from deeplabcut.pose_estimation_pytorch.models.backbones import ResNet
backbone = ResNet(model_name="resnet50", pretrained=False)
x = torch.randn(1, 3, 256, 256)
y = backbone(x)

Expected Output Shape:
If input size is (batch_size, 3, shape_x, shape_y), the output shape
Expand Down
31 changes: 19 additions & 12 deletions deeplabcut/pose_estimation_pytorch/models/heads/dekr.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ def __init__(
None

Examples:
channels = (64,128,17)
num_blocks = 3
dilation_rate = 2
final_conv_kernel = 3
block = BasicBlock
Initialize a DEKRHeatmap:

DEKRHeatmap(
channels=(64,128,17),
num_blocks=3,
dilation_rate=2,
final_conv_kernel=3,
block=BasicBlock,
)
"""
super().__init__()
self.bn_momentum = 0.1
Expand Down Expand Up @@ -284,13 +288,16 @@ def _make_layer(
A sequential layer containing stacked num_blocks.

Examples:
input:
block=BasicBlock
in_channels=64
out_channels=128
num_blocks=3
stride=1
dilation=1
Create a layer:

_make_layer(
block=BasicBlock,
in_channels=64,
out_channels=128,
num_blocks=3,
stride=1,
dilation=1,
)
"""
downsample = None
if stride != 1 or in_channels != out_channels * block.expansion:
Expand Down
10 changes: 6 additions & 4 deletions deeplabcut/pose_estimation_pytorch/models/necks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def make_sine_position_embedding(
Returns:
Sine position embeddings with shape (batch_size, d_model, h * w).

Example:
h, w, d_model = 10, 20, 512
pos_emb = make_sine_position_embedding(h, w, d_model)
print(pos_emb.shape) # Output: torch.Size([1, 512, 200])
Examples:
Generate sine position embedding:

h, w, d_model = 10, 20, 512
pos_emb = make_sine_position_embedding(h, w, d_model)
print(pos_emb.shape) # Output: torch.Size([1, 512, 200])
"""
area = torch.ones(1, h, w)
y_embed = area.cumsum(1, dtype=torch.float32)
Expand Down
Loading