deeplabcut.pose_estimation_pytorch.data.postprocessor
Post-process predictions made by models.
Classes:
| Name | Description |
|---|---|
AddContextToOutput |
Adds items from the context to the output, such as the bounding boxes contained |
AssignIndividualIdentities |
Assigns predicted identities to individuals. |
BboxToCoco |
Transforms bounding boxes from xyxy to COCO format (xywh) |
ComposePostprocessor |
Class to preprocess an image and turn it into a batch of inputs before running |
ConcatenateOutputs |
Checks that there is a single prediction for the image and returns it. |
PadOutputs |
Pads the outputs to have the maximum number of individuals. |
Postprocessor |
A post-processor can be called on the output of a model |
PredictKeypointIdentities |
Assigns predicted identities to keypoints. |
PrepareBackboneFeatures |
Adds backbone features for each individual and keypoint to the outputs. |
RemoveLowConfidenceBoxes |
Removes low confidence bounding boxes from detector output before they reach the |
RescaleAndOffset |
Rescales and offsets predictions back to their position in the original image. |
TrimOutputs |
Ensures all outputs have at most |
Functions:
| Name | Description |
|---|---|
build_bottom_up_postprocessor |
Creates a postprocessor for bottom-up pose estimation (or object detection) |
build_detector_postprocessor |
Creates a postprocessor for top-down pose estimation. |
build_top_down_postprocessor |
Creates a postprocessor for top-down pose estimation. |
AddContextToOutput
Bases: Postprocessor
Adds items from the context to the output, such as the bounding boxes contained during top-down inference.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
AssignIndividualIdentities
Bases: Postprocessor
Assigns predicted identities to individuals.
Attributes:
| Name | Type | Description |
|---|---|---|
identity_key |
Key with which to add predicted identities in the predictions dict |
|
pose_key |
Key for the bodyparts in the predictions dict |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
BboxToCoco
Bases: Postprocessor
Transforms bounding boxes from xyxy to COCO format (xywh)
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
ComposePostprocessor
Bases: Postprocessor
Class to preprocess an image and turn it into a batch of inputs before running inference.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
ConcatenateOutputs
Bases: Postprocessor
Checks that there is a single prediction for the image and returns it.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
PadOutputs
Bases: Postprocessor
Pads the outputs to have the maximum number of individuals.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
Postprocessor
Bases: ABC
A post-processor can be called on the output of a model TODO: Documentation
Methods:
| Name | Description |
|---|---|
__call__ |
Post-processes the outputs of a model into a single prediction. |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
__call__
abstractmethod
Post-processes the outputs of a model into a single prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
the predictions made by the model on a single image |
required |
|
Context
|
the context returned by the pre-processor with the image |
required |
Returns:
| Type | Description |
|---|---|
Any
|
a single post-processed prediction |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
PredictKeypointIdentities
Bases: Postprocessor
Assigns predicted identities to keypoints.
The identity maps have shape (h, w, num_ids).
Attributes:
| Name | Type | Description |
|---|---|---|
identity_key |
Key with which to add predicted identities in the predictions dict |
|
identity_map_key |
Key for the identity maps in the predictions dict |
|
pose_key |
Key for the bodyparts in the predictions dict |
|
keep_id_maps |
Whether to keep identity heatmaps in the output dictionary. Setting this value to True can be useful for debugging, but can lead to memory issues when running video analysis on long videos. |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
PrepareBackboneFeatures
Bases: Postprocessor
Adds backbone features for each individual and keypoint to the outputs.
Attributes:
| Name | Type | Description |
|---|---|---|
top_down |
Whether the model is a top-down model. |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
RemoveLowConfidenceBoxes
Bases: Postprocessor
Removes low confidence bounding boxes from detector output before they reach the pose estimator.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
RescaleAndOffset
Bases: Postprocessor
Rescales and offsets predictions back to their position in the original image.
This can be done in 3 ways
BBOX_XYWH: the data has shape (num_individuals, 4), in xywh format, and there is a single scale and offset for all bounding boxes (e.g., because the image was resized before being passed to a detector) KEYPOINT: the data has shape (num_individuals, num_keypoints, 2/3), and there is a single scale and offset for all individuals (e.g., because the image was resized before being passed to a BU pose model) KEYPOINT_TD: the data has shape (num_individuals, num_keypoints, 2/3), and there are num_individuals scales and offsets (one for each individual, as TD crops one image per individual)
If no scale and no offsets are given, then this postprocessor simply forwards the predictions and context.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
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 | |
TrimOutputs
Bases: Postprocessor
Ensures all outputs have at most max_individuals detections.
Assumes that the outputs are sorted by decreasing score, such that the first
max_individuals predictions are the ones to keep.
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
build_bottom_up_postprocessor
build_bottom_up_postprocessor(
max_individuals: int,
num_bodyparts: int,
num_unique_bodyparts: int,
with_identity: bool = False,
with_backbone_features: bool = False,
) -> ComposePostprocessor
Creates a postprocessor for bottom-up pose estimation (or object detection)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
the maximum number of individuals in a single image |
required |
|
int
|
the number of bodyparts output by the model |
required |
|
int
|
the number of unique_bodyparts output by the model |
required |
|
bool
|
whether the model has an identity head |
False
|
|
bool
|
When True, the backbone features are extracted from
the output and saved in a |
False
|
Returns:
| Type | Description |
|---|---|
ComposePostprocessor
|
A default bottom-up Postprocessor |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
build_detector_postprocessor
build_detector_postprocessor(max_individuals: int, min_bbox_score: float | None = None) -> Postprocessor
Creates a postprocessor for top-down pose estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
the maximum number of detections to keep in a single image |
required |
|
float | None
|
the threshold for filtering bounding boxes. Only bboxes with a value higher than this threshold are kept, the rest is removed. |
None
|
Returns:
| Type | Description |
|---|---|
Postprocessor
|
A default top-down Postprocessor |
Source code in deeplabcut/pose_estimation_pytorch/data/postprocessor.py
build_top_down_postprocessor
build_top_down_postprocessor(
max_individuals: int, num_bodyparts: int, num_unique_bodyparts: int, with_backbone_features: bool = False
) -> Postprocessor
Creates a postprocessor for top-down pose estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
the maximum number of individuals in a single image |
required |
|
int
|
the number of bodyparts output by the model |
required |
|
int
|
the number of unique_bodyparts output by the model |
required |
|
bool
|
When True, the backbone features are extracted from
the output and saved in a |
False
|
Returns:
| Type | Description |
|---|---|
Postprocessor
|
A default top-down Postprocessor |