Skip to content

[optimizing] drop separate scores for skin, detail and saturation#51

Merged
davidfischer-ch merged 4 commits intosmartcrop:masterfrom
derVedro:one-score-to-rule-them-all
Feb 17, 2026
Merged

[optimizing] drop separate scores for skin, detail and saturation#51
davidfischer-ch merged 4 commits intosmartcrop:masterfrom
derVedro:one-score-to-rule-them-all

Conversation

@derVedro
Copy link
Copy Markdown
Contributor

Elimination of unnecessary calculations: Each score call computes separate scores for skin, detail and saturation, that then are combined into the total score. We can avoid that and factor summation out of score method into the one-time precomputation of score.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 16, 2026

Pull Request Test Coverage Report for Build 22079823292

Details

  • 10 of 10 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 80.1%

Totals Coverage Status
Change from base Build 22051552779: -0.3%
Covered Lines: 322
Relevant Lines: 402

💛 - Coveralls

@derVedro
Copy link
Copy Markdown
Contributor Author

derVedro commented Feb 16, 2026

I also dropped the score scaling in respect to inv_down_sample in score method, it doesn't matter for finding the max.

And the timings…
Task                          [b] 05df417     e65fe1c   Δ time  speedup
-----------------------------------------------------------------------
business-work-1.jpg (100x400)   0.048755s   0.043840s  -10.08%   +1.11x
business-work-1.jpg (300x300)   0.039067s   0.036624s   -6.25%   +1.07x
business-work-1.jpg (350x50)    0.032613s   0.031723s   -2.73%   +1.03x
business-work-1.jpg (350x600)   0.106822s   0.065683s  -38.51%   +1.63x
business-work-1.jpg (600x600)   0.108540s   0.065381s  -39.76%   +1.66x
nature-1.jpg (100x400)          0.173007s   0.166548s   -3.73%   +1.04x
nature-1.jpg (300x300)          0.162226s   0.166383s   +2.56%   +0.98x
nature-1.jpg (350x50)           0.155467s   0.154872s   -0.38%   +1.00x
nature-1.jpg (350x600)          0.233632s   0.187152s  -19.89%   +1.25x
nature-1.jpg (600x600)          0.232647s   0.194626s  -16.34%   +1.20x
nature-1.jpg (833x833)          0.392469s   0.237661s  -39.44%   +1.65x
orientation.jpg (100x400)       0.126709s   0.117027s   -7.64%   +1.08x
orientation.jpg (300x300)       0.113818s   0.116738s   +2.57%   +0.97x
orientation.jpg (350x50)        0.108562s   0.113518s   +4.57%   +0.96x
orientation.jpg (350x600)       0.173123s   0.137242s  -20.73%   +1.26x
orientation.jpg (600x600)       0.171852s   0.148835s  -13.39%   +1.15x
travel-1.jpg (100x400)          0.067673s   0.061352s   -9.34%   +1.10x
travel-1.jpg (300x300)          0.057529s   0.054741s   -4.85%   +1.05x
travel-1.jpg (350x50)           0.049848s   0.050037s   +0.38%   +1.00x
travel-1.jpg (350x600)          0.122879s   0.081837s  -33.40%   +1.50x
travel-1.jpg (600x600)          0.125584s   0.080780s  -35.68%   +1.55x

Look how timings wonderfully scale with crop sizes.

@davidfischer-ch davidfischer-ch merged commit 0267f93 into smartcrop:master Feb 17, 2026
3 checks passed
@davidfischer-ch
Copy link
Copy Markdown
Member

Amazing, thank you @derVedro for taking great care of making the code more "vectorized" and looks cleaner!

@derVedro
Copy link
Copy Markdown
Contributor Author

derVedro commented Feb 17, 2026

Amazing, thank you @derVedro for taking great care of making the code more "vectorized" and looks cleaner!

You welcome. I have to keep the promise I made two years ago. :)

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