data_config
sleap_nn.config.data_config
¶
Serializable configuration classes for specifying all data configuration parameters.
These configuration classes are intended to specify all the parameters required to initialize the data config.
Classes:
Name | Description |
---|---|
AugmentationConfig |
Configuration of Augmentation. |
DataConfig |
Data configuration. |
GeometricConfig |
Configuration of Geometric (Optional). |
IntensityConfig |
Configuration of Intensity (Optional). |
PreprocessingConfig |
Configuration of Preprocessing. |
Functions:
Name | Description |
---|---|
data_mapper |
Maps the legacy data configuration to the new data configuration. |
validate_proportion |
General Proportion Validation. |
AugmentationConfig
¶
Configuration of Augmentation.
Attributes:
Name | Type | Description |
---|---|---|
intensity |
Optional[IntensityConfig]
|
Configuration options for intensity-based augmentations like brightness, contrast, etc. If None, no intensity augmentations will be applied. |
geometric |
Optional[GeometricConfig]
|
Configuration options for geometric augmentations like rotation, scaling, translation etc. If None, no geometric augmentations will be applied. |
Source code in sleap_nn/config/data_config.py
DataConfig
¶
Data configuration.
Attributes:
Name | Type | Description |
---|---|---|
train_labels_path |
Optional[List[str]]
|
(List[str]) List of paths to training data ( |
val_labels_path |
Optional[List[str]]
|
(List[str]) List of paths to validation data ( |
validation_fraction |
float
|
(float) Float between 0 and 1 specifying the fraction of the training set to sample for generating the validation set. The remaining labeled frames will be left in the training set. If the |
test_file_path |
Optional[str]
|
(str) Path to test dataset ( |
provider |
str
|
(str) Provider class to read the input sleap files. Only "LabelsReader" is currently supported for the training pipeline. Default: |
user_instances_only |
bool
|
(bool) |
data_pipeline_fw |
str
|
(str) Framework to create the data loaders. One of [ |
cache_img_path |
Optional[str]
|
(str) Path to save |
use_existing_imgs |
bool
|
(bool) Use existing train and val images/ chunks in the |
delete_cache_imgs_after_training |
bool
|
(bool) If |
preprocessing |
PreprocessingConfig
|
Configuration options related to data preprocessing. |
use_augmentations_train |
bool
|
(bool) True if the data augmentation should be applied to the training data, else False. Default: |
augmentation_config |
Optional[AugmentationConfig]
|
Configurations related to augmentation. (only if |
skeletons |
Optional[list]
|
skeleton configuration for the |
Source code in sleap_nn/config/data_config.py
GeometricConfig
¶
Configuration of Geometric (Optional).
Attributes:
Name | Type | Description |
---|---|---|
rotation_min |
float
|
(float) Minimum rotation angle in degrees. A random angle in (rotation_min, rotation_max) will be sampled and applied to both images and keypoints. Set to 0 to disable rotation augmentation. Default: |
rotation_max |
float
|
(float) Maximum rotation angle in degrees. A random angle in (rotation_min, rotation_max) will be sampled and applied to both images and keypoints. Set to 0 to disable rotation augmentation. Default: |
scale_min |
float
|
(float) Minimum scaling factor. If scale_min and scale_max are provided, the scale is randomly sampled from the range scale_min <= scale <= scale_max for isotropic scaling. Default: |
scale_max |
float
|
(float) Maximum scaling factor. If scale_min and scale_max are provided, the scale is randomly sampled from the range scale_min <= scale <= scale_max for isotropic scaling. Default: |
translate_width |
float
|
(float) Maximum absolute fraction for horizontal translation. For example, if translate_width=a, then horizontal shift is randomly sampled in the range -img_width * a < dx < img_width * a. Will not translate by default. Default: |
translate_height |
float
|
(float) Maximum absolute fraction for vertical translation. For example, if translate_height=a, then vertical shift is randomly sampled in the range -img_height * a < dy < img_height * a. Will not translate by default. Default: |
affine_p |
float
|
(float) Probability of applying random affine transformations. Default: |
erase_scale_min |
float
|
(float) Minimum value of range of proportion of erased area against input image. Default: |
erase_scale_max |
float
|
(float) Maximum value of range of proportion of erased area against input image. Default: |
erase_ratio_min |
float
|
(float) Minimum value of range of aspect ratio of erased area. Default: |
erase_ratio_max |
float
|
(float) Maximum value of range of aspect ratio of erased area. Default: |
erase_p |
float
|
(float) Probability of applying random erase. Default: |
mixup_lambda_min |
float
|
(float) Minimum mixup strength value. Default: |
mixup_lambda_max |
float
|
(float) Maximum mixup strength value. Default: |
mixup_p |
float
|
(float) Probability of applying random mixup v2. Default: |
Source code in sleap_nn/config/data_config.py
IntensityConfig
¶
Configuration of Intensity (Optional).
Attributes:
Name | Type | Description |
---|---|---|
uniform_noise_min |
float
|
(float) Minimum value for uniform noise (uniform_noise_min >=0). Default: |
uniform_noise_max |
float
|
(float) Maximum value for uniform noise (uniform_noise_max <>=1). Default: |
uniform_noise_p |
float
|
(float) Probability of applying random uniform noise. Default: |
gaussian_noise_mean |
float
|
(float) The mean of the gaussian noise distribution. Default: |
gaussian_noise_std |
float
|
(float) The standard deviation of the gaussian noise distribution. Default: |
gaussian_noise_p |
float
|
(float) Probability of applying random gaussian noise. Default: |
contrast_min |
float
|
(float) Minimum contrast factor to apply. Default: |
contrast_max |
float
|
(float) Maximum contrast factor to apply. Default: |
contrast_p |
float
|
(float) Probability of applying random contrast. Default: |
brightness_min |
float
|
(float) Minimum brightness factor to apply. Default: |
brightness_max |
float
|
(float) Maximum brightness factor to apply. Default: |
brightness_p |
float
|
(float) Probability of applying random brightness. Default: |
Source code in sleap_nn/config/data_config.py
PreprocessingConfig
¶
Configuration of Preprocessing.
Attributes:
Name | Type | Description |
---|---|---|
ensure_rgb |
bool
|
(bool) True if the input image should have 3 channels (RGB image). If input has only one channel when this is set to |
ensure_grayscale |
bool
|
(bool) True if the input image should only have a single channel. If input has three channels (RGB) and this is set to True, then we convert the image to grayscale (single-channel) image. If the source image has only one channel and this is set to False, then we retain the single channel input. Default: |
max_height |
Optional[int]
|
(int) Maximum height the image should be padded to. If not provided, the original image size will be retained. Default: |
max_width |
Optional[int]
|
(int) Maximum width the image should be padded to. If not provided, the original image size will be retained. Default: |
scale |
float
|
(float) Factor to resize the image dimensions by, specified as a float. Default: |
crop_size |
Optional[int]
|
(int) Crop size of each instance for centered-instance model. If |
min_crop_size |
Optional[int]
|
(int) Minimum crop size to be used if |
Methods:
Name | Description |
---|---|
validate_scale |
Scale Validation. |
Source code in sleap_nn/config/data_config.py
validate_scale()
¶
Scale Validation.
Ensures PreprocessingConfig's scale is a float>=0 or list of floats>=0
Source code in sleap_nn/config/data_config.py
data_mapper(legacy_config)
¶
Maps the legacy data configuration to the new data configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
legacy_config
|
dict
|
A dictionary containing the legacy data configuration. |
required |
Returns:
Type | Description |
---|---|
DataConfig
|
An instance of |
Source code in sleap_nn/config/data_config.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
|
validate_proportion(instance, attribute, value)
¶
General Proportion Validation.
Ensures all proportions are a 0<=float<=1.0