deeplabcut.utils.visualization
Functions:
| Name | Description |
|---|---|
get_cmap |
Get the cmap. |
make_labeled_image |
Creating a labeled image with the original human labels, as well as the |
make_labeled_images_from_dataframe |
Write labeled frames to disk from a DataFrame. |
make_multianimal_labeled_image |
Plots groundtruth labels and predictions onto the matplotlib's axes, with the |
plot_evaluation_results |
Creates labeled images using the results of inference, and saves them to an |
save_labeled_frame |
Save the labeled frame to disk. |
get_cmap
Get the cmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
number of distinct colors |
required |
|
str
|
name of matplotlib colormap |
'hsv'
|
Returns:
| Type | Description |
|---|---|
Colormap
|
A function that maps each index in 0, 1, ..., n-1 to a distinct RGB color; the keyword argument name must be a standard mpl colormap name. |
Source code in deeplabcut/utils/visualization.py
make_labeled_image
make_labeled_image(
frame, DataCombined, imagenr, pcutoff, Scorers, bodyparts, colors, cfg, labels=None, scaling=1, ax=None
)
Creating a labeled image with the original human labels, as well as the DeepLabCut's!
Source code in deeplabcut/utils/visualization.py
make_labeled_images_from_dataframe
make_labeled_images_from_dataframe(
df, cfg, destfolder=None, scale=1.0, dpi=100, keypoint="+", draw_skeleton=True, color_by="bodypart"
)
Write labeled frames to disk from a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DataFrame
|
DataFrame containing the labeled data. |
required |
|
dict
|
Project configuration. |
required |
|
str or Path
|
Destination folder for labeled images. |
None
|
|
float
|
Output dimension scaling factor. |
1.0
|
|
int
|
Output resolution. |
100
|
|
str
|
Matplotlib marker used for keypoints. |
'+'
|
|
bool
|
Whether to draw the configured skeleton. |
True
|
|
str
|
Either "bodypart" or "individual". |
'bodypart'
|
Source code in deeplabcut/utils/visualization.py
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 | |
make_multianimal_labeled_image
make_multianimal_labeled_image(
frame: ndarray,
coords_truth: ndarray | list,
coords_pred: ndarray | list,
probs_pred: ndarray | list,
colors: Colormap,
dotsize: float | int = 12,
alphavalue: float = 0.7,
pcutoff: float = 0.6,
labels: list = None,
ax: Axes | None = None,
bounding_boxes: tuple[ndarray, ndarray] | None = None,
bboxes_cutoff: float = 0.6,
bboxes_color: Colormap | str | None = None,
color_offset: int = 0,
) -> plt.Axes
Plots groundtruth labels and predictions onto the matplotlib's axes, with the specified graphical parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
image |
required |
|
ndarray | list
|
groundtruth labels |
required |
|
ndarray | list
|
predictions |
required |
|
ndarray | list
|
prediction probabilities |
required |
|
Colormap
|
colors for poses |
required |
|
float | int
|
size of dot |
12
|
|
float
|
transparency for the keypoints |
0.7
|
|
float
|
cut-off confidence value |
0.6
|
|
list
|
labels to use for ground truth, reliable predictions, and not reliable predictions (confidence below |
None
|
|
Axes | None
|
matplotlib plot's axes object |
None
|
|
tuple[ndarray, ndarray] | None
|
bounding boxes (top-left corner, size) and their respective confidence levels, |
None
|
|
float
|
bounding boxes confidence cutoff threshold. |
0.6
|
|
Colormap | str | None
|
color(s) for the bounding boxes. If Colormap is passed -> each bounding box will be colored into its own color from the colormap. If string is passed -> all bboxes will be of string's defined color. If None -> all bboxes will be colored into a default color. |
None
|
|
int
|
Index offset applied when selecting colors from the colormap. |
0
|
Returns:
| Type | Description |
|---|---|
Axes
|
matplotlib Axes object with plotted labels and predictions. |
Source code in deeplabcut/utils/visualization.py
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 | |
plot_evaluation_results
plot_evaluation_results(
df_combined: DataFrame,
project_root: Path,
scorer: str,
model_name: str,
output_folder: Path,
in_train_set: bool,
plot_unique_bodyparts: bool = False,
mode: PlotMode = "bodypart",
colormap: str = "rainbow",
dot_size: int = 12,
alpha_value: float = 0.7,
p_cutoff: float = 0.6,
bounding_boxes: dict | None = None,
bboxes_cutoff: float = 0.6,
bounding_boxes_color: BoundingBoxColor = "auto",
) -> None
Creates labeled images using the results of inference, and saves them to an output folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DataFrame
|
dataframe with multiindex rows ("labeled-data", video_name, image_name) and columns ("scorer", "individuals", "bodyparts", "coords"). There should be two scorers: scorer (for ground truth data) and model_name (for prediction data) |
required |
|
Path
|
the project root directory |
required |
|
str
|
the name of the scorer for ground truth data in df_combined |
required |
|
str
|
the name of the model for predictions in df_combined |
required |
|
Path
|
the directory where images should be saved |
required |
|
bool
|
whether df_combined is for train set images |
required |
|
bool
|
whether we should plot unique bodyparts |
False
|
|
PlotMode
|
one of {"bodypart", "individual"}. Determines the keypoint color grouping |
'bodypart'
|
|
str
|
the colormap to use for keypoints |
'rainbow'
|
|
int
|
the dot size to use for keypoints |
12
|
|
float
|
the alpha value to use for keypoints |
0.7
|
|
float
|
the p-cutoff for "confident" keypoints |
0.6
|
|
dict | None
|
dictionary with df_combined rows as keys and bounding boxes (np array for coordinates and np array for confidence). None corresponds to no bounding boxes. |
None
|
|
float
|
bounding boxes confidence cutoff threshold. |
0.6
|
|
BoundingBoxColor
|
If plotting bounding boxes, this is the color that will be used for bounding boxes. If set to "auto" (default value): - if mode is "bodypart", the bbox color will be a default color - if mode is "individual", each individual's color will be used for its bounding box |
'auto'
|
Source code in deeplabcut/utils/visualization.py
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 | |
save_labeled_frame
Save the labeled frame to disk.
Note: folder creation is handled upstream. This function assumes that the destination folder already exists.