Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic denoising and inpaint bbox sizing (#678)
* Added dynamic denoising and inpaint bbox sizing * Dynamic denoising: Once bboxes are available from the predictor, it is possible to calculate the size of the crop region relative to the original image size. Using this value, we can modulate the "Inpaint denoising strength" based on the region size, with smaller regions getting higher denoising, and smaller areas less. * Several algorithms were tested, ultimately, a configurable power value worked best. Values between 2-4 are recommended (1 is equivalent to linear). * Try match inpaint/bbox size: Again, using bbox sizes, we can determine more optimal dimensions and aspect ratio for the inpaint width and height. * Only active for SDXL, as the model natively handles various dimensions and aspect ratios. * Don't use inpaint/bbox matching if user has specified their own width and height * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove math.isclose. * Remove math import * Remove unneeded formatting * Better descriptions for new features in settings. * Tidy up bbox matching, filter out more resolutions earlier * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add strict and free inpaint bbox size matching * Strict: SDXL only, same as original implementation * Free (prefer smaller or larger): Theoretically works with any model. Adjusts the inpaint region to match the aspect ratio of the bbox exactly, favouring either the smaller dimension or larger dimension of the original inpaint region. We also round up (if needed) to the closest 8 pixels to make the dimensions nicer to diffusion/upscalers. "Prefer smaller" is the better option, as it will usually very closely match the original inpaint sizes. * Also added a threshold to the difference between the original inpaint size and adjusted size, and ignore the adjusted size if it's very similar. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use or for checking thresholds on new inpaint dimensions * Rework free mode to a single setting Should now always pick optimal dimensions --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information