Skip to content

v2.2.0

Latest

Choose a tag to compare

@mauwii mauwii released this 20 Oct 14:42
Immutable release. Only release title and notes can be modified.
d6affc5

PyPatchMatch 2.2.0 fills holes with the detail and the colors of their surroundings, continues repeating patterns across holes wider than its patches, and takes about half the time with the default patch_size of 15. It adds a wheel for Windows on ARM64. The API, the dependencies and the bundled OpenCV 5.0 are unchanged from 2.1.1; every fill with a hole differs from 2.1.1. The library is the one of 2.2.0rc1 and 2.2.0rc2.

pip install --upgrade PyPatchMatch

Fills

  • Textured regions were filled flatter than their surroundings (#148). The two finest levels average only the low frequencies of their votes and add the detail of the most similar patch (#149). A source with much less texture than the surroundings of the hole costs extra, and on the finest level a source has to be as detailed as the sources that the level above chose (#152, #155).
  • Each vote of the two finest levels carries the mean color difference between the fill and its source, so a fill keeps the colors that the coarser levels laid out instead of taking the brightness of its sources (#167).
  • With patch_size below 5, the coarsest level with a hole and the next one are also filled with patches of radius 5, and that fill is kept where it fits the surroundings better (#147).
  • Above patch_size 7, coarse levels narrower than six patches use the largest patch that fits, but at least 7 (#152). Larger patches found no sources there and left the fill flat.

scripts/evaluate_inpainting.py against 2.1.1 (workflow Fill quality of 2.2.0rc2), 10 seeds, means of the 14 cases with an original image. A detail of 1.0 means that a fill is as detailed as its surroundings.

patch_size detail error edges seam
3 0.80 → 0.93 15.30 → 12.52 5.19 → 4.43 1.12 → 1.10
7 0.82 → 0.94 12.35 → 11.83 4.96 → 4.24 1.22 → 1.22
15 0.80 → 0.95 14.07 → 11.93 5.06 → 4.24 1.30 → 1.30
  • Better: pattern-wide 37.23 → 5.46 (patch_size 3), camera 8.25 → 2.99, trees 12.46 → 4.97 and meadow 16.25 → 5.82 (15); the detail of coffee rises from 0.28 to 0.93 (15).
  • Worse: brick-large 12.28 → 16.17 (15), whose flat fill became stripes (#157); chelsea 16.06 → 17.00 (15) and 14.71 → 15.75 (7), whose detail and edges improve; pattern-wide 4.14 → 4.79 (7).

Speed

  • Links of patches without holes are no longer measured, and patches are checked for holes in constant time (#146).
  • The patch distances read the colors, gradients, texture and masks of each pixel from one packed array instead of up to eight (#162). It needs 6 bytes per pixel more than the two gradient images it replaces.

The 16 cases, 10 seeds, on the shared runner of the workflow: 620 → 286 s (−54 %) with patch_size 15, 118 → 88 s (−26 %) with 7. With 3 it is as fast as 2.1.1 on one core (7.8 s for the 16 cases and 3 seeds on macOS arm64); the +29 % on the runner come from its parallel jobs.

Wheels

Windows on ARM64 gets a wheel with a statically linked OpenCV, like the other platforms (#183). Before, pip built the source distribution there, which needs MSVC, CMake and OpenCV, and otherwise fell back to an installation without the native library.

C and C++ API

  • The native code checks the types and sizes of its inputs and reports invalid ones as RuntimeError instead of crashing (#144).
  • PatchDistanceMetric::with_patch_size returns the metric with another patch size; its default returns nullptr, so existing subclasses keep compiling.

Repository

  • uv run --group gui gui/app.py starts a Gradio GUI in which you paint holes into new images and compare the fill (#151).
  • The workflow Fill quality compares every release with the last stable one (#170). scripts/evaluate_inpainting.py restores an aged photo (camera, #154), rates the directions of edges (#160) and how much the patches of a fill repeat (#169), shows the fills cut to the holes (#164) and runs in parallel processes (#166).
  • The tests fail on warnings, uv.lock only takes packages that are at least 7 days old (#175), ruff runs from uv.lock (#176), and mypy checks the examples and scripts (#180, #181).

Known limitations

  • Large holes in brick walls get stripes instead of bricks (#157).
  • With patch_size 3, the fill of coffee is slightly more detailed than its surroundings (1.15).

Full changelog: v2.1.1...v2.2.0