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
Next Next commit
docs: convert docstrings to Google style (batch A3)
  • Loading branch information
deruyter92 committed Jun 3, 2026
commit 00425f4267428e67e38f13300ec0ae621ca807bf
30 changes: 12 additions & 18 deletions deeplabcut/pose_estimation_tensorflow/datasets/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,19 @@ def __init__(
max_shift=0.4,
crop_sampling="hybrid",
):
"""
Parameters
----------
width : int
Crop images down to this maximum width.

height : int
Crop images down to this maximum height.

max_shift : float, optional (default=0.25)
Maximum allowed shift of the cropping center position
as a fraction of the crop size.
"""Crop images to fixed size with keypoint-aware center sampling.

crop_sampling : str, optional (default="hybrid")
Crop centers sampling method. Must be either:
"uniform" (randomly over the image),
"keypoints" (randomly over the annotated keypoints),
"density" (weighing preferentially dense regions of keypoints),
or "hybrid" (alternating randomly between "uniform" and "density").
Args:
width (int): Crop images down to this maximum width.
height (int): Crop images down to this maximum height.
max_shift (float, optional): Maximum allowed shift of the cropping center position
as a fraction of the crop size. Defaults to 0.25.
crop_sampling (str, optional): Crop centers sampling method. Must be either:
"uniform" (randomly over the image),
"keypoints" (randomly over the annotated keypoints),
"density" (weighing preferentially dense regions of keypoints),
or "hybrid" (alternating randomly between "uniform" and "density").
Defaults to "hybrid".
"""
super().__init__(
width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,38 @@ def __init__(
customized_pose_config="",
init_weights="",
):
"""This class supports video adaptation to a super model.

Parameters
----------
video_path: string
The string to the path of the video
init_weights: string
The path to a superanimal model's checkpoint
supermodel_name: string
Currently we support supertopview(LabMice) and superquadruped (quadruped side-view animals)
scale_list: list
A list of different resolutions for the spatial pyramid
videotype: string
Checks for the extension of the video in case the input to the video is a directory.\n Only videos with this
extension are analyzed. The default is ``.avi``
adapt_iterations: int
Number of iterations for adaptation training. Empirically 1000 is sufficient. Training longer can cause worse
performance depending whether there is occlusion in the video
modelfolder: string, optional
Because the API does not need a dlc project, the checkpoint and logs go to this temporary model folder, and
otherwise model is saved to the current work place
customized_pose_config: string, optional
For future support of non modelzoo model
"""Support video adaptation to a super model.

Args:
video_path (string): The string to the path of the video.
init_weights (string): The path to a superanimal model's checkpoint.
supermodel_name (string): Currently we support supertopview (LabMice) and
superquadruped (quadruped side-view animals).
scale_list (list): A list of different resolutions for the spatial pyramid.
videotype (string): Checks for the extension of the video in case the input to
the video is a directory.\n Only videos with this extension are analyzed.
The default is ``.avi``.
adapt_iterations (int): Number of iterations for adaptation training.
Empirically 1000 is sufficient. Training longer can cause worse
performance depending whether there is occlusion in the video.
modelfolder (string, optional): Because the API does not need a dlc project,
the checkpoint and logs go to this temporary model folder, and otherwise
model is saved to the current work place.
customized_pose_config (string, optional): For future support of non modelzoo model.

Examples:
--------
from deeplabcut.modelzoo.apis import SpatiotemporalAdaptation
video_path = '/mnt/md0/shaokai/openfield_video/m3v1mp4.mp4'
superanimal_name = 'superanimal_topviewmouse'
videotype = 'mp4'
>>> adapter = SpatiotemporalAdaptation(video_path,
superanimal_name,
modelfolder = "temp_topview",
videotype = videotype)

adapter.before_adapt_inference()
adapter.adaptation_training()
adapter.after_adapt_inference()
from deeplabcut.modelzoo.apis import SpatiotemporalAdaptation
video_path = '/mnt/md0/shaokai/openfield_video/m3v1mp4.mp4'
superanimal_name = 'superanimal_topviewmouse'
videotype = 'mp4'
>>> adapter = SpatiotemporalAdaptation(video_path,
superanimal_name,
modelfolder = "temp_topview",
videotype = videotype)

adapter.before_adapt_inference()
adapter.adaptation_training()
adapter.after_adapt_inference()
"""
if scale_list is None:
scale_list = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,60 +452,43 @@ def _video_inference_superanimal(
These arrays are stored in an efficient Hierarchical Data Format (HDF) \n
in the same directory, where the video is stored.

Parameters
----------
videos: list
A list of strings containing the full paths to videos for analysis or a path to the directory,
where all the videos with same extension are stored.

superanimal_name: str
The name of the superanimal model.
In TensorFlow, we only support "superanimal_quadruped", "superanimal_topviewmouse".
Check out the PyTorch version for active development,
better performance and additional models (humans, birds, ...)
scale_list: list
A list of int containing the target height of the multi scale test time augmentation.
By default it uses the original size.
Users are advised to try a wide range of scale list when the super model does not give reasonable results

videotype: string, optional
Checks for the extension of the video in case the input to the video is a directory.\n
Only videos with this extension are analyzed.
The default is ``.avi``

video_adapt: bool, optional
Set True if you want to apply video adaptation to make the resulted video less jittering and better.
However, adaptation training takes more time than usual video inference

plot_trajectories: bool, optional (default=True)
By default, plot the trajectories of various body parts across the video.

pcutoff: float, optional
Keypoints confidence that are under pcutoff will not be shown in the resulted video

adapt_iterations: int, optional:
Number of iterations for adaptation training

pseudo_threshold: float, default 0.1
Video adaptation only uses predictions that are above pseudo_threshold

create_labeled_video (bool):
Specifies if a labeled video needs to be created, True by default.

Given a list of scales for spatial pyramid, i.e. [600, 700]

scale_list = range(600,800,100)

superanimal_name = 'superanimal_topviewmouse'
videotype = 'mp4'
scale_list = [200, 300, 400]
deeplabcut.video_inference_superanimal(
video,
superanimal_name,
videotype = '.avi',
scale_list = scale_list,
)
>>>
Args:
videos (list): A list of strings containing the full paths to videos for analysis or a path to the directory,
where all the videos with same extension are stored.
superanimal_name (str): The name of the superanimal model.
In TensorFlow, we only support "superanimal_quadruped", "superanimal_topviewmouse".
Check out the PyTorch version for active development,
better performance and additional models (humans, birds, ...)
scale_list (list): A list of int containing the target height of the multi scale test time augmentation.
By default it uses the original size.
Users are advised to try a wide range of scale list when the super model does not give reasonable results.
videotype (string, optional): Checks for the extension of the video in case the input
to the video is a directory.\n Only videos with this extension are analyzed.
The default is ``.avi``.
video_adapt (bool, optional): Set True to apply video adaptation for less jittering
results. Adaptation training takes more time than usual video inference.
plot_trajectories (bool, optional): By default, plot the trajectories of various body parts across the video.
Defaults to True.
pcutoff (float, optional): Keypoints confidence that are under pcutoff will not be shown in the resulted video.
adapt_iterations (int, optional): Number of iterations for adaptation training.
pseudo_threshold (float): Video adaptation only uses predictions that are above pseudo_threshold.
Defaults to 0.1.
create_labeled_video (bool): Specifies if a labeled video needs to be created. Defaults to True.

Given a list of scales for spatial pyramid, i.e. [600, 700]

scale_list = range(600,800,100)

superanimal_name = 'superanimal_topviewmouse'
videotype = 'mp4'
scale_list = [200, 300, 400]
deeplabcut.video_inference_superanimal(
video,
superanimal_name,
videotype = '.avi',
scale_list = scale_list,
)
>>>
"""
from deeplabcut.pose_estimation_tensorflow.modelzoo.api import (
SpatiotemporalAdaptation,
Expand Down
80 changes: 29 additions & 51 deletions deeplabcut/pose_tracking_pytorch/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,59 +37,37 @@ def transformer_reID(
Outputs: The tracklet file is saved in the same folder where the non-transformer
tracklet file is stored.

Parameters
----------
config: string
Full path of the config.yaml file as a string.

videos: list
A list of strings containing the full paths to videos for analysis or a path to
the directory, where all the videos with same extension are stored.

videotype : str | Sequence[str] | None, optional, default=None
Controls how ``videos`` are filtered, based on file extension.
File paths and directory contents are treated differently:
- ``None`` (default): file paths are accepted as-is; directories are
scanned for files with a recognized video extension.
- ``str`` or ``Sequence[str]`` (e.g. ``"mp4"`` or ``["mp4", "avi"]``):
both file paths and directory contents are filtered by the given
extension(s).

shuffle : int, optional
which shuffle to use

trainingsetindex : int. optional
which training fraction to use, identified by its index

track_method: str, optional
track method from which tracklets are sampled

n_tracks: int
number of tracks to be formed in the videos.
TODO: handling videos with different number of tracks

n_triplets: (optional) int
number of triplets to be mined from the videos

train_epochs: (optional), int
number of epochs to train the transformer

train_frac: (optional), fraction
fraction of triplets used for training/testing of the transformer
Args:
config (string): Full path of the config.yaml file as a string.
videos (list): A list of strings containing the full paths to videos for analysis or a path to
the directory, where all the videos with same extension are stored.
videotype (str | Sequence[str] | None, optional): Controls how ``videos`` are filtered, based on file extension.
File paths and directory contents are treated differently:
- ``None`` (default): file paths are accepted as-is; directories are
scanned for files with a recognized video extension.
- ``str`` or ``Sequence[str]`` (e.g. ``"mp4"`` or ``["mp4", "avi"]``):
both file paths and directory contents are filtered by the given
extension(s). Defaults to None.
shuffle (int, optional): which shuffle to use.
trainingsetindex (int, optional): which training fraction to use, identified by its index.
track_method (str, optional): track method from which tracklets are sampled.
n_tracks (int): number of tracks to be formed in the videos.
TODO: handling videos with different number of tracks.
n_triplets (int, optional): number of triplets to be mined from the videos.
train_epochs (int, optional): number of epochs to train the transformer.
train_frac (fraction, optional): fraction of triplets used for training/testing of the transformer.

Examples:
--------
Training model for one video based on ellipse-tracker derived tracklets
>>> config = "/home/users/.../dlc-project-2025-01-01/config.yaml"
>>> videos = ["/home/alex/video.mp4"]
>>> deeplabcut.transformer_reID(config, videos, shuffle=1, track_method="ellipse")
>>> deeplabcut.create_labeled_video(
>>> config,
>>> videos,
>>> shuffle=1,
>>> track_method="transformer",
>>> )
--------
Training model for one video based on ellipse-tracker derived tracklets
>>> config = "/home/users/.../dlc-project-2025-01-01/config.yaml"
>>> videos = ["/home/alex/video.mp4"]
>>> deeplabcut.transformer_reID(config, videos, shuffle=1, track_method="ellipse")
>>> deeplabcut.create_labeled_video(
>>> config,
>>> videos,
>>> shuffle=1,
>>> track_method="transformer",
>>> )
"""
import os

Expand Down
Loading