-
Notifications
You must be signed in to change notification settings - Fork 622
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
Add AutoAugment and ImageNet policy #4702
Conversation
f5ff9a2
to
24fc3af
Compare
24fc3af
to
16ec1a3
Compare
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
…kipping Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
16ec1a3
to
a42d47b
Compare
!build |
CI MESSAGE: [7543750]: BUILD STARTED |
CI MESSAGE: [7543750]: BUILD FAILED |
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
!build |
CI MESSAGE: [7563307]: BUILD STARTED |
param = [shape[0] * offset_fraction, 0] | ||
elif extent == 'width': | ||
param = [0, shape[1] * offset_fraction] | ||
params[param_name] = param |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
else: | ||
expected_counts[(mag, )] = prob / 2 | ||
expected_counts[(-mag, )] = prob / 2 | ||
only_right_p = (1 - left_p) * right_p / len(sub_policies) |
Check warning
Code scanning / CodeQL
Variable defined multiple times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
CI MESSAGE: [7563307]: BUILD FAILED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well documented, well tested (+1 for using nose2 utils), very good descriptions of errors. Nice
CI MESSAGE: [7563307]: BUILD PASSED |
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
!build |
CI MESSAGE: [7566484]: BUILD STARTED |
CI MESSAGE: [7566484]: BUILD FAILED |
CI MESSAGE: [7566484]: BUILD PASSED |
try: | ||
import numpy as np | ||
except ImportError: | ||
raise RuntimeError( | ||
"Could not import numpy. DALI's automatic augmentation examples depend on numpy. " | ||
"Please install numpy to use the examples.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears in multiple places throughout our codebase. Wouldn't it be better to just add a dependency to the DALI wheel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of followed a pattern here used elsewhere in DALI, but that makes a lot of sense. If we decide to change it, we can remove all such import wrapper at once.
* Add Policy util and utils for better error reporting * Add AutoAugment and ImageNet policy --------- Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
* Add Policy util and utils for better error reporting * Add AutoAugment and ImageNet policy --------- Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Category:
New feature (non-breaking change which adds functionality)
Description:
Adds AutoAugment: augmentation scheme that applies augmentations randomly per sample based on a policy. The policy consits of sub-polcies, each sub-policy is a sequence of augmentations to apply. Sub-policies are chosen uniformy at random for each sample. Then, the augmentations from the sequence are applied one-by-one. Each augmentation is described with the probability of it being applied or skipped and a magnitude - inuitevely a strenght of the operation.
The ImageNet policy is a policy found by the authors of the paper that introduces AA shown to improve the accuracy (https://arxiv.org/abs/1805.09501).
Additional information:
This is a part of Automatic Augmentation module #4648
The implementation groups the same augmentations from different sub-policies in hope for bigger partial-batches. For example, the ImageNet policy has 25 sub-policies, but in fact only 8 augmentations at each stage of the sub-policy.
Take the policy:
Here the samples processing is split in three paths. However images that fall into 1st and 3rd sub-policy can be run together in first stage. Similarily, in the second stage, the samples that fall into 2nd and 3rd policy can be run together.
DALI will execute such policy by first: splitting batch into one that is omitted this time based on the probabilities from the first stage, i.e.
(0.5, 0.2 and 0.9)
and the one to process in the given stage, then the latter batch is split between rotate and shear_x. The rotate is called with per-sample angle that corresponds to the magnitudes from sub_policy (7 and 6). The batch is then merged and similar split is done for the second stage.Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-3193