analyzer
sleap_nn.config_generator.analyzer
¶
Dataset analysis utilities for config generation.
This module provides tools for extracting statistics from SLP files to inform automatic configuration of training parameters.
Classes:
| Name | Description |
|---|---|
DatasetStats |
Statistics extracted from an SLP file for auto-configuration. |
ViewType |
Camera view orientation for augmentation defaults. |
Functions:
| Name | Description |
|---|---|
analyze_slp |
Analyze an SLP file and extract statistics for auto-configuration. |
DatasetStats
dataclass
¶
Statistics extracted from an SLP file for auto-configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
slp_path |
str
|
Path to the source SLP file. |
num_labeled_frames |
int
|
Number of frames with user labels. |
num_videos |
int
|
Number of video sources. |
max_height |
int
|
Maximum image height across videos. |
max_width |
int
|
Maximum image width across videos. |
num_channels |
int
|
Number of image channels (1=grayscale, 3=RGB). |
max_instances_per_frame |
int
|
Maximum instances in any single frame. |
avg_instances_per_frame |
float
|
Average instances per frame. |
max_bbox_size |
float
|
Maximum bounding box dimension of any instance
( |
avg_bbox_size |
float
|
Average bounding box size, defined as
|
avg_bbox_diagonal |
float
|
Average bounding box diagonal
( |
num_nodes |
int
|
Number of skeleton nodes. |
num_edges |
int
|
Number of skeleton edges. |
node_names |
List[str]
|
List of node names. |
edges |
List[Tuple[str, str]]
|
List of edge tuples (source_name, dest_name). |
has_tracks |
bool
|
Whether track annotations exist. |
num_tracks |
int
|
Number of unique tracks. |
estimated_total_bytes |
int
|
Estimated memory for all images. |
overlap_frequency |
float
|
Fraction of frames with overlapping instances (IoU > 0.2). |
node_visibility |
Optional[Dict[str, float]]
|
Dict mapping node names to visibility percentage (0-100). |
Methods:
| Name | Description |
|---|---|
__repr__ |
Return repr string. |
__str__ |
Return human-readable summary. |
Source code in sleap_nn/config_generator/analyzer.py
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 | |
animal_to_frame_ratio
property
¶
Ratio of average animal size to frame dimension (linear, not area).
This gives a more intuitive percentage - e.g., if an animal bbox is 100px and the frame is 1000px, the ratio is 10% (not 1% which area would give).
frame_area
property
¶
Total pixel area of a frame.
has_identity
property
¶
Whether identity tracking is available.
is_grayscale
property
¶
Whether images are grayscale.
is_multi_instance
property
¶
Whether dataset has multiple animals per frame.
is_rgb
property
¶
Whether images are RGB.
is_single_instance
property
¶
Whether dataset has only single animals per frame.
max_dimension
property
¶
Maximum image dimension.
__repr__()
¶
Return repr string.
Source code in sleap_nn/config_generator/analyzer.py
__str__()
¶
Return human-readable summary.
Source code in sleap_nn/config_generator/analyzer.py
ViewType
¶
analyze_slp(path, *, user_instances_only=True)
¶
Analyze an SLP file and extract statistics for auto-configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the .slp file. |
required |
user_instances_only
|
bool
|
If True, only analyze user-labeled instances. |
True
|
Returns:
| Type | Description |
|---|---|
DatasetStats
|
DatasetStats object with extracted statistics. |
Example
stats = analyze_slp("labels.slp") print(f"Max instances: {stats.max_instances_per_frame}") print(f"Image size: {stats.max_width}x{stats.max_height}")
Source code in sleap_nn/config_generator/analyzer.py
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 | |