identity
sleap_nn.data.identity
¶
Utilities for generating data for track identity models.
Functions:
Name | Description |
---|---|
generate_class_maps |
Generate class maps from track indices. |
make_class_maps |
Generate identity class maps using instance-wise confidence maps. |
make_class_vectors |
Make a binary class vectors from class indices. |
generate_class_maps(instances, img_hw, num_instances, class_inds, num_tracks, class_map_threshold=0.2, sigma=1.5, output_stride=2, is_centroids=False)
¶
Generate class maps from track indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instances
|
Tensor
|
Input keypoints. (n_samples=1, n_instances, n_nodes, 2) or for centroids - (n_samples=1, n_instances, 2) |
required |
img_hw
|
Tuple[int]
|
Image size as tuple (height, width). |
required |
num_instances
|
int
|
Original number of instances in the frame. |
required |
class_inds
|
Tensor
|
Class indices as |
required |
num_tracks
|
int
|
Total number of tracks in the dataset. |
required |
class_map_threshold
|
float
|
Minimum confidence map value below which map values will be replaced with zeros. |
0.2
|
sigma
|
float
|
The standard deviation of the Gaussian distribution that is used to generate confidence maps. Default: 1.5. |
1.5
|
output_stride
|
int
|
The relative stride to use when generating confidence maps. A larger stride will generate smaller confidence maps. Default: 2. |
2
|
is_centroids
|
bool
|
True if confidence maps should be generates for centroids else False. Default: False. |
False
|
Source code in sleap_nn/data/identity.py
make_class_maps(confmaps, class_inds, n_classes, threshold=0.2)
¶
Generate identity class maps using instance-wise confidence maps.
This is useful for making class maps defined on local neighborhoods around the peaks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
confmaps
|
Tensor
|
Confidence maps for the same points as the offset maps as a
|
required |
class_inds
|
Tensor
|
Class indices as |
required |
n_classes
|
int
|
Integer number of maximum classes. |
required |
threshold
|
float
|
Minimum confidence map value below which map values will be replaced with zeros. |
0.2
|
Returns:
Type | Description |
---|---|
Tensor
|
The class maps with shape |
Notes
Pixels that have confidence map values from more than one animal will have the class vectors weighed by the relative contribution of each instance.
Source code in sleap_nn/data/identity.py
make_class_vectors(class_inds, n_classes)
¶
Make a binary class vectors from class indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_inds
|
Tensor
|
Class indices as |
required |
n_classes
|
int
|
Integer number of maximum classes. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
A tensor with binary class vectors of shape |
Notes: A class index can be used to represent a track index.