Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved zoom augmentations through albumentations. #735

Open
4 tasks
bw4sz opened this issue Aug 7, 2024 · 4 comments · May be fixed by #749
Open
4 tasks

Improved zoom augmentations through albumentations. #735

bw4sz opened this issue Aug 7, 2024 · 4 comments · May be fixed by #749
Labels
API This tag is used for small improvements to the readability and usability of the python API. Docs Documentation Ideas for Machine Learning! These are machine learning ideas and papers that could be useful for DeepForest models. High level.

Comments

@bw4sz
Copy link
Collaborator

bw4sz commented Aug 7, 2024

One of the core challenges of machine learning for airborne biodiversity observation is trying to generalize across sensors and acquisition conditions. Given low data sizes, data augmentations are crucial for good generalization across resolutions, focal views and object size.

A quick search of albumentations suggests hits a few existing classes that should be useful:

https://huggingface.co/spaces/qubvel-hf/albumentations-demo?transform=Downscale

https://albumentations.ai/docs/api_reference/augmentations/crops/transforms/#albumentations.augmentations.crops.transforms.RandomSizedBBoxSafeCrop

https://huggingface.co/spaces/qubvel-hf/albumentations-demo?transform=RandomSizedBBoxSafeCrop

https://albumentations.ai/docs/api_reference/augmentations/geometric/transforms/#albumentations.augmentations.geometric.transforms.PadIfNeeded

Checklist

  • Implement augmentations in their own module, not within preprocessing. Currently lives inline

    [A.HorizontalFlip(p=0.5), ToTensorV2()],

  • Allow the user to choose the augmentations either through the config file. Careful to allow defaults to remain unchanged and sets reasonable defaults if not specified in existing config files.

  • Make a doc page showing example augmentations

Optional

  • Compare training with augmentations and without when predicting across resolutions.
@bw4sz bw4sz added Docs Documentation API This tag is used for small improvements to the readability and usability of the python API. Ideas for Machine Learning! These are machine learning ideas and papers that could be useful for DeepForest models. High level. labels Aug 7, 2024
@Om-Doiphode Om-Doiphode linked a pull request Aug 14, 2024 that will close this issue
@Om-Doiphode
Copy link
Contributor

Hi @bw4sz, should I remove the following function from the deepforest/dataset.py?

def get_transform(augment):
    """Albumentations transformation of bounding boxs."""
    if augment:
        transform = A.Compose(
            [A.HorizontalFlip(p=0.5), ToTensorV2()],
            bbox_params=A.BboxParams(format='pascal_voc', label_fields=["category_ids"]))

    else:
        transform = A.Compose([ToTensorV2()],
                              bbox_params=A.BboxParams(format='pascal_voc',
                                                       label_fields=["category_ids"]))

    return transform

And replace it with get_augmentations?

@bw4sz
Copy link
Collaborator Author

bw4sz commented Aug 14, 2024

Sure, but i'd keep calling it transforms since that it is what it is, and the user wouldn't need to always do augmentation (validation), basically the A.compose statement with optional augmentations. maybe something like

def get_transform(augmentations=None):
    """Albumentations transformation of bounding boxes.
   Args:
        augmentations (str): Name of albumentations augmentation, e.g. "Downscale". For information see albumentations transforms (link). 
   """
  ...

Then loop through the named augmentations and generate them? Having users specify a string that finds a function is always a bit annoying, but its not too many to create if statements.

@Om-Doiphode
Copy link
Contributor

Om-Doiphode commented Aug 15, 2024

Hi @bw4sz, the get_transform function will take the augmentations from the deepforest_config.yml file right? Not through the function parameter list right?

@bw4sz
Copy link
Collaborator Author

bw4sz commented Aug 19, 2024

The general philosophy is to have a config argument, and then allow the user to overwrite it specifying an arg directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API This tag is used for small improvements to the readability and usability of the python API. Docs Documentation Ideas for Machine Learning! These are machine learning ideas and papers that could be useful for DeepForest models. High level.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants