config¶
The config documents, typed: the run config, the training config and their tables.
The schema is docs/config-schema.md, its conventions are ADR-0028 to ADR-0034 and
the loader is pydantic (ADR-0059). The package is torch-free, so a config loads and
fails without building a model (ADR-0032).
Layer
module-attribute
¶
Layer = Annotated[
VideoLayer
| SkeletonLayer
| MeshLayer
| BoxLayer
| BallLayer
| TraceLayer
| TextLayer,
Field(discriminator="draw"),
]
One entry of a video's layers, a table per draw kind (ADR-0059).
A key on the wrong kind, radius on a text layer, is an unknown key.
STAGE_ARRAYS
module-attribute
¶
STAGE_ARRAYS: dict[str, dict[str, tuple]] = {
"pose2d": {
"points": ("N", *VTK2),
"conf": ("N", *VTK),
"crops": ("N", *VT4),
"candidates/xy": ("N", "V", "T", "K", "C", 2),
"candidates/score": ("N", "V", "T", "K", "C"),
"centers": ("N", "T", 3),
"track_flags": ("N", "T"),
"center_candidates": ("V", "T", "C", 3),
},
"bundle_adjustment": {
"reproj_before": VTK,
"reproj_after": VTK,
},
"pose3d": {
"points": ("N", *TK3),
"reproj_error": ("N", *VTK),
"inliers": ("N", *VTK),
"support": ("N", "T", "K"),
"selected/points": ("N", *VTK2),
"selected/conf": ("N", *VTK),
},
"smoothing": {
"points": ("N", *TK3),
"var": ("N", *TK3),
"smooth_param": ("N", "K"),
},
"correction": {"points": ("N", *TK3)},
"ik": {
"angles": ("N", *TD),
"points": ("N", *TK3),
"chain_scale": ("N", "C"),
"chain_offset": ("N", "C", 3),
},
"ball": {
"center": ("T", 3),
"center_sd": ("T", 3),
"radius": (),
"rotation": ("T", 3),
"step": ("T", 3),
"axes": (3, 3),
"tracks": TD,
},
"render": {},
}
Per stage, the arrays it writes into a run's results/<name>.h5 and their axes.
Every per-animal array leads with N (ADR-0052); those without it describe the
recording: the center peaks, the bundle adjustment residuals, fitted on animal 0, and
the treadmill ball.
AugmentSpec ¶
Bases: Table
[augment]: the training-time augmentation, mild by default.
An absent table means no augmentation, an empty one these defaults: strong
geometric augmentation and cutout cost contralateral accuracy in the previous
training repo's measurements. The loop reads it as
Augment. rig_symmetry replaces
the mirror draw of a grouped sample with one symmetry of its rig
(rig_symmetries):
each view's picture flipped as a mirror or a turn of the world would flip it,
which a flip of every view about its own axis is not on a rig whose cameras are
turned against each other; flip_p then goes unused for calibrated projects.
Source code in src/deeperfly/config/train.py
BallStage ¶
Bases: Table
[ball]: track the treadmill ball under a tethered animal -> ball/*.
spintrack, an optional extra (deeperfly[ball]), tracks the ball's rotation in
view's video; the ball's outline in the outline views places it on every frame,
starting from where the 3D pose's leg tips rest on it, and the pose orients the
animal on it (ball, ADR-0144). Everything it writes is in the
world frame.
Attributes:
| Name | Type | Description |
|---|---|---|
view |
str
|
The view whose video spintrack tracks: one that sees the ball's texture, unmirrored. |
outline |
tuple[str, ...]
|
View selector for the views whose outline of the ball places it; mirrored views are left out. Depth along a line of sight needs a view off it. |
input |
str | None
|
The 3D the ball is started from and the animal oriented by; omitted, the latest upstream 3D. |
contact |
tuple[str, ...]
|
Point selector for the points that rest on the ball in stance. |
stand |
tuple[str, ...]
|
Point selector for the points whose centroid is where the animal stands, just above the ball. |
front |
tuple[str, ...]
|
Point selector for the front of the body axis. |
hind |
tuple[str, ...]
|
Point selector for the back of the body axis. |
contact_frames |
int
|
How many opening frames of the 3D the ball's radius is fitted and the animal oriented in, as a ball can move in its holder later. |
two_pass |
bool
|
Map the ball in a throwaway first pass, as |
tracking |
dict[str, Any]
|
spintrack's |
Source code in src/deeperfly/config/run.py
BundleAdjustmentStage ¶
Bases: Table
[bundle_adjustment]: refine [calibration] on this project.
It starts from the parameters [calibration] gives and hands the refined rig to
the 3D stages after it; the result is the run's bundle_adjustment/views, a raw
view per view that a [calibration.views.<name>] table accepts. Cached like any
stage, so --force re-solves from [calibration] rather than refining the
refinement (ADR-0086).
Attributes:
| Name | Type | Description |
|---|---|---|
source |
Literal['pose2d/points', 'labels/points']
|
Which 2D to fit: the detector's, or the project's hand labels
(which need no |
points |
tuple[str, ...]
|
Point selector to fit on; empty uses every point. |
fixed |
tuple[str, ...]
|
Solver references held constant ( |
shared |
tuple[tuple[str, ...], ...]
|
Groups of references tied to one value. |
frames |
int
|
How many labeled or predicted frames to sample, evenly. |
weighted |
bool
|
Weight each residual by the detector's confidence. |
loss |
Literal['linear', 'soft_l1', 'huber', 'cauchy', 'arctan']
|
Robust loss for the solver. |
threshold_px |
float
|
Inlier margin of the robust loss, in pixels. |
max_nfev |
int
|
Maximum solver function evaluations. |
Source code in src/deeperfly/config/run.py
fixed_refs ¶
The references to hold; empty expands to the default for these views.
Compute ¶
Bases: Table
[compute]: the machine, not the run, so a committed config stays portable.
Every knob is a CLI flag too, and none changes what a run computes (ADR-0033).
Attributes:
| Name | Type | Description |
|---|---|---|
device |
str | None
|
|
Source code in src/deeperfly/config/_base.py
ConfigError ¶
CorrectionStage ¶
Bases: Table
[correction]: fix known anatomical violations -> correction/points.
Two fixed sub-tables, applied in that order.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
str | None
|
The 3D to correct; omitted, the latest upstream 3D. |
static |
StaticCorrection | None
|
|
symmetrize |
SymmetrizeCorrection | None
|
|
Source code in src/deeperfly/config/run.py
IkStage ¶
Bases: Table
[ik]: fit a body model to the 3D pose -> ik/angles, ik/points.
The solve is QuickIK's, an optional extra (deeperfly[ik]); see
ik. model names a pack and binding where the skeleton's points
sit on it (ADR-0041); damping and symmetric_segments are ADR-0065 and
ADR-0066.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
str | None
|
The 3D to fit; omitted, the latest upstream 3D. |
model |
str
|
A packaged model pack ( |
binding |
str | None
|
The |
chains |
tuple[str, ...]
|
The model's non-leg chains to solve; empty solves every one the pack defines. The legs are always solved. |
iterations |
int
|
Gauss-Newton steps per frame. |
damping |
float
|
Levenberg-Marquardt damping of the step. |
neutral_weight |
float
|
Pull toward each DOF's neutral value, which pins the DOFs the keypoints do not determine. |
position_tolerance |
float
|
Early-stop threshold on the observations, in model units. |
angle_tolerance |
float
|
Early-stop threshold on the angles, in radians. |
fixed_body |
bool
|
Hold the body in the model frame and fit the legs to it (a tethered fly); false fits a 6-DOF root per frame. |
symmetric_segments |
bool
|
One shared length per segment for each leg and its mirror. |
weighted |
bool
|
Weight the observations by the detector's confidence. |
bounds |
dict[str, tuple[float, float]]
|
Per-DOF limits in degrees, |
markers |
dict[str, dict[str, Any]]
|
Per chain, |
Source code in src/deeperfly/config/run.py
InitialCalibration ¶
Bases: Table
[calibration]: the camera parameters a run starts from (ADR-0086).
Either a copy made at run start or placements written here, never both. A copy is of the values, so the run reproduces after the calibration files change; the values are what the geometry stages use, what their fingerprints hash and what the run stores.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
int | str | None
|
|
views |
dict[str, ViewSpec]
|
|
Source code in src/deeperfly/config/run.py
OutputSpec ¶
Bases: Table
[render.outputs.<name>]: one output video, <name>.mp4.
Attributes:
| Name | Type | Description |
|---|---|---|
grid |
tuple[tuple[str, ...], ...]
|
Panel names, row by row: views, videos, synthetic views and blank
panels. |
layers |
tuple[Layer, ...]
|
What to draw, in order, back to front. |
crop |
str | None
|
A |
frames |
FrameRange
|
|
speed |
float | None
|
Playback rate, overriding |
fps |
float | None
|
Encoded frame rate, overriding |
cell |
tuple[int, int] | None
|
Cell size |
max_size |
tuple[Side, Side] | None
|
The largest |
background |
str | None
|
Background color, overriding |
Source code in src/deeperfly/config/render.py
Pose2dStage ¶
Bases: Table
[pose2d]: run the detector over the video -> pose2d/*.
Several weights are an ensemble, collapsed by combine inside the forward pass,
so every later stage sees one pose2d/points.
Attributes:
| Name | Type | Description |
|---|---|---|
weights |
tuple[ArtifactRef, ...]
|
Trained artifacts: paths relative to the config (ADR-0085), a
directory meaning its |
combine |
Literal['mean', 'median']
|
How the members collapse into |
tta |
bool
|
Also run each frame mirrored and average the two decodes (ADR-0045). |
candidates |
int
|
Distinct peaks kept per |
crops |
dict[str, tuple[int, int, int, int] | tuple[tuple[int, int, int, int], ...]]
|
Fixed per-view windows |
tightness |
float
|
How much wider than the animal a discovered window is, as the
training's crop tightness measures it: the static windows, and the size
a per-frame window keeps. No effect on fixed |
crop_aspect |
dict[str, float]
|
Per view, the aspect (width / height) of the detector's window
instead of the input's, |
window |
Literal['static', 'per_frame']
|
|
locator |
ArtifactRef | None
|
The full-frame locator a per-frame run needs where views share a
frame (ADR-0064), named as |
tracking |
Tracking
|
|
Source code in src/deeperfly/config/run.py
Pose3dStage ¶
Bases: Table
[pose3d]: lift the 2D to one 3D track per keypoint -> pose3d/*.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
Literal['ransac', 'dlt', 'pictorial', 'election']
|
|
threshold_px |
float
|
Inlier margin of the consensus, in pixels; for |
min_views |
int
|
Views a point needs to be triangulated; for |
weighted |
bool
|
Weight each observation by its confidence's precision ( |
bone_prior |
float
|
|
veto |
tuple[str, ...]
|
View selectors that never vote (a weakly calibrated view): they take
no part in any triangulation, but |
Source code in src/deeperfly/config/run.py
RenderConfig ¶
Bases: Table
[render]: the videos a run writes, and the defaults they share.
Attributes:
| Name | Type | Description |
|---|---|---|
outputs |
dict[str, OutputSpec]
|
|
views |
dict[str, RenderView]
|
|
frames |
FrameRange
|
|
speed |
float
|
Playback rate: the animation runs at the video's fps times |
fps |
float
|
The rate written into the file, each drawn frame held a whole number of
output frames to reach it, so none is dropped; |
cell |
tuple[int, int]
|
One cell's |
max_size |
tuple[Side, Side]
|
The largest |
background |
str
|
What a panel is filled with where content does not reach. |
codec |
str
|
The encoder to hand the frames to. |
crf |
int | None
|
The encoder's constant rate factor: lower keeps more, in a larger
file. 18 keeps a thin colored mark sharp over footage, which libx264's
own 23 smears; |
Source code in src/deeperfly/config/render.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
check ¶
Check every reference and panel against what the run actually writes.
available is {"group/array": axes} for every array the enabled stages
write, plus video and labels/*
(available). A (V,T,K) alpha may
not reach a synthetic view, which has no view axis.
Source code in src/deeperfly/config/render.py
RenderView ¶
Bases: Table
[render.views.<name>]: a synthetic view, written as an orbit placement.
The orbit keys are OrbitView's; distance, focal and
image_size may be left to the renderer, which fits them to the 3D in the panel.
Attributes:
| Name | Type | Description |
|---|---|---|
azimuth_deg |
float
|
Orbit rotation in the world xy-plane. |
elevation_deg |
float
|
Orbit lift toward |
roll_deg |
float
|
Rotation about the optical axis. |
look_at |
tuple[float, float, float]
|
World point the camera aims at. |
distance |
float | None
|
Distance from |
focal |
float | None
|
Focal length in pixels. |
image_size |
tuple[int, int] | None
|
Panel |
Source code in src/deeperfly/config/render.py
RunConfig ¶
Bases: Table
A whole run config: the frames, the starting calibration, one table per stage.
Attributes:
| Name | Type | Description |
|---|---|---|
format_version |
int
|
The schema version the document is written for. |
name |
str | None
|
The run's name, its results file |
frames |
tuple[int | str, ...]
|
The frame set the run covers: indices and |
compute |
RunCompute
|
|
calibration |
InitialCalibration | None
|
|
pose2d |
Pose2dStage | None
|
|
bundle_adjustment |
BundleAdjustmentStage | None
|
|
pose3d |
Pose3dStage | None
|
|
smoothing |
SmoothingStage | None
|
|
correction |
CorrectionStage | None
|
|
ik |
IkStage | None
|
|
ball |
BallStage | None
|
|
render |
RenderConfig | None
|
|
path |
Path | None
|
The file this was loaded from, or |
text |
str | None
|
The document as a run records it when the command line set keys
( |
Source code in src/deeperfly/config/run.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | |
available ¶
{"group/array": axes} for everything a reference may name here.
The enabled stages' arrays plus the virtual video and labels/*, for a
project of animals animals; a stage that is off contributes nothing, so a
stale reference to it fails the check.
Source code in src/deeperfly/config/run.py
check_points ¶
Every point selector must match the skeleton's names.
Part of check_project.
Source code in src/deeperfly/config/run.py
check_project ¶
check_project(
views: Sequence[str],
animals: int,
points: Sequence[str],
videos: Sequence[str] = (),
) -> None
Check the config against a project: its views, videos, animals, keypoints.
What a run config cannot know on its own, since the videos, the views, the
skeleton and the animal count are the project's (ADR-0081). The run checks
each project before any stage runs, and so does --dry-run. videos are the
names a render grid may show whole.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If a table names a view or a point the project lacks, the calibration places other views, the animals need what the config lacks, or a render reference names nothing this config writes. |
Source code in src/deeperfly/config/run.py
from_document
classmethod
¶
Build from a parsed document, resolving its paths against doc_dir.
Source code in src/deeperfly/config/run.py
input_of ¶
What stage reads: its declared input, else the latest upstream 3D.
Source code in src/deeperfly/config/run.py
load
classmethod
¶
Load, lint and type a run config file.
changes are values by dotted key (overrides)
set over the file's before it is typed, as if the file said them; the run
records them, written into the file's text.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file, with the changes, breaks any rule of the schema. |
Source code in src/deeperfly/config/run.py
recorded_text ¶
The document as a run records it: the file's text, with any --set keys.
Empty for a config built in memory.
Source code in src/deeperfly/config/run.py
SmoothingStage ¶
Bases: Table
[smoothing]: the geometric EKS over the 2D observations -> smoothing/*.
The keys are smooth's (ADR-0062).
Attributes:
| Name | Type | Description |
|---|---|---|
smooth_param |
float | None
|
The process-noise scale, smaller smoothing harder; omitted, fitted per keypoint. |
fit_frames |
int
|
Frames sampled for that fit. |
fit_iterations |
int
|
Iterations of the fit. |
inflate |
bool
|
Inflate the variance of a view that disagrees with the others. |
inflate_threshold |
float
|
The Mahalanobis distance above which it is inflated. |
inflate_factor |
float
|
How much it is inflated by, per round. |
var |
Literal['var', 'confidence_weighted_var']
|
The observation variance: the members' spread, or that spread weighted by their confidences. |
fill_unobserved |
bool
|
Report the smoothed 2D in the cells nothing observed, instead of NaN. |
Source code in src/deeperfly/config/run.py
Tracking ¶
Bases: Table
[pose2d.tracking]: how center peaks become animals and stay themselves.
Read only when animals > 1. Every gate is in the view's own video pixels, and
the defaults are hexaview's (ADR-0063).
Attributes:
| Name | Type | Description |
|---|---|---|
min_score |
float
|
What a center peak must score to count as a detection. |
min_views |
int
|
Views that must see a center before it is an animal; 3 on hexaview. |
gate_px |
float
|
A view supports a 3D center when its nearest peak reprojects within this. |
min_separation_px |
float
|
Two centers closer than this in every view are one animal found twice; touching flies on hexaview are 85-95 px apart in the views across them, a split single blob under 35 (ADR-0131). |
max_step_px |
float
|
The frame-to-frame link gate, as the largest reprojected jump over the views. |
hold_frames |
int
|
Frames a track keeps its last position without a detection before the slot is freed. |
Source code in src/deeperfly/config/run.py
TrainConfig ¶
Bases: Table
A whole training document, with its paths resolved.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
TrainData
|
|
format_version |
int
|
The schema version the document is written for. |
model |
TrainModel
|
|
augment |
AugmentSpec | None
|
|
train |
TrainLoop
|
|
compute |
TrainCompute
|
|
unlabeled |
TrainUnlabeled | None
|
|
path |
Path | None
|
The file this was loaded from, or |
root |
Path | None
|
The directory its paths resolved against, the file's own; not a key. |
text |
str | None
|
The document as the training records it when the command line set
keys ( |
Source code in src/deeperfly/config/train.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
from_document
classmethod
¶
Build from a parsed document, resolving its paths (see the module docs).
Source code in src/deeperfly/config/train.py
load
classmethod
¶
Load, lint and type a training document.
changes are values by dotted key (overrides)
set over the file's before it is typed, as if the file said them; the
training records them, written into the file's text.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file, with the changes, breaks any rule of the schema. |
Source code in src/deeperfly/config/train.py
recorded_text ¶
The document as the training records it: the file's text, with --set keys.
Empty for a document built in memory.
Source code in src/deeperfly/config/train.py
TrainData ¶
Bases: Table
[data]: which labels to train on and what to hold out.
Three corpus kinds share the table, and a key of another kind is an error.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['project', 'df3d', 'lightning_pose']
|
|
task |
Literal['pose', 'locate']
|
|
projects |
tuple[str, ...]
|
For |
root |
TomlPath | None
|
The corpus directory, for the other two kinds. |
skeleton |
str | None
|
A packaged preset for a corpus kind, which carries no project;
|
holdout |
tuple[str, ...]
|
Selector held out and scored, never trained on: projects by their names in the collection (project_names), or a corpus's recordings. |
train |
tuple[str, ...]
|
Selector trained on; empty means every labeled project not held out. |
split |
TomlPath | None
|
A TOML file holding a |
holdout_every |
int
|
|
exclude |
tuple[str, ...]
|
|
views |
tuple[str, ...]
|
|
crops |
Crops
|
|
center_channel |
bool
|
Build the head one channel wider, trained to peak at each
animal's center (ADR-0063): the median of the frame's solved 3D
keypoints, projected, so it needs a calibrated project. Raise
|
fill |
Fill
|
|
boost |
Boost
|
|
mark_others |
bool
|
On a frame of several animals, mark every other animal's center in each sample's input (ADR-0148): a white disk in a black ring, so a window says which animal it is not about. The detector records it and draws the same mark at inference. |
mark_jitter |
float
|
Training-time error of a marked center, in input pixels, a stand-in for the window's at inference; evaluation marks exactly. |
off_view_weight |
float
|
Weight of a target that lands outside its own view's image, where no pixel is behind it (not the off-frame margin the head is built to carry). |
view_aspect |
dict[str, float]
|
View name -> the aspect (width / height) of its crop box,
instead of the input's, for a subject far from square such as a prism
strip's; a run config's |
keypoint_weights |
dict[str, float]
|
Per-point loss weight overrides, |
view_sides |
dict[str, str]
|
View name -> |
cache |
TomlPath | None
|
Where the decoded-frame cache lives; |
Source code in src/deeperfly/config/train.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
TrainLoop ¶
Bases: Table
[train]: the optimization loop's knobs, one default each.
Attributes:
| Name | Type | Description |
|---|---|---|
steps |
int
|
Optimizer steps to run. |
batch_size |
int
|
Samples per step -- view groups when |
images_per_batch |
int
|
With |
optimizer |
Optimizer
|
|
loss |
Loss
|
|
eval |
Eval
|
|
grad_checkpoint |
bool
|
Recompute the backbone blocks in the backward pass, to fit a larger model or batch in memory. Slower, same numbers. |
grad_clip |
float
|
Gradient-norm clip; 0 is off. |
amp |
bool
|
Mixed-precision forward/backward. |
ema_decay |
float
|
Exponential moving average of the weights; 0 is off. |
view_drop_p |
float
|
Probability of dropping a view from a training group. |
view_min |
int
|
Views a group keeps after dropping. |
grouped |
bool | None
|
Train on view groups rather than independent images; |
seed |
int
|
Seed for torch, numpy and the samplers. |
log_every |
int
|
Steps between log lines. |
out |
TomlPath | None
|
Where the training writes, against the document's directory;
|
Source code in src/deeperfly/config/train.py
TrainModel ¶
Bases: Table
[model]: the detector to build, the schema's one open table (ADR-0032).
Attributes:
| Name | Type | Description |
|---|---|---|
family |
Literal['monocular', 'simcc', 'mvt', 'fast']
|
|
backbone |
str | None
|
A |
pretrained |
bool
|
Load the backbone's pretrained weights. |
input_hw |
tuple[int, int]
|
Network input |
init_from |
ArtifactRef | None
|
Warm start from an earlier training's artifact: a path against
the document's directory (a directory means its |
extra |
dict[str, Any]
|
The family's own builder keys, checked against |
Source code in src/deeperfly/config/train.py
check_commented_headers ¶
Refuse a commented-out table header that uncommented keys follow.
# [smoothing] looks like the way to switch a stage off, but TOML binds the keys
below it to the previous table (ADR-0028).
Source code in src/deeperfly/document.py
check_format_version ¶
check_format_version(
data: Mapping,
kind: str,
expected: int = DOCUMENT_FORMAT_VERSION,
hint: str = "",
) -> None
Refuse a document written for another version of the schema.
Read before anything else, so another version's file is reported as such rather
than as an unknown key; a document that declares none is version 1. kind names
the document in the error and hint is appended to it.
Source code in src/deeperfly/document.py
load_document ¶
Parse a config file, linted, with the directory it lives in.
Every relative path in it resolves against that directory (ADR-0085), so it travels with the document.
Source code in src/deeperfly/document.py
match_names ¶
The names a selector claims, in names order; empty patterns mean all.
A list unions its matches. An entry with a glob character must match at least one
name and one without must be a name, since either miss is a typo; where names
the selector in the error.
Source code in src/deeperfly/document.py
without_animal_axis ¶
The table every config shares, and the run config's format version.
Compute ¶
Bases: Table
[compute]: the machine, not the run, so a committed config stays portable.
Every knob is a CLI flag too, and none changes what a run computes (ADR-0033).
Attributes:
| Name | Type | Description |
|---|---|---|
device |
str | None
|
|
Source code in src/deeperfly/config/_base.py
deeperfly train -c config.toml: the typed training config.
The tables are [data], [model], [augment], [train], [compute] and the
optional [unlabeled]. The schema still moves with the recipe, so a key may be
renamed between versions, and format_version is the one promise (ADR-0061).
[model] is the one open table: its extra keys go to the family's builder, checked
against the torch-free MODEL_KEYS (ADR-0032). Every path resolves against the
document's own directory (ADR-0085): [data] projects, root, split and cache,
init_from, teacher, [train] out.
AugmentSpec ¶
Bases: Table
[augment]: the training-time augmentation, mild by default.
An absent table means no augmentation, an empty one these defaults: strong
geometric augmentation and cutout cost contralateral accuracy in the previous
training repo's measurements. The loop reads it as
Augment. rig_symmetry replaces
the mirror draw of a grouped sample with one symmetry of its rig
(rig_symmetries):
each view's picture flipped as a mirror or a turn of the world would flip it,
which a flip of every view about its own axis is not on a rig whose cameras are
turned against each other; flip_p then goes unused for calibrated projects.
Source code in src/deeperfly/config/train.py
Boost ¶
Bases: Table
[data.boost]: projects whose labeled moments an epoch draws more often.
A corpus of thousands of composited or pseudo-labeled moments drowns a few dozen hand-labeled ones of the recordings that matter: drawn uniformly, each is seen less than once in a short run (ADR-0136).
Attributes:
| Name | Type | Description |
|---|---|---|
projects |
tuple[str, ...]
|
Project selector of the boosted projects; empty boosts nothing. |
share |
float
|
The share of an epoch the boosted projects' labeled animals make up, each repeated as often as that takes and never less than once; 0 is off. |
Source code in src/deeperfly/config/train.py
Crops ¶
Bases: Table
[data.crops]: how a training sample is cropped around its animal (ADR-0046).
Attributes:
| Name | Type | Description |
|---|---|---|
tightness |
tuple[float, float]
|
Log-uniform range of the crop's tightness around the animal; below 1 leaves points outside the crop on purpose. |
jitter |
float
|
Fraction of the crop size the window is shifted by. |
eval_tightness |
float
|
The fixed tightness a held-out sample is cropped at. |
min_points |
int
|
Below this many finite points a view falls back to the largest window of the frame at the input's aspect. |
full_p |
float
|
Probability of a letterboxed whole-frame crop instead, as an inference without a window sees; 0 once a locator makes the coarse pass (ADR-0064). |
Source code in src/deeperfly/config/train.py
Eval ¶
Bases: Table
[train.eval]: when the held-out projects are scored, and on what.
Attributes:
| Name | Type | Description |
|---|---|---|
every |
int
|
Steps between held-out evaluations; 0 evaluates only at the end. |
pck_px |
float
|
PCK threshold of the held-out report, in image pixels. |
tta |
bool
|
Also run the mirrored pass when evaluating. |
select_best |
str | None
|
Keep the evaluated weights that scored best on this metric, a
dotted path into the report ( |
Source code in src/deeperfly/config/train.py
Fill ¶
Bases: Table
[data.fill]: reprojected targets for the views a frame does not label.
Attributes:
| Name | Type | Description |
|---|---|---|
weight |
float
|
Weight of the filled targets; 0 turns the fill off. |
max_residual_px |
float
|
Skip the fill of a keypoint whose 3D reprojects further than this from the views that labeled it. |
min_views |
int
|
Labeled views a keypoint needs before its 3D is triangulated for the fill. |
Source code in src/deeperfly/config/train.py
Loss ¶
Bases: Table
[train.loss]: the objective's terms, each off at zero.
Attributes:
| Name | Type | Description |
|---|---|---|
sigma |
float
|
Target heatmap sigma in field cells. |
fg_weight |
float
|
Weight of the foreground cells in the heatmap loss. |
field_weight |
float
|
Weight of the field cross-entropy, which lets a soft-argmax readout learn the off-frame margin. |
center_weight |
float
|
Weight of the center channel's cross-entropy, when
|
coord_weight |
float
|
Weight of the decoded-coordinate loss. |
coord_radius |
int
|
Field cells the coordinate loss reads around the peak. |
coord_huber |
float
|
Huber knee of the coordinate loss, in input pixels. |
tri_weight |
float
|
Weight of the pair-triangulation loss over a view group. |
tri_huber |
float
|
Huber knee of the triangulation loss, in world units. |
tri_max_world |
float
|
Reject a triangulated pair further than this from the group's consensus, in world units. |
decode |
Literal['local', 'softargmax']
|
How the geometric losses read coordinates off the field in
training, |
Source code in src/deeperfly/config/train.py
Optimizer ¶
Bases: Table
[train.optimizer]: AdamW and its schedule.
Attributes:
| Name | Type | Description |
|---|---|---|
lr |
float
|
Peak learning rate after the warmup. |
weight_decay |
float
|
AdamW weight decay. |
warmup_steps |
int
|
Linear warmup length. |
backbone_lr_mult |
float
|
Learning-rate multiplier for the backbone's parameters. |
Source code in src/deeperfly/config/train.py
SplitFile ¶
Bases: Table
A [data] split file: what is held out, by project or by frame.
Projects are named as [data].holdout names them.
Attributes:
| Name | Type | Description |
|---|---|---|
holdout |
tuple[str, ...]
|
Selector held out whole, unioned with |
holdout_frames |
dict[str, tuple[int, ...]]
|
|
exclude_frames |
dict[str, tuple[int, ...]]
|
|
Source code in src/deeperfly/config/train.py
load
classmethod
¶
Parse a split file strictly: an unknown key is a ConfigError.
TrainCompute ¶
Bases: Compute
[compute] of a training config: the shared knobs and data loading (ADR-0088).
Attributes:
| Name | Type | Description |
|---|---|---|
workers |
int
|
Data-loading worker processes. |
Source code in src/deeperfly/config/train.py
TrainConfig ¶
Bases: Table
A whole training document, with its paths resolved.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
TrainData
|
|
format_version |
int
|
The schema version the document is written for. |
model |
TrainModel
|
|
augment |
AugmentSpec | None
|
|
train |
TrainLoop
|
|
compute |
TrainCompute
|
|
unlabeled |
TrainUnlabeled | None
|
|
path |
Path | None
|
The file this was loaded from, or |
root |
Path | None
|
The directory its paths resolved against, the file's own; not a key. |
text |
str | None
|
The document as the training records it when the command line set
keys ( |
Source code in src/deeperfly/config/train.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
from_document
classmethod
¶
Build from a parsed document, resolving its paths (see the module docs).
Source code in src/deeperfly/config/train.py
load
classmethod
¶
Load, lint and type a training document.
changes are values by dotted key (overrides)
set over the file's before it is typed, as if the file said them; the
training records them, written into the file's text.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file, with the changes, breaks any rule of the schema. |
Source code in src/deeperfly/config/train.py
recorded_text ¶
The document as the training records it: the file's text, with --set keys.
Empty for a document built in memory.
Source code in src/deeperfly/config/train.py
TrainData ¶
Bases: Table
[data]: which labels to train on and what to hold out.
Three corpus kinds share the table, and a key of another kind is an error.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['project', 'df3d', 'lightning_pose']
|
|
task |
Literal['pose', 'locate']
|
|
projects |
tuple[str, ...]
|
For |
root |
TomlPath | None
|
The corpus directory, for the other two kinds. |
skeleton |
str | None
|
A packaged preset for a corpus kind, which carries no project;
|
holdout |
tuple[str, ...]
|
Selector held out and scored, never trained on: projects by their names in the collection (project_names), or a corpus's recordings. |
train |
tuple[str, ...]
|
Selector trained on; empty means every labeled project not held out. |
split |
TomlPath | None
|
A TOML file holding a |
holdout_every |
int
|
|
exclude |
tuple[str, ...]
|
|
views |
tuple[str, ...]
|
|
crops |
Crops
|
|
center_channel |
bool
|
Build the head one channel wider, trained to peak at each
animal's center (ADR-0063): the median of the frame's solved 3D
keypoints, projected, so it needs a calibrated project. Raise
|
fill |
Fill
|
|
boost |
Boost
|
|
mark_others |
bool
|
On a frame of several animals, mark every other animal's center in each sample's input (ADR-0148): a white disk in a black ring, so a window says which animal it is not about. The detector records it and draws the same mark at inference. |
mark_jitter |
float
|
Training-time error of a marked center, in input pixels, a stand-in for the window's at inference; evaluation marks exactly. |
off_view_weight |
float
|
Weight of a target that lands outside its own view's image, where no pixel is behind it (not the off-frame margin the head is built to carry). |
view_aspect |
dict[str, float]
|
View name -> the aspect (width / height) of its crop box,
instead of the input's, for a subject far from square such as a prism
strip's; a run config's |
keypoint_weights |
dict[str, float]
|
Per-point loss weight overrides, |
view_sides |
dict[str, str]
|
View name -> |
cache |
TomlPath | None
|
Where the decoded-frame cache lives; |
Source code in src/deeperfly/config/train.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
TrainLoop ¶
Bases: Table
[train]: the optimization loop's knobs, one default each.
Attributes:
| Name | Type | Description |
|---|---|---|
steps |
int
|
Optimizer steps to run. |
batch_size |
int
|
Samples per step -- view groups when |
images_per_batch |
int
|
With |
optimizer |
Optimizer
|
|
loss |
Loss
|
|
eval |
Eval
|
|
grad_checkpoint |
bool
|
Recompute the backbone blocks in the backward pass, to fit a larger model or batch in memory. Slower, same numbers. |
grad_clip |
float
|
Gradient-norm clip; 0 is off. |
amp |
bool
|
Mixed-precision forward/backward. |
ema_decay |
float
|
Exponential moving average of the weights; 0 is off. |
view_drop_p |
float
|
Probability of dropping a view from a training group. |
view_min |
int
|
Views a group keeps after dropping. |
grouped |
bool | None
|
Train on view groups rather than independent images; |
seed |
int
|
Seed for torch, numpy and the samplers. |
log_every |
int
|
Steps between log lines. |
out |
TomlPath | None
|
Where the training writes, against the document's directory;
|
Source code in src/deeperfly/config/train.py
TrainModel ¶
Bases: Table
[model]: the detector to build, the schema's one open table (ADR-0032).
Attributes:
| Name | Type | Description |
|---|---|---|
family |
Literal['monocular', 'simcc', 'mvt', 'fast']
|
|
backbone |
str | None
|
A |
pretrained |
bool
|
Load the backbone's pretrained weights. |
input_hw |
tuple[int, int]
|
Network input |
init_from |
ArtifactRef | None
|
Warm start from an earlier training's artifact: a path against
the document's directory (a directory means its |
extra |
dict[str, Any]
|
The family's own builder keys, checked against |
Source code in src/deeperfly/config/train.py
TrainUnlabeled ¶
Bases: Table
[unlabeled]: the cross-view distillation stream over unlabeled moments.
kind = "project" only. A teacher predicts every view of sampled unlabeled
moments, the predictions are triangulated robustly and reprojected, and the
student trains on the consensus with some views' tokens masked (see
unlabeled).
Attributes:
| Name | Type | Description |
|---|---|---|
teacher |
ArtifactRef | None
|
The teacher artifact, named as |
n_per_project |
int
|
Unlabeled moments sampled per project, spread over the video, labeled frames skipped. |
exclude |
tuple[str, ...]
|
Project selector left out of the stream. |
transductive |
bool
|
Also draw from the held-out projects' unlabeled frames. |
agree_px |
float
|
Reprojection distance within which a view agrees with the consensus. |
min_views |
int
|
Agreeing views a keypoint needs before it has a consensus. |
conf_min |
float
|
Teacher confidence below which a view does not vote. |
geom_weight |
float
|
How far the target moves from the teacher's own pixel (0) toward the reprojected consensus (1); see consensus_targets. |
guard_frames |
int
|
Frames either side of a held-out frame the stream must not draw; 0 skips the held frames only. |
weight |
float
|
Weight of the distillation term against the labeled loss. |
mask_ratios |
tuple[float, ...]
|
Per-view token-mask ratios drawn per unlabeled group; one view per group always stays whole. |
masked_weight |
float
|
Cell weight on masked views. |
unmasked_weight |
float
|
Cell weight on whole views. |
crop_tightness |
tuple[float, float]
|
Log-uniform crop tightness around the consensus points. |
cache |
TomlPath | None
|
Where the unlabeled caches live, against the document's directory;
|
Source code in src/deeperfly/config/train.py
artifact_path ¶
A detector reference of a training or a run config, as the config holds it.
A released model's name stays a name, found in the cache when the detector is
loaded (ADR-0151). Anything else is a path against the document (ADR-0085), a
directory meaning its ARTIFACT_NAME.
Source code in src/deeperfly/config/train.py
deeperfly run PATH... -c config.toml: the typed run config (format 4).
A run config says what to compute, never what the videos are: the videos, the
layout, the views, the skeleton and the animal count are the project's
(deeperfly.toml, ADR-0081), and one config applied to several projects gives one
run per project. [calibration] holds the camera parameters a run starts from
(ADR-0086); every other table is a stage, enabled by its presence (ADR-0028) and
named for what it writes (ADR-0029, ADR-0034). Every path resolves against the
config's own directory (ADR-0085). What can only be checked against a project is
check_project. The schema is
docs/config-schema.md.
BallStage ¶
Bases: Table
[ball]: track the treadmill ball under a tethered animal -> ball/*.
spintrack, an optional extra (deeperfly[ball]), tracks the ball's rotation in
view's video; the ball's outline in the outline views places it on every frame,
starting from where the 3D pose's leg tips rest on it, and the pose orients the
animal on it (ball, ADR-0144). Everything it writes is in the
world frame.
Attributes:
| Name | Type | Description |
|---|---|---|
view |
str
|
The view whose video spintrack tracks: one that sees the ball's texture, unmirrored. |
outline |
tuple[str, ...]
|
View selector for the views whose outline of the ball places it; mirrored views are left out. Depth along a line of sight needs a view off it. |
input |
str | None
|
The 3D the ball is started from and the animal oriented by; omitted, the latest upstream 3D. |
contact |
tuple[str, ...]
|
Point selector for the points that rest on the ball in stance. |
stand |
tuple[str, ...]
|
Point selector for the points whose centroid is where the animal stands, just above the ball. |
front |
tuple[str, ...]
|
Point selector for the front of the body axis. |
hind |
tuple[str, ...]
|
Point selector for the back of the body axis. |
contact_frames |
int
|
How many opening frames of the 3D the ball's radius is fitted and the animal oriented in, as a ball can move in its holder later. |
two_pass |
bool
|
Map the ball in a throwaway first pass, as |
tracking |
dict[str, Any]
|
spintrack's |
Source code in src/deeperfly/config/run.py
BundleAdjustmentStage ¶
Bases: Table
[bundle_adjustment]: refine [calibration] on this project.
It starts from the parameters [calibration] gives and hands the refined rig to
the 3D stages after it; the result is the run's bundle_adjustment/views, a raw
view per view that a [calibration.views.<name>] table accepts. Cached like any
stage, so --force re-solves from [calibration] rather than refining the
refinement (ADR-0086).
Attributes:
| Name | Type | Description |
|---|---|---|
source |
Literal['pose2d/points', 'labels/points']
|
Which 2D to fit: the detector's, or the project's hand labels
(which need no |
points |
tuple[str, ...]
|
Point selector to fit on; empty uses every point. |
fixed |
tuple[str, ...]
|
Solver references held constant ( |
shared |
tuple[tuple[str, ...], ...]
|
Groups of references tied to one value. |
frames |
int
|
How many labeled or predicted frames to sample, evenly. |
weighted |
bool
|
Weight each residual by the detector's confidence. |
loss |
Literal['linear', 'soft_l1', 'huber', 'cauchy', 'arctan']
|
Robust loss for the solver. |
threshold_px |
float
|
Inlier margin of the robust loss, in pixels. |
max_nfev |
int
|
Maximum solver function evaluations. |
Source code in src/deeperfly/config/run.py
fixed_refs ¶
The references to hold; empty expands to the default for these views.
CorrectionStage ¶
Bases: Table
[correction]: fix known anatomical violations -> correction/points.
Two fixed sub-tables, applied in that order.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
str | None
|
The 3D to correct; omitted, the latest upstream 3D. |
static |
StaticCorrection | None
|
|
symmetrize |
SymmetrizeCorrection | None
|
|
Source code in src/deeperfly/config/run.py
IkStage ¶
Bases: Table
[ik]: fit a body model to the 3D pose -> ik/angles, ik/points.
The solve is QuickIK's, an optional extra (deeperfly[ik]); see
ik. model names a pack and binding where the skeleton's points
sit on it (ADR-0041); damping and symmetric_segments are ADR-0065 and
ADR-0066.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
str | None
|
The 3D to fit; omitted, the latest upstream 3D. |
model |
str
|
A packaged model pack ( |
binding |
str | None
|
The |
chains |
tuple[str, ...]
|
The model's non-leg chains to solve; empty solves every one the pack defines. The legs are always solved. |
iterations |
int
|
Gauss-Newton steps per frame. |
damping |
float
|
Levenberg-Marquardt damping of the step. |
neutral_weight |
float
|
Pull toward each DOF's neutral value, which pins the DOFs the keypoints do not determine. |
position_tolerance |
float
|
Early-stop threshold on the observations, in model units. |
angle_tolerance |
float
|
Early-stop threshold on the angles, in radians. |
fixed_body |
bool
|
Hold the body in the model frame and fit the legs to it (a tethered fly); false fits a 6-DOF root per frame. |
symmetric_segments |
bool
|
One shared length per segment for each leg and its mirror. |
weighted |
bool
|
Weight the observations by the detector's confidence. |
bounds |
dict[str, tuple[float, float]]
|
Per-DOF limits in degrees, |
markers |
dict[str, dict[str, Any]]
|
Per chain, |
Source code in src/deeperfly/config/run.py
InitialCalibration ¶
Bases: Table
[calibration]: the camera parameters a run starts from (ADR-0086).
Either a copy made at run start or placements written here, never both. A copy is of the values, so the run reproduces after the calibration files change; the values are what the geometry stages use, what their fingerprints hash and what the run stores.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
int | str | None
|
|
views |
dict[str, ViewSpec]
|
|
Source code in src/deeperfly/config/run.py
Pose2dStage ¶
Bases: Table
[pose2d]: run the detector over the video -> pose2d/*.
Several weights are an ensemble, collapsed by combine inside the forward pass,
so every later stage sees one pose2d/points.
Attributes:
| Name | Type | Description |
|---|---|---|
weights |
tuple[ArtifactRef, ...]
|
Trained artifacts: paths relative to the config (ADR-0085), a
directory meaning its |
combine |
Literal['mean', 'median']
|
How the members collapse into |
tta |
bool
|
Also run each frame mirrored and average the two decodes (ADR-0045). |
candidates |
int
|
Distinct peaks kept per |
crops |
dict[str, tuple[int, int, int, int] | tuple[tuple[int, int, int, int], ...]]
|
Fixed per-view windows |
tightness |
float
|
How much wider than the animal a discovered window is, as the
training's crop tightness measures it: the static windows, and the size
a per-frame window keeps. No effect on fixed |
crop_aspect |
dict[str, float]
|
Per view, the aspect (width / height) of the detector's window
instead of the input's, |
window |
Literal['static', 'per_frame']
|
|
locator |
ArtifactRef | None
|
The full-frame locator a per-frame run needs where views share a
frame (ADR-0064), named as |
tracking |
Tracking
|
|
Source code in src/deeperfly/config/run.py
Pose3dStage ¶
Bases: Table
[pose3d]: lift the 2D to one 3D track per keypoint -> pose3d/*.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
Literal['ransac', 'dlt', 'pictorial', 'election']
|
|
threshold_px |
float
|
Inlier margin of the consensus, in pixels; for |
min_views |
int
|
Views a point needs to be triangulated; for |
weighted |
bool
|
Weight each observation by its confidence's precision ( |
bone_prior |
float
|
|
veto |
tuple[str, ...]
|
View selectors that never vote (a weakly calibrated view): they take
no part in any triangulation, but |
Source code in src/deeperfly/config/run.py
RunCompute ¶
Bases: Compute
[compute]: the run's machine knobs, on top of the shared ones.
Attributes:
| Name | Type | Description |
|---|---|---|
batch |
int
|
Inference frames per forward pass, all views of a frame together. |
precision |
Literal['auto', 'float32', 'float16', 'bfloat16']
|
Inference dtype; |
compile |
bool
|
Compile the pose net with |
accumulate |
Literal['float32', 'float16']
|
What float16 matrix products accumulate in; |
Source code in src/deeperfly/config/run.py
RunConfig ¶
Bases: Table
A whole run config: the frames, the starting calibration, one table per stage.
Attributes:
| Name | Type | Description |
|---|---|---|
format_version |
int
|
The schema version the document is written for. |
name |
str | None
|
The run's name, its results file |
frames |
tuple[int | str, ...]
|
The frame set the run covers: indices and |
compute |
RunCompute
|
|
calibration |
InitialCalibration | None
|
|
pose2d |
Pose2dStage | None
|
|
bundle_adjustment |
BundleAdjustmentStage | None
|
|
pose3d |
Pose3dStage | None
|
|
smoothing |
SmoothingStage | None
|
|
correction |
CorrectionStage | None
|
|
ik |
IkStage | None
|
|
ball |
BallStage | None
|
|
render |
RenderConfig | None
|
|
path |
Path | None
|
The file this was loaded from, or |
text |
str | None
|
The document as a run records it when the command line set keys
( |
Source code in src/deeperfly/config/run.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | |
available ¶
{"group/array": axes} for everything a reference may name here.
The enabled stages' arrays plus the virtual video and labels/*, for a
project of animals animals; a stage that is off contributes nothing, so a
stale reference to it fails the check.
Source code in src/deeperfly/config/run.py
check_points ¶
Every point selector must match the skeleton's names.
Part of check_project.
Source code in src/deeperfly/config/run.py
check_project ¶
check_project(
views: Sequence[str],
animals: int,
points: Sequence[str],
videos: Sequence[str] = (),
) -> None
Check the config against a project: its views, videos, animals, keypoints.
What a run config cannot know on its own, since the videos, the views, the
skeleton and the animal count are the project's (ADR-0081). The run checks
each project before any stage runs, and so does --dry-run. videos are the
names a render grid may show whole.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If a table names a view or a point the project lacks, the calibration places other views, the animals need what the config lacks, or a render reference names nothing this config writes. |
Source code in src/deeperfly/config/run.py
from_document
classmethod
¶
Build from a parsed document, resolving its paths against doc_dir.
Source code in src/deeperfly/config/run.py
input_of ¶
What stage reads: its declared input, else the latest upstream 3D.
Source code in src/deeperfly/config/run.py
load
classmethod
¶
Load, lint and type a run config file.
changes are values by dotted key (overrides)
set over the file's before it is typed, as if the file said them; the run
records them, written into the file's text.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the file, with the changes, breaks any rule of the schema. |
Source code in src/deeperfly/config/run.py
recorded_text ¶
The document as a run records it: the file's text, with any --set keys.
Empty for a config built in memory.
Source code in src/deeperfly/config/run.py
SmoothingStage ¶
Bases: Table
[smoothing]: the geometric EKS over the 2D observations -> smoothing/*.
The keys are smooth's (ADR-0062).
Attributes:
| Name | Type | Description |
|---|---|---|
smooth_param |
float | None
|
The process-noise scale, smaller smoothing harder; omitted, fitted per keypoint. |
fit_frames |
int
|
Frames sampled for that fit. |
fit_iterations |
int
|
Iterations of the fit. |
inflate |
bool
|
Inflate the variance of a view that disagrees with the others. |
inflate_threshold |
float
|
The Mahalanobis distance above which it is inflated. |
inflate_factor |
float
|
How much it is inflated by, per round. |
var |
Literal['var', 'confidence_weighted_var']
|
The observation variance: the members' spread, or that spread weighted by their confidences. |
fill_unobserved |
bool
|
Report the smoothed 2D in the cells nothing observed, instead of NaN. |
Source code in src/deeperfly/config/run.py
StaticCorrection ¶
Bases: Table
[correction.static]: replace a point that should not move over time.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
tuple[str, ...]
|
Point selector to hold still (thorax-coxa joints, the neck). |
method |
Literal['mean', 'median', 'trimmed_mean', 'mode', 'geometric_median']
|
Which single position stands for every frame of a stretch. |
trim |
float
|
Fraction trimmed from each tail; |
Source code in src/deeperfly/config/run.py
SymmetrizeCorrection ¶
Bases: Table
[correction.symmetrize]: mirror paired points about the animal's midline.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
tuple[str, ...]
|
Selector naming either half of each pair; the skeleton's
|
midline |
tuple[str, ...]
|
Points that define the sagittal plane. |
per_frame |
bool
|
Fit the plane per frame instead of once per stretch. |
strength |
float
|
How far toward the symmetric solution to move; 0 is off. |
Source code in src/deeperfly/config/run.py
Tracking ¶
Bases: Table
[pose2d.tracking]: how center peaks become animals and stay themselves.
Read only when animals > 1. Every gate is in the view's own video pixels, and
the defaults are hexaview's (ADR-0063).
Attributes:
| Name | Type | Description |
|---|---|---|
min_score |
float
|
What a center peak must score to count as a detection. |
min_views |
int
|
Views that must see a center before it is an animal; 3 on hexaview. |
gate_px |
float
|
A view supports a 3D center when its nearest peak reprojects within this. |
min_separation_px |
float
|
Two centers closer than this in every view are one animal found twice; touching flies on hexaview are 85-95 px apart in the views across them, a split single blob under 35 (ADR-0131). |
max_step_px |
float
|
The frame-to-frame link gate, as the largest reprojected jump over the views. |
hold_frames |
int
|
Frames a track keeps its last position without a detection before the slot is freed. |
Source code in src/deeperfly/config/run.py
check_run_name ¶
Refuse a run name that is not a path below the results directory.
A run is results/<name>.h5, so / nests it and anything else goes, but an
absolute name or a .. would leave the directory (ADR-0082).
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the name is empty, absolute or climbs out. |
Source code in src/deeperfly/config/run.py
parse_frames ¶
A frame set's entries as indices and slices, checked but not yet bounded.
An entry is an index (5000, or "5000") or a numpy slice string
"start:stop:step" with any part omitted ("0::2", ":1000", "::10").
Raises:
| Type | Description |
|---|---|
ValueError
|
On an entry that is neither, a negative number, or a zero step. |
Source code in src/deeperfly/config/run.py
[render]: video frames and result arrays mapped onto the panels of a video.
A video is a grid of panels, each showing a recorded view, a whole video with every
view it carries (ADR-0096), a synthetic one from [render.views], or a blank panel for
plots and text. Layers draw in order into every panel that can host them, each pairing
one data reference with one draw kind, and the referenced array's shape decides what
it can feed (ADR-0031). The checks here need no
project, only the inventory of what the enabled stages write; those that need one live
in RunConfig.
Layer
module-attribute
¶
Layer = Annotated[
VideoLayer
| SkeletonLayer
| MeshLayer
| BoxLayer
| BallLayer
| TraceLayer
| TextLayer,
Field(discriminator="draw"),
]
One entry of a video's layers, a table per draw kind (ADR-0059).
A key on the wrong kind, radius on a text layer, is an unknown key.
BallLayer ¶
Bases: _Layer
{ draw = "ball", data = "ball/center" }: the treadmill ball, as a view sees it.
The ball's outline, and the trail the animal has walked over it: the surface point it stood on at each recent frame, carried to where the ball has turned it since, on the side the view faces, dark blue to cyan from old to new, as spintrack's debug video draws it.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['ball']
|
The kind. |
data |
str
|
|
color |
str | None
|
The outline's |
width |
float | None
|
Line width in panel pixels, of the outline and the trail. |
alpha |
float | None
|
Opacity. |
window_frames |
int
|
How many frames of the trail to draw, back to the start of the frame's stretch at most; 0 draws none. |
Source code in src/deeperfly/config/render.py
BoxLayer ¶
Bases: _Layer
{ draw = "box", data = "pose2d/crops" }: each animal's rectangle, per view.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['box']
|
The kind. |
data |
str
|
A |
color |
str | None
|
|
width |
float | None
|
Line width in panel pixels. |
dash |
tuple[float, float] | None
|
|
alpha |
float | None
|
Opacity. |
Source code in src/deeperfly/config/render.py
MeshLayer ¶
Bases: _Layer
{ draw = "mesh", data = "ik/points" }: the fitted body model, skinned.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['mesh']
|
The kind. |
data |
str
|
|
alpha |
float | None
|
Opacity. A mesh has no keypoints to fade by, so a number only. |
hide |
tuple[str, ...]
|
Body-model segments left out. |
Source code in src/deeperfly/config/render.py
OutputSpec ¶
Bases: Table
[render.outputs.<name>]: one output video, <name>.mp4.
Attributes:
| Name | Type | Description |
|---|---|---|
grid |
tuple[tuple[str, ...], ...]
|
Panel names, row by row: views, videos, synthetic views and blank
panels. |
layers |
tuple[Layer, ...]
|
What to draw, in order, back to front. |
crop |
str | None
|
A |
frames |
FrameRange
|
|
speed |
float | None
|
Playback rate, overriding |
fps |
float | None
|
Encoded frame rate, overriding |
cell |
tuple[int, int] | None
|
Cell size |
max_size |
tuple[Side, Side] | None
|
The largest |
background |
str | None
|
Background color, overriding |
Source code in src/deeperfly/config/render.py
RenderConfig ¶
Bases: Table
[render]: the videos a run writes, and the defaults they share.
Attributes:
| Name | Type | Description |
|---|---|---|
outputs |
dict[str, OutputSpec]
|
|
views |
dict[str, RenderView]
|
|
frames |
FrameRange
|
|
speed |
float
|
Playback rate: the animation runs at the video's fps times |
fps |
float
|
The rate written into the file, each drawn frame held a whole number of
output frames to reach it, so none is dropped; |
cell |
tuple[int, int]
|
One cell's |
max_size |
tuple[Side, Side]
|
The largest |
background |
str
|
What a panel is filled with where content does not reach. |
codec |
str
|
The encoder to hand the frames to. |
crf |
int | None
|
The encoder's constant rate factor: lower keeps more, in a larger
file. 18 keeps a thin colored mark sharp over footage, which libx264's
own 23 smears; |
Source code in src/deeperfly/config/render.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
check ¶
Check every reference and panel against what the run actually writes.
available is {"group/array": axes} for every array the enabled stages
write, plus video and labels/*
(available). A (V,T,K) alpha may
not reach a synthetic view, which has no view axis.
Source code in src/deeperfly/config/render.py
RenderView ¶
Bases: Table
[render.views.<name>]: a synthetic view, written as an orbit placement.
The orbit keys are OrbitView's; distance, focal and
image_size may be left to the renderer, which fits them to the 3D in the panel.
Attributes:
| Name | Type | Description |
|---|---|---|
azimuth_deg |
float
|
Orbit rotation in the world xy-plane. |
elevation_deg |
float
|
Orbit lift toward |
roll_deg |
float
|
Rotation about the optical axis. |
look_at |
tuple[float, float, float]
|
World point the camera aims at. |
distance |
float | None
|
Distance from |
focal |
float | None
|
Focal length in pixels. |
image_size |
tuple[int, int] | None
|
Panel |
Source code in src/deeperfly/config/render.py
SkeletonLayer ¶
Bases: _Layer
{ draw = "skeleton", data = ... }: keypoints and bones over the panel.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['skeleton']
|
The kind. |
data |
str
|
The array to draw: a |
select |
tuple[str, ...]
|
Point selector ( |
color |
str | None
|
|
colors |
dict[str, str]
|
Per-name color overrides. |
edge_color |
str | None
|
One color for every edge, overriding the palette. |
radius |
float | None
|
Point radius in panel pixels; 0 draws edges only. |
width |
float | None
|
Line width in panel pixels; 0 draws points only. |
dash |
tuple[float, float] | None
|
|
outline |
float | None
|
Outline width drawn under the mark, for contrast on pale footage; none by default, marks carrying their own color. |
alpha |
float | str | None
|
Opacity, or a |
alpha_range |
tuple[float, float] | None
|
|
identity |
Literal['hue', 'label', 'dash', 'none']
|
How several animals are told apart: |
Source code in src/deeperfly/config/render.py
TextLayer ¶
Bases: _Layer
{ draw = "text", text = ... }: a caption.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['text']
|
The kind. |
text |
str
|
The caption, with |
size |
float | None
|
Text size in panel pixels. |
color |
str | None
|
|
anchor |
Literal['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'] | None
|
Which corner (or center) the text sits at. |
Source code in src/deeperfly/config/render.py
TraceLayer ¶
Bases: _Layer
{ draw = "trace", data = ... }: a named-channel time series, plotted.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['trace']
|
The kind. |
data |
str
|
A |
select |
tuple[str, ...]
|
Channel selector. |
window_frames |
int
|
How many frames of history the trace shows. |
width |
float | None
|
Line width in panel pixels. |
color |
str | None
|
|
Source code in src/deeperfly/config/render.py
VideoLayer ¶
Bases: _Layer
{ draw = "video" }: the panel view's own frames.
Attributes:
| Name | Type | Description |
|---|---|---|
draw |
Literal['video']
|
The kind. |
alpha |
float | str | None
|
Opacity, or a |