Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(deps): require pypatchmatch 2.2 so PatchMatch loads offline (#10298)
Alexander Eichhorn9b4880020170
diff --git a/docs/src/content/docs/configuration/Optimization/patchmatch.mdx b/docs/src/content/docs/configuration/Optimization/patchmatch.mdxindex 4be5e3978c..5893452903 100644--- a/docs/src/content/docs/configuration/Optimization/patchmatch.mdx+++ b/docs/src/content/docs/configuration/Optimization/patchmatch.mdx@@ -2,8 +2,6 @@title: Patchmatch----import { Tabs, TabItem, Steps } from '@astrojs/starlight/components'-PatchMatch is an algorithm used to infill images. It can greatly improve outpainting results. PyPatchMatch is a python wrapper around a C++ implementation of the algorithm.It uses the image data around the target area as a reference to generate new image data of a similar character and quality.@@ -22,105 +20,18 @@ PatchMatch is CPU-bound, and the amount of time it takes increases proportionall## Installation-Unfortunately, installation can be somewhat challenging, as it requires some things that `pip` cannot install for you.--<Steps>- 1. Ensure you have the necessary dependencies installed for your system (see below).-- <Tabs syncKey="operatingSystem">- <TabItem label="Windows" icon="seti:windows">- You're in luck! On Windows x64 PyPatchMatch will install automatically with no extra intervention. There is no prebuilt library for Windows on ARM64, where the `patchmatch` infill method is unavailable. Every startup there logs `ERROR patchmatch failed to load or compile`; that message is expected on ARM64 and can be ignored.- </TabItem>- <TabItem label="MacOS" icon="apple">- You need to have opencv installed so that pypatchmatch can be built:-- ```bash- brew install opencv- ```-- The next time you start `invoke`, after successfully installing opencv, pypatchmatch will be built.- </TabItem>- <TabItem label="Linux" icon="linux">- Prior to installing PyPatchMatch, you need to take the following steps:-- <Tabs syncKey="linuxDistro">- <TabItem label="Debian">- <Steps>- 1. Install the `build-essential` tools:-- ```sh- sudo apt update # Update package lists- sudo apt install build-essential- ```-- 2. Install `opencv`:-- ```sh- sudo apt install python3-opencv libopencv-dev- ```-- 3. Activate the environment you use for invokeai, either with `conda` or with a virtual environment.- </Steps>- </TabItem>- <TabItem label="Arch">- <Steps>- 1. Install the `base-devel` package:-- ```sh- sudo pacman -Syu- sudo pacman -S --needed base-devel- ```-- 2. Install `opencv`, `blas`, and required dependencies:-- ```sh- sudo pacman -S opencv blas fmt glew vtk hdf5- ```-- or for CUDA support-- ```sh- sudo pacman -S opencv-cuda blas fmt glew vtk hdf5- ```-- 3. Fix the naming of the `opencv` package configuration file:-- ```sh- cd /usr/lib/pkgconfig/- ln -sf opencv4.pc opencv.pc- ```- </Steps>- </TabItem>- </Tabs>- </TabItem>- </Tabs>+PyPatchMatch is installed with Invoke. Its wheels include the prebuilt library for Windows (x64 and ARM64), macOS 11 or later (Intel and Apple silicon) and Linux (x86_64 and aarch64, glibc 2.28 or later), so there is nothing to compile and nothing is downloaded when Invoke starts. PatchMatch works offline.- 2. Install pypatchmatch:+To check that it loaded, run this in the Python environment Invoke uses:- ```sh- pip install pypatchmatch- ```+```sh+python -c "from patchmatch import patch_match; print(patch_match.patchmatch_available)"+```- 3. Confirm that pypatchmatch is installed. At the command-line prompt enter `python`, and then at the `>>>` line type `from patchmatch import patch_match`: It should look like the following:+It prints `True` when the `patchmatch` infill method is available.- ```py- Python 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] on linux- Type "help", "copyright", "credits" or "license" for more information.- >>> from patchmatch import patch_match- Compiling and loading c extensions from "/home/lstein/Projects/InvokeAI/.invokeai-env/src/pypatchmatch/patchmatch".- rm -rf build/obj libpatchmatch.so- mkdir: created directory 'build/obj'- mkdir: created directory 'build/obj/csrc/'- [dep] csrc/masked_image.cpp ...- [dep] csrc/nnf.cpp ...- [dep] csrc/inpaint.cpp ...- [dep] csrc/pyinterface.cpp ...- [CC] csrc/pyinterface.cpp ...- [CC] csrc/inpaint.cpp ...- [CC] csrc/nnf.cpp ...- [CC] csrc/masked_image.cpp ...- [link] libpatchmatch.so ...- ```+On any other platform, PyPatchMatch is built from source when it is installed. That needs a C++ compiler, CMake and OpenCV. If the build fails, the package installs without its library and the `patchmatch` infill method is unavailable. Install the missing tools, then reinstall it without the cache:- If you're not seeing any errors, you're ready to go!-</Steps>+```sh+pip install --force-reinstall --no-deps --no-cache-dir pypatchmatch+```diff --git a/docs/src/content/docs/start-here/system-requirements.mdx b/docs/src/content/docs/start-here/system-requirements.mdxindex bdb0ce01c9..f374d107ac 100644--- a/docs/src/content/docs/start-here/system-requirements.mdx+++ b/docs/src/content/docs/start-here/system-requirements.mdx@@ -140,7 +140,6 @@ Differences from Windows x64, all because the underlying package has no Windows- The image map projects with PCA instead of UMAP, so it is less structured.- `xformers` is not available; torch's own attention kernels are used.- `.woff2` fonts cannot be read: the font list skips them, and an upload is rejected with a message that the format is not supported on this platform. `.ttf`, `.otf` and `.woff` work.-- PyPatchMatch has no prebuilt library for Windows ARM64, so the `patchmatch` infill method is unavailable.GPU generation on RTX Spark has not yet been validated by the Invoke team on hardware; installation and the CPU code paths are exercised in CI on Windows ARM64 runners.diff --git a/pyproject.toml b/pyproject.tomlindex 20fc565867..f6dda9ab79 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -126,7 +126,7 @@ dependencies = ["picklescan","pillow>=13.0.0","prompt-toolkit",- "pypatchmatch",+ "pypatchmatch>=2.2.0", # wheels ship the native library; 1.x downloads or compiles it at import"PyJWT>=2.15.0","python-multipart","requests",diff --git a/uv.lock b/uv.lockindex 2cd869c0d3..b2fdf821da 100644--- a/uv.lock+++ b/uv.lock@@ -2197,7 +2197,7 @@ requires-dist = [{ name = "pydantic-settings" },{ name = "pyjwt", specifier = ">=2.15.0" },{ name = "pymysql", marker = "extra == 'mysql'", specifier = ">=1.2.3,<2" },- { name = "pypatchmatch" },+ { name = "pypatchmatch", specifier = ">=2.2.0" },{ name = "pytest", marker = "extra == 'test'", specifier = ">6.0.0" },{ name = "pytest-cov", marker = "extra == 'test'" },{ name = "pytest-datadir", marker = "extra == 'test'" },@@ -3636,17 +3636,21 @@ wheels = [[[package]]name = "pypatchmatch"-version = "1.0.2"+version = "2.2.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine != 'ARM64' or sys_platform != 'win32' or (extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-cuda') or (extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-rocm') or (extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-xpu') or (extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-rocm') or (extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-xpu') or (extra == 'extra-8-invokeai-rocm' and extra == 'extra-8-invokeai-xpu')" },{ name = "numpy", version = "2.3.5", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'ARM64' and sys_platform == 'win32') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-cuda') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-rocm') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-xpu') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-rocm') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-xpu') or (platform_machine != 'ARM64' and extra == 'extra-8-invokeai-rocm' and extra == 'extra-8-invokeai-xpu') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-cuda') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-rocm') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-cpu' and extra == 'extra-8-invokeai-xpu') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-rocm') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-cuda' and extra == 'extra-8-invokeai-xpu') or (sys_platform != 'win32' and extra == 'extra-8-invokeai-rocm' and extra == 'extra-8-invokeai-xpu')" },{ name = "pillow" },- { name = "tqdm" },]-sdist = { url = "https://files.pythonhosted.org/packages/89/7f/4403ceb49442988ec7aeb0d5fa372ea4a150967bb50fd64ecc7280d72d15/PyPatchMatch-1.0.2.tar.gz", hash = "sha256:7e01e332cdffa082a0c0fd752eb7644167e8f4e5297b464f501418eae7079b41", size = 16633, upload-time = "2025-05-06T21:23:52.3Z" }+sdist = { url = "https://files.pythonhosted.org/packages/04/82/7e41ba4c760d331d54eb7f940667f5a02b9d53decacd05bf410a7307f613/pypatchmatch-2.2.0.tar.gz", hash = "sha256:0baa0870e175173db1f9a6517be7a85c490ef344668bfece7a083d7569425b7b", size = 1631924, upload-time = "2026-10-20T16:04:32.51Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/14/85/403c3491d3820f85772c44cb411b16a249065f136fd85115fe3830acb620/PyPatchMatch-1.0.2-py3-none-any.whl", hash = "sha256:d749b411c5376086bbf2ca7a3638553c745c8e4318d7531e8e065106335cba9c", size = 20287, upload-time = "2025-05-06T21:23:50.965Z" },+ { url = "https://files.pythonhosted.org/packages/ee/49/75a7b8f276d4ef6c5d1aa329bb18d6b94abc81239d53bb5104ca68ea99c7/pypatchmatch-2.2.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7239ac7682e9e84b35e5c13e8a531c7d9e46a788d92517c5c9b8989a16af47df", size = 401673, upload-time = "2026-10-20T16:04:21.505Z" },+ { url = "https://files.pythonhosted.org/packages/4e/b5/0c8e8d6aa85abde3b6fedce0a30cfaeaf05b433a408b563b3683f2689c50/pypatchmatch-2.2.0-py3-none-macosx_11_0_x86_64.whl", hash = "sha256:abcb4f4cdaba8dcc31da99b40a7d5d5d35b8c13534e242c8f638a5c7b15a9fa1", size = 568959, upload-time = "2026-10-20T16:04:23.359Z" },+ { url = "https://files.pythonhosted.org/packages/71/7c/9aaa52b0438e30a3fb0282eff6622ad7b24679144ae13b507e6a9cd50a69/pypatchmatch-2.2.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b7bdc098c021e6d944586c3f4ddbb881d3923582331f9491441754a0c49d7e5f", size = 488812, upload-time = "2026-10-20T16:04:25.455Z" },+ { url = "https://files.pythonhosted.org/packages/b5/24/a0646eb76ce9d968cccf08e63651e8aca78044b5f552f22135280f114f66/pypatchmatch-2.2.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4baafe1c9d5d276b9e10e89f586bfed3c975d79aca883efb0265951579fd184d", size = 651238, upload-time = "2026-10-20T16:04:27.123Z" },+ { url = "https://files.pythonhosted.org/packages/2a/02/c814735cde25d08bf2f17c99314ea3aaa0fb9de939dad7b8078755c686a0/pypatchmatch-2.2.0-py3-none-win_amd64.whl", hash = "sha256:6d4f63217c1eb9570f05ee049f0d1d2aef5bff7bc7e4faf8fb0fb908360eb79b", size = 628660, upload-time = "2026-10-20T16:04:28.909Z" },+ { url = "https://files.pythonhosted.org/packages/35/8d/969a21977f1b474b8168a839ec4ccd6842dd932dfe65882f57d648c82803/pypatchmatch-2.2.0-py3-none-win_arm64.whl", hash = "sha256:fd792444251df13c5990016de3db53760490b7c08c9398b6deada9fccb7d8050", size = 518747, upload-time = "2026-10-20T16:04:30.508Z" },][[package]]