utils
sleap_nn.tracking.utils
¶
Helper functions for Tracker module.
Functions:
| Name | Description |
|---|---|
compute_cosine_sim |
Return cosine simalirity between a and b vectors. |
compute_euclidean_distance |
Return the negative euclidean distance between a and b points. |
compute_iou |
Return the intersection over union for given a and b bounding boxes [xmin, ymin, xmax, ymax]. |
cull_frame_instances |
Removes instances (for single frame) over instance per frame threshold. |
cull_instances |
Removes instances from frames over instance per frame threshold. |
get_bbox |
Return the bounding box coordinates for the |
get_centroid |
Return the centroid of the |
get_keypoints |
Return keypoints as np.array from the |
greedy_matching |
Match new instances to existing tracks using greedy bipartite matching. |
hungarian_matching |
Match new instances to existing tracks using Hungarian matching. |
nms_fast |
From: https://www.pyimagesearch.com/2015/02/16/faster-non-maximum-suppression-python/. |
nms_instances |
NMS for instances. |
compute_cosine_sim(a, b)
¶
Return cosine simalirity between a and b vectors.
compute_euclidean_distance(a, b)
¶
compute_iou(a, b)
¶
Return the intersection over union for given a and b bounding boxes [xmin, ymin, xmax, ymax].
Source code in sleap_nn/tracking/utils.py
cull_frame_instances(instances_list, instance_count, iou_threshold=None)
¶
Removes instances (for single frame) over instance per frame threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances_list
|
List[PredictedInstance]
|
The list of instances for a single frame. |
required |
instance_count
|
int
|
The maximum number of instances we want per frame. |
required |
iou_threshold
|
Optional[float]
|
Intersection over Union (IOU) threshold to use when removing overlapping instances over target count; if None, then only use score to determine which instances to remove. |
None
|
Returns:
| Type | Description |
|---|---|
List[PredictedInstance]
|
Updated list of frames, also modifies frames in place. |
Source code in sleap_nn/tracking/utils.py
cull_instances(frames, instance_count, iou_threshold=None)
¶
Removes instances from frames over instance per frame threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
List[LabeledFrame]
|
The list of |
required |
instance_count
|
int
|
The maximum number of instances we want per frame. |
required |
iou_threshold
|
Optional[float]
|
Intersection over Union (IOU) threshold to use when removing overlapping instances over target count; if None, then only use score to determine which instances to remove. |
None
|
Returns:
| Type | Description |
|---|---|
|
None; modifies frames in place. |
Source code in sleap_nn/tracking/utils.py
get_bbox(pred_instance)
¶
Return the bounding box coordinates for the PredictedInstance object.
Source code in sleap_nn/tracking/utils.py
get_centroid(pred_instance)
¶
Return the centroid of the PredictedInstance object.
Source code in sleap_nn/tracking/utils.py
get_keypoints(pred_instance)
¶
Return keypoints as np.array from the PredictedInstance object.
greedy_matching(cost_matrix)
¶
Match new instances to existing tracks using greedy bipartite matching.
Source code in sleap_nn/tracking/utils.py
hungarian_matching(cost_matrix)
¶
Match new instances to existing tracks using Hungarian matching.
nms_fast(boxes, scores, iou_threshold, target_count=None)
¶
From: https://www.pyimagesearch.com/2015/02/16/faster-non-maximum-suppression-python/.
Source code in sleap_nn/tracking/utils.py
nms_instances(instances, iou_threshold, target_count=None)
¶
NMS for instances.