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

Speedup expand when meets large image #4089

Merged
merged 3 commits into from
Nov 18, 2020
Merged

Conversation

Sundrops
Copy link
Contributor

@Sundrops Sundrops commented Nov 11, 2020

ref: numpy/numpy#13001

%%timeit
a = np.full((4000, 2000, 3), [0.0, 0.0, 0.0], np.float32)
76.9 ms ± 346 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit
a = np.full((4000, 2000, 3), [0, 0, 0], np.float32)
71.4 ms ± 516 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit
a = np.full((4000, 2000, 3), 0.0, np.float32)
47.2 ms ± 1.21 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit
a = np.full((4000, 2000, 3), 0, np.float32)
47 ms ± 139 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit
a = np.empty((4000, 2000, 3), np.float32)
a.fill(0.0)
46.3 ms ± 278 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit
a = np.empty((4000, 2000, 3), np.float32)
a.fill(0)
46.3 ms ± 184 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

@codecov
Copy link

codecov bot commented Nov 11, 2020

Codecov Report

Merging #4089 (1b35880) into master (7ad44cd) will increase coverage by 0.02%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4089      +/-   ##
==========================================
+ Coverage   61.92%   61.95%   +0.02%     
==========================================
  Files         225      225              
  Lines       16641    16647       +6     
  Branches     2814     2817       +3     
==========================================
+ Hits        10305    10313       +8     
+ Misses       5838     5832       -6     
- Partials      498      502       +4     
Flag Coverage Δ
unittests 61.90% <20.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
mmdet/core/evaluation/mean_ap.py 41.63% <16.66%> (-0.55%) ⬇️
mmdet/datasets/pipelines/transforms.py 73.18% <25.00%> (-0.31%) ⬇️
mmdet/core/bbox/assigners/max_iou_assigner.py 72.36% <0.00%> (-1.32%) ⬇️
mmdet/models/dense_heads/corner_head.py 76.77% <0.00%> (+1.91%) ⬆️
mmdet/models/detectors/cornernet.py 100.00% <0.00%> (+5.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ad44cd...6a21820. Read the comment docs.

expand_img = np.full((int(h * ratio), int(w * ratio), c),
self.mean,
dtype=img.dtype)
if self.mean[0] == self.mean[1] and self.mean[1] == self.mean[2]:
Copy link
Member

Choose a reason for hiding this comment

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

  • We can leave a comment here to tell users why.
  • The processed image does not necessarily have 3 channels, we can use if np.all(self.mean == self.mean[0]) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@hellock hellock merged commit 3812377 into open-mmlab:master Nov 18, 2020
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.

None yet

2 participants