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

Augmentation SpeedUp fix #154

Merged
merged 29 commits into from
Aug 26, 2024
Merged

Augmentation SpeedUp fix #154

merged 29 commits into from
Aug 26, 2024

Conversation

sokovninn
Copy link
Member

@sokovninn sokovninn commented Aug 22, 2024

This PR includes:

  • Resize() after all other augmentations to ensure the correct input shape
  • Optimizing amount of Resize() calls

Some benchmarks on the COCO train dataset (1 epoch, 4 workers, bs 16):

  • Mosaic + set of other augmentations (do change shape):

    • resize before augs + resize if needed after augs: 22:26
    • resize after augs: 20:41
    • resize before normalization only + resize if needed after augs: 20:57 - chosen solution
  • Only mosaic augmentation (doesn't change shape):

    • resize before augs + resize if needed after augs: 14:53
    • resize after augs: 15:42
    • resize before normalization only: 15:24
    • resize before normalization only + resize if needed after augs: 14:49 - chosen solution

Update:

  • Add separate pixel transformations
  • Resize if needed before pixel transformations

COCO train dataset (normalize, defocus, sharpen, rotate, perspective, affine, randomscale (all with p=1)):

  • Previous approach: 19:33
  • batch-> spatial -> resize (if shapes are changed) -> pixel augs: 19:16

Original PR with a bug (reverted)

@sokovninn sokovninn self-assigned this Aug 22, 2024
@sokovninn sokovninn added the bug Something isn't working label Aug 22, 2024
Copy link

github-actions bot commented Aug 22, 2024

Test Results

  1 files    1 suites   4m 28s ⏱️
102 tests 102 ✅ 0 💤 0 ❌
114 runs  114 ✅ 0 💤 0 ❌

Results for commit 178a395.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 22, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
3697 3091 84% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
luxonis_ml/data/augmentations/utils.py 97% 🟢
TOTAL 97% 🟢

updated for commit: 178a395 by action🐍

@kozlov721 kozlov721 added the fix Fixing a bug label Aug 22, 2024
@kozlov721 kozlov721 added data Changes affecting luxonis_ml.data subpackage and removed bug Something isn't working labels Aug 22, 2024
),
)

return batch_transform, spatial_transform, resize_transform
Copy link
Collaborator

@kozlov721 kozlov721 Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type annotation and docs of _parse_cfg are outdated

Copy link
Collaborator

@kozlov721 kozlov721 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments otherwise LGTM

luxonis_ml/data/augmentations/utils.py Outdated Show resolved Hide resolved
luxonis_ml/data/augmentations/utils.py Outdated Show resolved Hide resolved
luxonis_ml/data/augmentations/utils.py Show resolved Hide resolved
@sokovninn sokovninn merged commit 465c5f8 into dev Aug 26, 2024
11 checks passed
@kozlov721 kozlov721 deleted the fix/augmentation-speedup-order branch August 29, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Changes affecting luxonis_ml.data subpackage fix Fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants