Skip to content

Conversation

@kimmyjuarez
Copy link

@kimmyjuarez kimmyjuarez commented Nov 15, 2025

My team wanted to expand DeepLabCut's limited augmentation options by incorporating the albumentations library as our project needed augmentations that mimic glares. We developed a hybrid approach that preserves DLC's existing augmentation method while enabling custom augmentations.

For this to work, we added a new 'transform' section inside 'train' in the pytorch_config file. The new format is a list which has each entry in this list to specify an augmentation name followed by its parameters. Our solution maintains DLC's default augmentation values and calculations in a function called transforms_legacy (supporting dictionary). We then created a new function, transform_new, which handles both legacy DLC augmentations and our custom augmentations.

Example config format:

image

The transform_new function works sequentially. First, it checks whether the 'augmentation' section exists, if not, then it loops to the next augmentation. Next, it checks if an augmentation is one of DLC's original methods. If it is, the function calls transforms_legacy and we pass it the augmentation name and its parameters in dictionary format, to retrieve the appropriate augmentation settings. If not, it proceeds to check whether the augmentation exists in the albumentations library. When an albumentations augmentation is found, the function extracts its parameters and adds it to a list of transforms. Otherwise, it issues a warning that the given augmentation does not exist. When finished looping through augmentations, it returns the transform list to build_transforms, which integrates these augmentations into the training pipeline.

To add a new augmentation:

  1. List the augmentation inside the 'transform' section, must be written with '-' and 'augmentation'. Augmentation must exist from the albumentations library and it is case sensitive so it should match spelling.
    - augmentation: <name_of_augmentation>
  2. List its parameter following it with the name of the parameter and the value of it
    - augmentation: <name_of_augmentation>
    p: 0.6

Below is our augmentation that we applied using our new method:

image

This approach allows us to leverage albumentations' extensive library while maintaining DLC's existing method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants