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

Improve polygon utils #3707

Merged
merged 4 commits into from
Jul 3, 2024
Merged

Conversation

wonjuleee
Copy link
Contributor

@wonjuleee wonjuleee commented Jul 3, 2024

Summary

Creating dm.Polygon is not compute-efficient way because of running annotation validation.
So, through this PR, I would like to reuse the current dm.Polygon annotations instead.

With RTMDet-Tiny model on large instance segmentation dataset (5 times repeat), I can reduce 2.5% iteration time on average.

  epoch e2e iter time f1
develop 30.2 326.5254 0.32453617 0.44547
fix_polygon 29 310.143 0.31644868 0.451077
<style> </style>
  develop fix_polygon reduction (%)
otx.core.data.transform_libs.torchvision.CachedMosaic: 0.28111 0.27406 2.507683577
otx.core.data.transform_libs.torchvision.RandomResize: 0.02781 0.02545 8.486345826
otx.core.data.transform_libs.torchvision.RandomCrop: 0.00561 0.00499 11.1882294
otx.core.data.transform_libs.torchvision.YOLOXHSVRandomAug: 0.00529 0.00513 3.088670277
otx.core.data.transform_libs.torchvision.RandomFlip: 0.00058 0.00044 24.97037152
otx.core.data.transform_libs.torchvision.Pad: 0.00109 0.00107 2.479535156
otx.core.data.transform_libs.torchvision.CachedMixUp: 0.01892 0.01944 -2.76476453
otx.core.data.transform_libs.torchvision.FilterAnnotations: 0.00186 0.00186 0.312082033
torchvision.transforms.v2._misc.ToDtype: 0.00122 0.00139 -13.44773689
torchvision.transforms.v2._misc.Normalize: 0.00256 0.00265 -3.36598766
SUM 0.346057 0.336452 2.775750417

How to test

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have ran e2e tests and there is no issues.
  • I have added the description of my changes into CHANGELOG in my target branch (e.g., CHANGELOG in develop).​
  • I have updated the documentation in my target branch accordingly (e.g., documentation in develop).
  • I have linked related issues.

License

  • I submit my code changes under the same Apache License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

harimkang
harimkang previously approved these changes Jul 3, 2024
Copy link
Contributor

@harimkang harimkang left a comment

Choose a reason for hiding this comment

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

LGTM, i left minor comment

src/otx/core/data/transform_libs/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@eunwoosh eunwoosh left a comment

Choose a reason for hiding this comment

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

Thanks for your work. Could you update integration test result? and I left some comments. Please take a look.

src/otx/core/data/transform_libs/utils.py Outdated Show resolved Hide resolved
src/otx/core/data/transform_libs/utils.py Show resolved Hide resolved
Copy link
Contributor

@sungchul2 sungchul2 left a comment

Choose a reason for hiding this comment

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

LGTM. But could you compare data time only? It doesn't look like the performance improvement is evident.
(Of course, I think there is good improvement because reallocating dm.Polygon which was a bottleneck disappeared.)

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.47%. Comparing base (3a44e46) to head (df46747).

Files Patch % Lines
src/otx/core/data/transform_libs/utils.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3707      +/-   ##
===========================================
- Coverage    80.54%   80.47%   -0.08%     
===========================================
  Files          255      255              
  Lines        25835    25829       -6     
===========================================
- Hits         20810    20787      -23     
- Misses        5025     5042      +17     
Flag Coverage Δ
py310 80.47% <88.23%> (-0.06%) ⬇️
py311 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wonjuleee
Copy link
Contributor Author

Thanks for your work. Could you update integration test result? and I left some comments. Please take a look.

image

I have just run instance_segmentation related tests here.

Copy link
Collaborator

@kprokofi kprokofi left a comment

Choose a reason for hiding this comment

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

@wonjuleee , could you briefly describe what exactly here helps to reduce time and raise metrics? Because as I see it is just some refactoring done. Did you check it with different seeds and data?
UPD: I got it, thanks :)

@wonjuleee wonjuleee merged commit 1fde0c8 into openvinotoolkit:develop Jul 3, 2024
7 of 8 checks passed
@wonjuleee
Copy link
Contributor Author

@wonjuleee , could you briefly describe what exactly here helps to reduce time and raise metrics? Because as I see it is just some refactoring done. Did you check it with different seeds and data? UPD: I got it, thanks :)

Hi Kirill, thank you for the question. Previously, it used to create a new dm.Polygon annotation for each annotation, but it takes some converter logics described in https://github.com/openvinotoolkit/datumaro/blob/6a9227694fc4bac0883269974118dfd318bc573d/src/datumaro/components/annotation.py#L687. So, I turned to reuse the existing dm.Polygon annotation and update only the points for the augmentations (random crop/resize/flip).

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.

5 participants