implement boost support#56
Open
seanluong wants to merge 2 commits into
Open
Conversation
Adds a Boost dataclass (x, y, width, height, weight) that callers can pass to crop() and analyse() to bias crop selection toward regions of interest (e.g. detected faces). Based on the boost feature in smartcrop.js, with the difference that boost data is kept in a separate float32 array rather than the alpha channel. Boost coordinates are prescaled alongside the image when prescaling fires. boost_weight (default 100.0) controls the global influence of boosts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
derVedro
reviewed
May 13, 2026
| skin_color: tuple[float, float, float] = DEFAULT_SKIN_COLOR | ||
| skin_threshold: float = 0.8 | ||
| skin_weight: float = 1.8 | ||
| boost_weight: float = 100.0 |
Contributor
There was a problem hiding this comment.
Are you sure about using such a high weight value? All other project-related weights are about two orders of magnitude smaller.
Author
There was a problem hiding this comment.
That's a good point. I've been thinking of a good way to set the value for this but maybe it's not really needed as users can provide a weight for each boosted area themselves.
boost_weight was a global multiplier (default 100.0) applied on top of per-boost weights, making boosted regions ~43x stronger than the maximum non-boosted pixel score. Removing it lets Boost.weight operate in the same units as skin_weight, saturation_weight, etc., giving callers intuitive control without a hidden scaling factor.
Contributor
|
@davidfischer-ch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I came across this Python version of https://github.com/jwagner/smartcrop.js working on a different project. I already implemented boosting for the vendored version of this library in that project so I thought that I should contribute that implementation back here.
This PR adds a Boost dataclass (x, y, width, height, weight) that callers can pass to crop() and analyse() to bias crop selection toward regions of interest (e.g. detected faces).
Boost coordinates are prescaled alongside the image when prescaling fires.
boost_weight(default 100.0) controls the global influence of boosts.