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

Add data-aware anchor generator #1251

Merged
merged 18 commits into from
Jan 30, 2024

Conversation

wonjuleee
Copy link
Contributor

@wonjuleee wonjuleee commented Jan 25, 2024

Summary

How to test

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have added the description of my changes into CHANGELOG.​
  • I have updated the documentation accordingly

License

  • I submit my code changes under the same MIT 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) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT

@wonjuleee wonjuleee requested review from a team as code owners January 25, 2024 07:18
@wonjuleee wonjuleee requested review from sooahleex and removed request for a team January 25, 2024 07:18
Copy link
Contributor

@sooahleex sooahleex left a comment

Choose a reason for hiding this comment

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

Looks good to me. I left some minor comments.

src/datumaro/components/algorithms/rise.py Show resolved Hide resolved
src/datumaro/plugins/anchor_generator.py Outdated Show resolved Hide resolved
src/datumaro/plugins/anchor_generator.py Outdated Show resolved Hide resolved
src/datumaro/plugins/anchor_generator.py Outdated Show resolved Hide resolved
Comment on lines +220 to +230
scale_samples, ratio_samples = [], []
for target in targets[gt_max_overlaps > 0.1]:
h = target[3] - target[1]
w = target[2] - target[0]
r = h / w
affine_h = base_size * torch.sqrt(r)
affine_w = base_size / torch.sqrt(r)
s = max(h / affine_h, w / affine_w)

scale_samples.append(s)
ratio_samples.append(r)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
scale_samples, ratio_samples = [], []
for target in targets[gt_max_overlaps > 0.1]:
h = target[3] - target[1]
w = target[2] - target[0]
r = h / w
affine_h = base_size * torch.sqrt(r)
affine_w = base_size / torch.sqrt(r)
s = max(h / affine_h, w / affine_w)
scale_samples.append(s)
ratio_samples.append(r)
scale_samples = [max(h / (base_size * torch.sqrt(r)), w / (base_size / torch.sqrt(r))) for h, w, r in zip(targets[:, 3] - targets[:, 1], targets[:, 2] - targets[:, 0], targets[:, 3] / targets[:, 2])]
ratio_samples = [h / w for h, w in zip(targets[:, 3] - targets[:, 1], targets[:, 2] - targets[:, 0])]

I think there are some repeated computation.

src/datumaro/plugins/anchor_generator.py Show resolved Hide resolved
Comment on lines 352 to 353
scales = torch.Tensor(scales).to(self.device).detach().requires_grad_(True)
ratios = torch.Tensor(ratios).to(self.device).detach().requires_grad_(True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
scales = torch.Tensor(scales).to(self.device).detach().requires_grad_(True)
ratios = torch.Tensor(ratios).to(self.device).detach().requires_grad_(True)
scales = scales.detach().requires_grad_(True)
ratios = ratios.detach().requires_grad_(True)

tests/unit/test_anchor_generator.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sure there's a way to pre-check for errors that isn't try except, but I can't think of it. If there's a better structure, I'd like to use it instead of try except.

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (895bf4c) 80.53% compared to head (4ca75f8) 80.57%.
Report is 1 commits behind head on develop.

Files Patch % Lines
src/datumaro/plugins/anchor_generator.py 90.47% 10 Missing and 6 partials ⚠️
src/datumaro/components/dataset.py 50.00% 1 Missing and 1 partial ⚠️
src/datumaro/components/dataset_item_storage.py 88.88% 1 Missing ⚠️
src/datumaro/components/errors.py 75.00% 1 Missing ⚠️
...vino_plugin/samples/clip_visual_ViT-B_32_interp.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1251      +/-   ##
===========================================
+ Coverage    80.53%   80.57%   +0.04%     
===========================================
  Files          270      271       +1     
  Lines        30248    30441     +193     
  Branches      5907     5930      +23     
===========================================
+ Hits         24360    24528     +168     
- Misses        4507     4525      +18     
- Partials      1381     1388       +7     
Flag Coverage Δ
ubuntu-20.04_Python-3.8 80.55% <89.23%> (+0.04%) ⬆️
windows-2022_Python-3.8 80.54% <89.23%> (+0.04%) ⬆️

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 wonjuleee merged commit a819dbb into openvinotoolkit:develop Jan 30, 2024
5 checks passed
@yunchu yunchu added this to the 2.0.0 milestone Mar 28, 2024
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.

3 participants