deeplabcut.pose_estimation_tensorflow
Modules:
| Name | Description |
|---|---|
auxfun_models |
DeepLabCut2.0 Toolbox (deeplabcut.org) |
auxfun_multianimal |
DeepLabCut2.0 Toolbox (deeplabcut.org) |
auxiliaryfunctions |
DeepLabCut2.0 Toolbox (deeplabcut.org) |
backbones |
|
config |
|
core |
|
datasets |
|
export |
|
inferenceutils |
|
lib |
|
modelzoo |
|
nnets |
|
predict |
|
predict_multianimal |
|
predict_videos |
|
trackingutils |
|
training |
|
util |
Adapted from DeeperCut by Eldar Insafutdinov: |
visualize |
Adapted from DeeperCut by Eldar Insafutdinov |
visualizemaps |
|
Functions:
| Name | Description |
|---|---|
AnalyzeVideo |
Helper function for analyzing a video. |
GetPoseDynamic |
Non batch wise pose estimation for video cap by dynamically cropping around |
GetPoseF |
Batchwise prediction of pose. |
GetPoseF_GTF |
Batchwise prediction of pose. |
GetPoseF_OV |
Prediction of pose. |
GetPoseS |
Non batch wise pose estimation for video cap. |
GetPoseS_GTF |
Non batch wise pose estimation for video cap. |
GetPosesofFrames |
Batchwise prediction of pose for frame list in directory. |
Plotting |
Function used for plotting GT and predictions. |
analyze_time_lapse_frames |
Analyze all images (of type |
analyze_videos |
Makes prediction based on a trained network. |
argmax_pose_predict |
Combine scoremat and offsets to the final pose. |
calculatepafdistancebounds |
Returns distances along paf edges in train/test data. |
cfg_from_file |
Load a config from file filename and merge it into the default options. |
collect_video_paths |
Collects video paths from a given set of data paths: directories, files, or a mix |
convert_detections2tracklets |
This should be called at the end of deeplabcut.analyze_videos for multianimal |
evaluate_network |
Evaluates the network. |
extract_cnn_output |
Extract locref + scmap from network. |
extract_maps |
Extracts the scoremap, locref, partaffinityfields (if available). |
extract_save_all_maps |
Extract scoremap, location refinement field and part affinity field predictions. |
get_available_requested_snapshots |
Intersects the requested snapshot names with the available snapshots. |
get_snapshots_by_index |
Assume available_snapshots is ordered in ascending order. |
keypoint_error |
Computes the RMSE error for each bodypart. |
make_results_file |
Makes result file in csv format and saves under evaluation_results directory. |
pairwisedistances |
Calculates the pairwise Euclidean distance metric over body parts vs. |
renamed_parameter |
Support a renamed keyword argument while warning callers to update. |
return_evaluate_network_data |
Returns the results for (previously evaluated) network. |
return_train_network_path |
Returns the training and test pose config file names as well as the folder where |
stitch_tracklets |
Stitch sparse tracklets into full tracks via a graph-based, minimum-cost flow |
train_network |
Trains the network with the labels in the training dataset. |
visualize_locrefs |
Plots a scoremap and the corresponding location refinement field on an image. |
visualize_paf |
Plots the PAF on top of the image. |
visualize_scoremaps |
Plots scoremaps as an image overlay. |
AnalyzeVideo
AnalyzeVideo(
video,
DLCscorer,
DLCscorerlegacy,
trainFraction,
cfg,
dlc_cfg,
sess,
inputs,
outputs,
pdindex,
save_as_csv,
destfolder=None,
TFGPUinference=True,
dynamic=(False, 0.5, 10),
use_openvino="CPU" if is_openvino_available else None,
)
Helper function for analyzing a video.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
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 | |
GetPoseDynamic
Non batch wise pose estimation for video cap by dynamically cropping around previously detected parts.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
GetPoseF
Batchwise prediction of pose.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
GetPoseF_GTF
Batchwise prediction of pose.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
GetPoseF_OV
Prediction of pose.
Source code in deeplabcut/pose_estimation_tensorflow/core/openvino/session.py
GetPoseS
Non batch wise pose estimation for video cap.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
GetPoseS_GTF
Non batch wise pose estimation for video cap.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
GetPosesofFrames
Batchwise prediction of pose for frame list in directory.
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
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 | |
Plotting
Function used for plotting GT and predictions.
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
analyze_time_lapse_frames
analyze_time_lapse_frames(
config, directory, frametype=".png", shuffle=1, trainingsetindex=0, gputouse=None, save_as_csv=False, modelprefix=""
)
Analyze all images (of type frametype) in a folder and store the output in
one file.
You can crop the frames (before analysis), by changing 'cropping'=True and setting 'x1','x2','y1','y2' in the config file.
Output labels are stored as a MultiIndex Pandas DataFrame containing the network
name, body part name, (x, y) label position in pixels, and likelihood for each
frame per body part. These arrays are stored in HDF format in the same directory
as the images. If save_as_csv is True, data can also be exported as CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
string
|
Full path to directory containing the frames that shall be analyzed. |
required |
|
string
|
Checks for the file extension of the frames.
Only images with this extension are analyzed. Defaults to |
'.png'
|
|
int
|
Shuffle index of the training dataset used for training the network. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). Defaults to 0. |
0
|
|
int
|
Natural number indicating the number of your GPU (see number in nvidia-smi). If you do not have a GPU, set to None. See: https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries |
None
|
|
bool
|
Saves the predictions in a .csv file. Defaults to False. |
False
|
|
str
|
Directory containing the deeplabcut models to use. Defaults to "". |
''
|
Examples:
If you want to analyze all frames in /analysis/project/timelapseexperiment1:
deeplabcut.analyze_images(
"/analysis/project/reaching-task/config.yaml",
"/analysis/project/timelapseexperiment1",
)
Note
For test purposes one can extract all frames from a video with ffmpeg, e.g. ffmpeg -i testvideo.avi thumb%04d.png
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 | |
analyze_videos
analyze_videos(
config,
videos,
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
gputouse=None,
save_as_csv=False,
in_random_order=True,
destfolder=None,
batchsize=None,
cropping=None,
TFGPUinference=True,
dynamic=(False, 0.5, 10),
modelprefix="",
robust_nframes=False,
allow_growth=False,
use_shelve=False,
auto_track=True,
n_tracks=None,
animal_names=None,
calibrate=False,
identity_only=False,
use_openvino="CPU" if is_openvino_available else None,
)
Makes prediction based on a trained network.
The index of the trained network is specified by parameters in the config file (in particular the variable 'snapshotindex').
The labels are stored as MultiIndex Pandas Array, which contains the name of the network, body part name, (x, y) label position in pixels, and the likelihood for each frame per body part. These arrays are stored in an efficient Hierarchical Data Format (HDF) in the same directory where the video is stored. However, if the flag save_as_csv is set to True, the data can also be exported in comma-separated values format (.csv), which in turn can be imported in many programs, such as MATLAB, R, Prism, etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Full path of the config.yaml file. |
required |
|
list[str]
|
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. |
required |
|
str | Sequence[str] | None
|
Controls how |
None
|
|
int
|
Shuffle index of the training dataset used for training the network. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). Defaults to 0. |
0
|
|
int or None
|
Indicates the GPU to use (see number in |
None
|
|
bool
|
Saves the predictions in a .csv file. Defaults to False. |
False
|
|
bool
|
Whether or not to analyze videos in a random order.
This is only relevant when specifying a video directory in |
True
|
|
string or None
|
Destination folder for analysis data. If |
None
|
|
int or None
|
Batch size for inference; overwrites |
None
|
|
list or None
|
List of cropping coordinates as [x1, x2, y1, y2].
Note that the same cropping parameters will then be used for all videos.
If different video crops are desired, run |
None
|
|
bool
|
Perform inference on GPU with TensorFlow code. Introduced in "Pretraining boosts out-of-domain robustness for pose estimation" by Alexander Mathis, Mert Yüksekgönül, Byron Rogers, Matthias Bethge, Mackenzie W. Mathis. Source: https://arxiv.org/abs/1909.11229. Defaults to True. |
True
|
|
tuple[bool, float, int]
|
Triple containing (state, detection_threshold, margin). If state is True, dynamic cropping is performed: when any body part exceeds detection_threshold, object boundaries are computed from min/max x/y positions, expanded by margin, and only the posture within this crop is analyzed until the object is lost. Defaults to (False, 0.5, 10). |
(False, 0.5, 10)
|
|
str
|
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder. Defaults to "". |
''
|
|
bool
|
Evaluate a video's number of frames in a robust manner. This option is slower (as the whole video is read frame-by-frame), but does not rely on metadata, hence its robustness against file corruption. Defaults to False. |
False
|
|
bool
|
For some smaller GPUs the memory issues happen. If |
False
|
|
bool
|
By default, data are dumped in a pickle file at the end of the video analysis. Otherwise, data are written to disk on the fly using a "shelf"; i.e., a pickle-based, persistent, database-like object by default, resulting in constant memory footprint. Defaults to False. |
False
|
|
bool
|
For multi-animal projects, automatically perform
tracking and stitching to produce the final h5 file. If False, run
|
True
|
|
bool
|
If True and animal identity was learned by the model, assembly and tracking rely exclusively on identity prediction. Defaults to False. |
False
|
|
bool
|
If True, use training data to calibrate the animal assembly procedure. Defaults to False. |
False
|
|
int or None
|
Number of tracks to reconstruct. By default from config.yaml. Pass another value if animal count differs from training. Defaults to None. |
None
|
|
list[str]
|
If you want the names given to individuals in the labeled data file, you can
specify those names as a list here. If given and |
None
|
|
str
|
Use "CPU" for inference if OpenVINO is available in the Python environment. Defaults to "CPU" when OpenVINO is available, otherwise None. |
'CPU' if is_openvino_available else None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
DLCScorer; the scorer used to analyze the videos. |
Examples:
Analyzing a single video on Windows:
deeplabcut.analyze_videos(
'C:\myproject\reaching-task\config.yaml',
['C:\yourusername\rig-95\Videos\reachingvideo1.avi'],
)
Analyzing a single video on Linux/MacOS:
deeplabcut.analyze_videos(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/videos/reachingvideo1.avi'],
)
Analyze all videos of type avi in a folder:
deeplabcut.analyze_videos(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/videos'],
video_extensions='.avi',
)
Analyze multiple videos:
deeplabcut.analyze_videos(
'/analysis/project/reaching-task/config.yaml',
[
'/analysis/project/videos/reachingvideo1.avi',
'/analysis/project/videos/reachingvideo2.avi',
],
)
Analyze multiple videos with shuffle=2:
deeplabcut.analyze_videos(
'/analysis/project/reaching-task/config.yaml',
[
'/analysis/project/videos/reachingvideo1.avi',
'/analysis/project/videos/reachingvideo2.avi',
],
shuffle=2,
)
Analyze multiple videos with shuffle=2, save results as an additional csv file:
deeplabcut.analyze_videos(
'/analysis/project/reaching-task/config.yaml',
[
'/analysis/project/videos/reachingvideo1.avi',
'/analysis/project/videos/reachingvideo2.avi',
],
shuffle=2,
save_as_csv=True,
)
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 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 | |
argmax_pose_predict
Combine scoremat and offsets to the final pose.
Source code in deeplabcut/pose_estimation_tensorflow/core/predict.py
calculatepafdistancebounds
calculatepafdistancebounds(config, shuffle=0, trainingsetindex=0, modelprefix='', numdigits=0, onlytrain=False)
Returns distances along paf edges in train/test data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
int
|
Integer specifying shuffle index of the training dataset. Defaults to 0. |
0
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). This variable can also be set to "all". |
0
|
|
int
|
Number of digits to round for distances. |
0
|
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
cfg_from_file
Load a config from file filename and merge it into the default options.
Source code in deeplabcut/pose_estimation_tensorflow/config.py
collect_video_paths
collect_video_paths(
data_path: str | Path | list[str | Path],
extensions: str | Sequence[str] | None = None,
shuffle: bool = False,
exclude_patterns: Sequence[str] = DEFAULT_EXCLUDE_PATTERNS,
) -> list[Path]
Collects video paths from a given set of data paths: directories, files, or a mix of both. Directories are scanned one level deep (non-recursively).
Files and directories are treated differently with respect to extension filtering:
- File paths are accepted as-is when extensions is None; only filtered when
extensions is explicitly set.
- Directory contents are always filtered by extension: by SUPPORTED_VIDEOS when
extensions is None, or by the given value(s) otherwise.
- exclude_patterns are always applied to both files and directory contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path | list[str | Path]
|
Path or list of paths to folders containing videos, or individual video files. Can be a mix of directories and files. |
required |
|
str | Sequence[str] | None
|
Controls extension filtering for collected video files.
- |
None
|
|
bool
|
Whether to shuffle the order of videos. If |
False
|
|
Sequence[str]
|
Patterns to exclude from the collection. Defaults to
|
DEFAULT_EXCLUDE_PATTERNS
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
The paths of videos to analyze. Duplicate paths are removed. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If any path in |
ValueError
|
If |
Source code in deeplabcut/utils/auxfun_videos.py
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 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 | |
convert_detections2tracklets
convert_detections2tracklets(
config,
videos,
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
overwrite=False,
destfolder=None,
ignore_bodyparts=None,
inferencecfg=None,
modelprefix="",
greedy=False,
calibrate=False,
window_size=0,
identity_only=False,
track_method="",
)
This should be called at the end of deeplabcut.analyze_videos for multianimal projects!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
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. |
required |
|
str | Sequence[str] | None
|
Controls how |
None
|
|
int
|
Shuffle index of the training dataset used for training the network. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). Defaults to 0. |
0
|
|
bool
|
Overwrite tracks file; recompute tracks from full detections. Defaults to False. |
False
|
|
string
|
Destination folder for analysis data (default is the path of the video). Note that for subsequent analysis this folder also needs to be passed. |
None
|
|
list
|
List of body part names to ignore during tracking. By default, all body parts are used. Defaults to None. |
None
|
|
dict
|
Configuration for inference (assembly of individuals). Ideally obtained from cross validation. By default loaded from inference_cfg.yaml. Defaults to None. |
None
|
|
str
|
Directory containing the deeplabcut models to use. Defaults to "". |
''
|
|
bool
|
Use greedy assembly instead of default method. Defaults to False. |
False
|
|
bool
|
If True, use training data to calibrate the animal assembly procedure. This improves its robustness to wrong body part links, but requires very little missing data. Defaults to False. |
False
|
|
int
|
Recurrent connections in the past |
0
|
|
bool
|
If True and animal identity was learned by the model, assembly and tracking rely exclusively on identity prediction. Defaults to False. |
False
|
|
string
|
Specifies the tracker used to generate the pose estimation data. For multiple animals, must be either 'box', 'skeleton', or 'ellipse' and will be taken from the config.yaml file if none is given. Defaults to "". |
''
|
Examples:
If you want to convert detections to tracklets:
deeplabcut.convert_detections2tracklets(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/video1.mp4'],
video_extensions='.mp4',
)
If you want to convert detections to tracklets based on box_tracker:
deeplabcut.convert_detections2tracklets(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/video1.mp4'],
video_extensions='.mp4',
track_method='box',
)
Source code in deeplabcut/pose_estimation_tensorflow/predict_videos.py
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 | |
evaluate_network
evaluate_network(
config,
Shuffles=None,
trainingsetindex=0,
plotting=False,
show_errors=True,
comparisonbodyparts="all",
gputouse=None,
rescale=False,
modelprefix="",
per_keypoint_evaluation: bool = False,
snapshots_to_evaluate: list[str] = None,
)
Evaluates the network.
Evaluates the network based on the saved models at different stages of the training network. The evaluation results are stored in the .h5 and .csv file under the subdirectory 'evaluation_results'. Change the snapshotindex parameter in the config file to 'all' in order to evaluate all the saved models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file. |
required |
|
list
|
List of integers specifying the shuffle indices of the training dataset. Defaults to [1]. |
required |
|
int or str
|
Integer specifying which "TrainingsetFraction" to use. Note that "TrainingFraction" is a list in config.yaml. This variable can also be set to "all". Defaults to 0. |
0
|
|
bool or str
|
Plots the predictions on the train and test
images. If provided it must be either |
False
|
|
bool
|
Display train and test errors. Defaults to True. |
True
|
|
str or list
|
The average error will be computed for those body parts only. The provided list has to be a subset of the defined body parts. Defaults to "all". |
'all'
|
|
int or None
|
Indicates the GPU to use (see number in
|
None
|
|
bool
|
Evaluate the model at the |
False
|
|
str
|
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder. Defaults to "". |
''
|
|
bool
|
Compute the train and test RMSE for each keypoint, and save the results to a {model_name}-keypoint-results.csv in the evaluation-results folder. Defaults to False. |
False
|
|
list[str]
|
List of snapshot names to evaluate (e.g. ["snapshot-50000", "snapshot-75000", ...]). Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
None |
Examples:
If you do not want to plot and evaluate with shuffle set to 1:
deeplabcut.evaluate_network(
"/analysis/project/reaching-task/config.yaml",
Shuffles=[1],
)
If you want to plot and evaluate with shuffle set to 0 and 1:
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",
)
Note: This defaults to standard plotting for single-animal projects.
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
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 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 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 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 | |
extract_cnn_output
Extract locref + scmap from network.
Source code in deeplabcut/pose_estimation_tensorflow/core/predict.py
extract_maps
extract_maps(config, shuffle=0, trainingsetindex=0, gputouse=None, rescale=False, Indices=None, modelprefix='')
Extracts the scoremap, locref, partaffinityfields (if available).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
integer
|
Integer specifying shuffle index of the training dataset. Defaults to 0. |
0
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). This variable can also be set to "all". Defaults to 0. |
0
|
|
int
|
GPU index (see nvidia-smi). Use None if no GPU. Defaults to None. |
None
|
|
bool
|
Evaluate the model at the 'global_scale' variable (as set in the test/pose_config.yaml file for a particular project). I.e. every image will be resized according to that scale and prediction will be compared to the resized ground truth. The error will be reported in pixels at rescaled to the original size. I.e. For a [200,200] pixel image evaluated at global_scale=.5, the predictions are calculated on [100,100] pixel images, compared to 1/2*ground truth and this error is then multiplied by 2!. The evaluation images are also shown for the original size! Defaults to False. |
False
|
|
list
|
Image indices for which to extract maps. Defaults to None. |
None
|
|
str
|
Directory containing the deeplabcut models to use. Defaults to "". |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dictionary indexed by trainingsetfraction, snapshotindex, and imageindex; each item contains (image, scmap, locref, paf, bpt names, partaffinity graph, imagename, True/False if this image was in trainingset). |
Examples:
If you want to extract the data for image 0 and 103 (of the training set) for model trained with shuffle 0:
deeplabcut.extract_maps(configfile, 0, Indices=[0, 103])
Source code in deeplabcut/pose_estimation_tensorflow/visualizemaps.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 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 | |
extract_save_all_maps
extract_save_all_maps(
config,
shuffle=1,
trainingsetindex=0,
comparisonbodyparts="all",
extract_paf=True,
all_paf_in_one=True,
gputouse=None,
rescale=False,
Indices=None,
modelprefix="",
dest_folder=None,
)
Extract scoremap, location refinement field and part affinity field predictions.
Maps are rescaled to the size of the input image and stored in the corresponding model folder in /evaluation-results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
integer
|
Integer specifying shuffle index of the training dataset. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). This variable can also be set to "all". Defaults to 0. |
0
|
|
list of bodyparts
|
Average error for those body parts only (subset of all body parts). Defaults to "all". |
'all'
|
|
bool
|
Extract part affinity fields by default. Note that turning it off will make the function much faster. Defaults to True. |
True
|
|
bool
|
By default, all part affinity fields are displayed on a single frame. If false, individual fields are shown on separate frames. Defaults to True. |
True
|
|
int
|
GPU index (see nvidia-smi). Use None if no GPU. Defaults to None. |
None
|
|
bool
|
Evaluate at global_scale from pose_config.yaml. Defaults to False. |
False
|
|
list
|
Image indices for which to compute scmap/locref/paf. Defaults to None. |
None
|
|
str
|
Directory containing the deeplabcut models to use. Defaults to "". |
''
|
|
string
|
Destination folder for saved maps. Defaults to None. |
None
|
Examples:
Calculated maps for images 0, 1 and 33.
deeplabcut.extract_save_all_maps(
"/analysis/project/reaching-task/config.yaml", shuffle=1, Indices=[0, 1, 33]
)
Source code in deeplabcut/pose_estimation_tensorflow/visualizemaps.py
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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 | |
get_available_requested_snapshots
get_available_requested_snapshots(requested_snapshots: list[str], available_snapshots: list[str]) -> list[str]
Intersects the requested snapshot names with the available snapshots.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Snapshot names. |
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
get_snapshots_by_index
Assume available_snapshots is ordered in ascending order.
Returns snapshot names.
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
keypoint_error
keypoint_error(
df_error: DataFrame, df_error_p_cutoff: DataFrame, train_indices: list[int], test_indices: list[int]
) -> pd.DataFrame
Computes the RMSE error for each bodypart.
The error dataframes can be in single animal format (non-hierarchical columns, one column for each bodypart) or multi-animal format (hierarchical columns with 3 levels: "scorer", "individuals", "bodyparts").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DataFrame
|
dataframe containing the RMSE error for each image, individual and bodypart |
required |
|
DataFrame
|
dataframe containing the RMSE error with p-cutoff for each image, individual and bodypart |
required |
|
list[int]
|
the indices of rows in the dataframe that are in the train set |
required |
|
list[int]
|
the indices of rows in the dataframe that are in the test set |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A dataframe containing 4 rows (train and test error, with and without p-cutoff) and one column for each bodypart. |
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
make_results_file
Makes result file in csv format and saves under evaluation_results directory.
If the file exists (typically, when the network has already been evaluated), newer results are appended to it.
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
pairwisedistances
Calculates the pairwise Euclidean distance metric over body parts vs.
images
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
renamed_parameter
renamed_parameter(*, old: str, new: str, since: str | None = None) -> Callable[[Callable[P, R]], Callable[P, R]]
Support a renamed keyword argument while warning callers to update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The old parameter name that callers may still pass. |
required |
|
str
|
The current parameter name the function actually accepts. |
required |
|
str | None
|
Version when the rename happened. |
None
|
Rules
newmust be the name used in the function signature and all internal call-sites.oldmust not appear in the signature.- Do not chain renames. If
Awas renamed toBandBis later renamed toC, replace theA→Bdecorator withA→Cdirectly rather than stacking a second decorator. Example: @renamed_parameter(old="A", new="C", since="12.4.0") @renamed_parameter(old="B", new="C", since="13.0.0") def func(*, C: int): print(f"C={C}") - Multiple independent renames on the same function (e.g.
batchsize→batch_sizeandvideotype→video_extensions) are fine as long as they do not form a chain. - This decorator only intercepts keyword arguments. Positional arguments are passed through unchanged; renaming a parameter that callers commonly pass positionally will not be caught.
Source code in deeplabcut/core/deprecation.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
return_evaluate_network_data
return_evaluate_network_data(
config,
shuffle=0,
trainingsetindex=0,
comparisonbodyparts="all",
Snapindex=None,
rescale=False,
fulldata=False,
show_errors=True,
modelprefix="",
returnjustfns=True,
)
Returns the results for (previously evaluated) network.
deeplabcut.evaluate_network(..) Returns list of (per model): [trainingsiterations,tr ainfraction,shuffle,trainerror,testerror,pcutoff,trainerrorpcutoff,testerrorpcutoff, Snapshots[snapindex],scale,net_type]
If fulldata=True, also returns (the complete annotation and prediction array) Returns list of: (DataMachine, Data, data, trainIndices, testIndices, trainFraction, DLCscorer,comparisonbodyparts, cfg, Snapshots[snapindex])
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
int
|
Integer specifying shuffle index of the training dataset. Defaults to 0. |
0
|
|
int
|
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml). This variable can also be set to "all". |
0
|
|
list of bodyparts
|
The average error will be computed for those body parts only (Has to be a subset of the body parts). Defaults to "all". |
'all'
|
|
bool
|
Evaluate the model at the 'global_scale' variable (as set in the test/pose_config.yaml file for a particular project). I.e. every image will be resized according to that scale and prediction will be compared to the resized ground truth. The error will be reported in pixels at rescaled to the original size. I.e. For a [200,200] pixel image evaluated at global_scale=.5, the predictions are calculated on [100,100] pixel images, compared to 1/2*ground truth and this error is then multiplied by 2!. The evaluation images are also shown for the original size! Defaults to False. |
False
|
Examples:
If you do not want to plot:
deeplabcut._evaluate_network_data(
"/analysis/project/reaching-task/config.yaml",
shuffle=[1],
)
If you want to plot:
deeplabcut.evaluate_network(
"/analysis/project/reaching-task/config.yaml",
shuffle=[1],
plotting=True,
)
Source code in deeplabcut/pose_estimation_tensorflow/core/evaluate.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 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 | |
return_train_network_path
Returns the training and test pose config file names as well as the folder where the snapshot is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
int
|
Integer value specifying the shuffle index to select for training. |
1
|
|
int
|
Which TrainingsetFraction to use. By default the first (TrainingFraction is a list in config.yaml). Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
trainposeconfigfile, testposeconfigfile, snapshotfolder. |
Source code in deeplabcut/pose_estimation_tensorflow/training.py
stitch_tracklets
stitch_tracklets(
config_path: str | Path,
videos: list[str | Path],
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
n_tracks=None,
animal_names: list[str] | None = None,
min_length=10,
split_tracklets=True,
prestitch_residuals=True,
max_gap=None,
weight_func=None,
destfolder=None,
modelprefix="",
track_method="",
output_name="",
transformer_checkpoint="",
save_as_csv=False,
**kwargs
)
Stitch sparse tracklets into full tracks via a graph-based, minimum-cost flow optimization problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Path to the main project config.yaml file. |
required |
|
list[str | Path]
|
Full paths to videos for analysis, or a directory where all videos with the same extension are stored. |
required |
|
str | Sequence[str] | None
|
Controls how |
None
|
|
int
|
Shuffle index of the training dataset used for training the network. Defaults to 1. |
1
|
|
int
|
Which TrainingsetFraction to use. By default the first (TrainingFraction is a list in config.yaml). |
0
|
|
int
|
Number of tracks to reconstruct. By default, taken as the number of individuals defined in the config.yaml. Another number can be passed if the number of animals in the video is different from the number of animals the model was trained on. |
None
|
|
list
|
If you want the names given to individuals in the labeled data file, you can
specify those names as a list here. If given and |
None
|
|
int
|
Tracklets less than |
10
|
|
bool
|
By default, tracklets whose time indices are not consecutive integers
are split in shorter tracklets whose time continuity is guaranteed.
This is for example very powerful to get rid of tracking errors
(e.g., identity switches) which are often signaled by a missing
time frame at the moment they occur. Note though that for long
occlusions where tracker re-identification capability can be trusted,
setting |
True
|
|
bool
|
Residuals will by default be grouped together according to their temporal proximity prior to being added back to the tracks. This is done to improve robustness and simultaneously reduce complexity. |
True
|
|
int
|
Maximal temporal gap to allow between a pair of tracklets. This is automatically determined by the TrackletStitcher by default. |
None
|
|
callable
|
Function accepting two tracklets as arguments and returning a scalar that must be inversely proportional to the likelihood that the tracklets belong to the same track; i.e., the higher the confidence that the tracklets should be stitched together, the lower the returned value. |
None
|
|
string
|
Destination folder for analysis data (default is the path of the video). Note that for subsequent analysis this folder also needs to be passed. |
None
|
|
string
|
Tracker used to generate the pose estimation data. For multiple animals, must be either 'box', 'skeleton', or 'ellipse' and will be taken from the config.yaml file if none is given. |
''
|
|
str
|
Name of the output h5 file. By default, tracks are automatically stored into the same directory as the pickle file and with its name. |
''
|
|
str
|
Path to transformer checkpoint for re-ID stitching. Defaults to "". |
''
|
|
bool
|
Whether to write the tracks to a CSV file too (False by default). |
False
|
|
dict
|
Additional arguments. For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
TrackletStitcher |
A TrackletStitcher object. |
Source code in deeplabcut/refine_training_dataset/stitch.py
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 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 | |
train_network
train_network(
config,
shuffle=1,
trainingsetindex=0,
max_snapshots_to_keep=5,
displayiters=None,
saveiters=None,
maxiters=None,
allow_growth=True,
gputouse=None,
autotune=False,
keepdeconvweights=True,
modelprefix="",
superanimal_name="",
superanimal_transfer_learning=False,
)
Trains the network with the labels in the training dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config.yaml file as a string. |
required |
|
int
|
Integer value specifying the shuffle index to select for training. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. Note that TrainingFraction is a list in config.yaml. Defaults to 0. |
0
|
|
int or None
|
Sets how many snapshots are kept, i.e. states of the trained network. Every
saving iteration many times a snapshot is stored, however only the last
|
5
|
|
int
|
This variable is actually set in |
required |
|
int
|
This variable is actually set in |
None
|
|
int
|
This variable is actually set in |
None
|
|
bool
|
For some smaller GPUs the memory issues happen. If |
True
|
|
int
|
Natural number indicating the number of your GPU (see number in nvidia-smi). If you do not have a GPU put None. See: https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries. Defaults to None. |
None
|
|
bool
|
Property of TensorFlow, somehow faster if |
False
|
|
bool
|
Restores deconvolution layer (and backbone) weights when training from a snapshot. Set to false if bodypart count changes. Defaults to True. |
True
|
|
str
|
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder. Defaults to "". |
''
|
|
str
|
Specified if transfer learning with superanimal is desired. Defaults to "". |
''
|
|
bool
|
If true, transfer learning (new decoding layer). If false and superanimal_name is set, fine-tuning (reuse decoding layer). Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
None |
Examples:
To train the network for first shuffle of the training dataset
deeplabcut.train_network("/analysis/project/reaching-task/config.yaml")
To train the network for second shuffle of the training dataset
deeplabcut.train_network(
'/analysis/project/reaching-task/config.yaml',
shuffle=2,
keepdeconvweights=True,
)
Source code in deeplabcut/pose_estimation_tensorflow/training.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 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 | |
visualize_locrefs
visualize_locrefs(
image: ndarray, scmap: ndarray, locref_x: ndarray, locref_y: ndarray, step: int = 5, zoom_width: int = 0
) -> tuple[plt.Figure, plt.Axes]
Plots a scoremap and the corresponding location refinement field on an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
An image as a numpy array of shape (h, w, channels) |
required |
|
ndarray
|
A scoremap of shape (h, w) |
required |
|
ndarray
|
The x-coordinate of the location refinement field, of shape (h, w) |
required |
|
ndarray
|
The y-coordinate of the location refinement field, of shape (h, w) |
required |
|
int
|
The step with which to plot the location refinement field. |
5
|
|
int
|
The zoom width with which to plot the scoremaps. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
The figure and axis on which the image scoremap and locref field were plot. |
Source code in deeplabcut/core/visualization.py
visualize_paf
visualize_paf(image: ndarray, paf: ndarray, step: int = 5, colors: list | None = None) -> tuple[plt.Figure, plt.Axes]
Plots the PAF on top of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
Shape (height, width, channels). The image on which the model was run. |
required |
|
ndarray
|
Shape (height, width, 2 * len(paf_graph)). The PAF output by the model. |
required |
|
int
|
The step with which to plot the scoremaps. |
5
|
|
list | None
|
The colormap to use. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
The figure and axis on which the image PAF was plot. |
Source code in deeplabcut/core/visualization.py
visualize_scoremaps
Plots scoremaps as an image overlay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
An image as a numpy array of shape (h, w, channels) |
required |
|
ndarray
|
A scoremap of shape (h, w) |
required |
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
The figure and axis on which the image scoremap was plot. |