|
2 | 2 | title: Installing PyPatchMatch |
3 | 3 | --- |
4 | 4 |
|
5 | | -# :octicons-paintbrush-16: Installing PyPatchMatch |
| 5 | +# :material-image-size-select-large: Installing PyPatchMatch |
6 | 6 |
|
7 | | -pypatchmatch is a Python module for inpainting images. It is not |
8 | | -needed to run InvokeAI, but it greatly improves the quality of |
9 | | -inpainting and outpainting and is recommended. |
| 7 | +pypatchmatch is a Python module for inpainting images. It is not needed to run |
| 8 | +InvokeAI, but it greatly improves the quality of inpainting and outpainting and |
| 9 | +is recommended. |
10 | 10 |
|
11 | | -Unfortunately, it is a C++ optimized module and installation |
12 | | -can be somewhat challenging. This guide leads you through the steps. |
| 11 | +Unfortunately, it is a C++ optimized module and installation can be somewhat |
| 12 | +challenging. This guide leads you through the steps. |
13 | 13 |
|
14 | 14 | ## Windows |
15 | 15 |
|
16 | | -You're in luck! On Windows platforms PyPatchMatch will install |
17 | | -automatically on Windows systems with no extra intervention. |
| 16 | +You're in luck! On Windows platforms PyPatchMatch will install automatically on |
| 17 | +Windows systems with no extra intervention. |
18 | 18 |
|
19 | 19 | ## Macintosh |
20 | 20 |
|
21 | | -PyPatchMatch is not currently supported, but the team is working on |
22 | | -it. |
| 21 | +PyPatchMatch is not currently supported, but the team is working on it. |
23 | 22 |
|
24 | 23 | ## Linux |
25 | 24 |
|
26 | | -Prior to installing PyPatchMatch, you need to take the following |
27 | | -steps: |
| 25 | +Prior to installing PyPatchMatch, you need to take the following steps: |
28 | 26 |
|
29 | 27 | ### Debian Based Distros |
30 | 28 |
|
31 | | - |
32 | 29 | 1. Install the `build-essential` tools: |
33 | 30 |
|
34 | | - ``` |
35 | | - sudo apt update |
36 | | - sudo apt install build-essential |
37 | | - ``` |
| 31 | + ```sh |
| 32 | + sudo apt update |
| 33 | + sudo apt install build-essential |
| 34 | + ``` |
38 | 35 |
|
39 | 36 | 2. Install `opencv`: |
40 | 37 |
|
41 | | - ``` |
42 | | - sudo apt install python3-opencv libopencv-dev |
43 | | - ``` |
| 38 | + ```sh |
| 39 | + sudo apt install python3-opencv libopencv-dev |
| 40 | + ``` |
44 | 41 |
|
45 | 42 | 3. Fix the naming of the `opencv` package configuration file: |
46 | 43 |
|
47 | | - ``` |
48 | | - cd /usr/lib/x86_64-linux-gnu/pkgconfig/ |
49 | | - ln -sf opencv4.pc opencv.pc |
50 | | - ``` |
51 | | - |
52 | | -4. Activate the environment you use for invokeai, either with |
53 | | -`conda` or with a virtual environment. |
54 | | - |
55 | | -5. Do a "develop" install of pypatchmatch: |
56 | | - |
57 | | - ``` |
58 | | - pip install "git+https://github.com/invoke-ai/PyPatchMatch@0.1.3#egg=pypatchmatch" |
59 | | - ``` |
60 | | - |
61 | | -6. Confirm that pypatchmatch is installed. |
62 | | - At the command-line prompt enter `python`, and |
63 | | - then at the `>>>` line type `from patchmatch import patch_match`: |
64 | | - It should look like the follwing: |
65 | | - |
66 | | - ``` |
67 | | - Python 3.9.5 (default, Nov 23 2021, 15:27:38) |
68 | | - [GCC 9.3.0] on linux |
69 | | - Type "help", "copyright", "credits" or "license" for more information. |
70 | | - >>> from patchmatch import patch_match |
71 | | - Compiling and loading c extensions from "/home/lstein/Projects/InvokeAI/.invokeai-env/src/pypatchmatch/patchmatch". |
72 | | - rm -rf build/obj libpatchmatch.so |
73 | | - mkdir: created directory 'build/obj' |
74 | | - mkdir: created directory 'build/obj/csrc/' |
75 | | - [dep] csrc/masked_image.cpp ... |
76 | | - [dep] csrc/nnf.cpp ... |
77 | | - [dep] csrc/inpaint.cpp ... |
78 | | - [dep] csrc/pyinterface.cpp ... |
79 | | - [CC] csrc/pyinterface.cpp ... |
80 | | - [CC] csrc/inpaint.cpp ... |
81 | | - [CC] csrc/nnf.cpp ... |
82 | | - [CC] csrc/masked_image.cpp ... |
83 | | - [link] libpatchmatch.so ... |
84 | | - ``` |
85 | | - |
| 44 | + ```sh |
| 45 | + cd /usr/lib/x86_64-linux-gnu/pkgconfig/ |
| 46 | + ln -sf opencv4.pc opencv.pc |
| 47 | + ``` |
| 48 | + |
| 49 | +4. Activate the environment you use for invokeai, either with `conda` or with a |
| 50 | + virtual environment. |
| 51 | + |
| 52 | +5. Install pypatchmatch: |
| 53 | + |
| 54 | + ```sh |
| 55 | + pip install "git+https://github.com/invoke-ai/PyPatchMatch@0.1.3#egg=pypatchmatch" |
| 56 | + ``` |
| 57 | + |
| 58 | +6. Confirm that pypatchmatch is installed. At the command-line prompt enter |
| 59 | + `python`, and then at the `>>>` line type |
| 60 | + `from patchmatch import patch_match`: It should look like the follwing: |
| 61 | + |
| 62 | + ```py |
| 63 | + Python 3.9.5 (default, Nov 23 2021, 15:27:38) |
| 64 | + [GCC 9.3.0] on linux |
| 65 | + Type "help", "copyright", "credits" or "license" for more information. |
| 66 | + >>> from patchmatch import patch_match |
| 67 | + Compiling and loading c extensions from "/home/lstein/Projects/InvokeAI/.invokeai-env/src/pypatchmatch/patchmatch". |
| 68 | + rm -rf build/obj libpatchmatch.so |
| 69 | + mkdir: created directory 'build/obj' |
| 70 | + mkdir: created directory 'build/obj/csrc/' |
| 71 | + [dep] csrc/masked_image.cpp ... |
| 72 | + [dep] csrc/nnf.cpp ... |
| 73 | + [dep] csrc/inpaint.cpp ... |
| 74 | + [dep] csrc/pyinterface.cpp ... |
| 75 | + [CC] csrc/pyinterface.cpp ... |
| 76 | + [CC] csrc/inpaint.cpp ... |
| 77 | + [CC] csrc/nnf.cpp ... |
| 78 | + [CC] csrc/masked_image.cpp ... |
| 79 | + [link] libpatchmatch.so ... |
| 80 | + ``` |
86 | 81 |
|
87 | 82 | ### Arch Based Distros |
88 | 83 |
|
89 | 84 | 1. Install the `base-devel` package: |
90 | | - ``` |
91 | | - sudo pacman -Syu |
92 | | - sudo pacman -S --needed base-devel |
93 | | - ``` |
| 85 | + |
| 86 | + ```sh |
| 87 | + sudo pacman -Syu |
| 88 | + sudo pacman -S --needed base-devel |
| 89 | + ``` |
94 | 90 |
|
95 | 91 | 2. Install `opencv`: |
96 | | - ``` |
97 | | - sudo pacman -S opencv |
98 | | - ``` |
99 | | - or for CUDA support |
100 | | - ``` |
101 | | - sudo pacman -S opencv-cuda |
102 | | - ``` |
103 | 92 |
|
104 | | -3. Fix the naming of the `opencv` package configuration file: |
105 | | - ``` |
106 | | - cd /usr/lib/pkgconfig/ |
107 | | - ln -sf opencv4.pc opencv.pc |
108 | | - ``` |
| 93 | + ```sh |
| 94 | + sudo pacman -S opencv |
| 95 | + ``` |
109 | 96 |
|
110 | | -**Next, Follow Steps 4-6 from the Debian Section above** |
| 97 | + or for CUDA support |
111 | 98 |
|
| 99 | + ```sh |
| 100 | + sudo pacman -S opencv-cuda |
| 101 | + ``` |
112 | 102 |
|
113 | | -If you see no errors, then you're ready to go! |
| 103 | +3. Fix the naming of the `opencv` package configuration file: |
114 | 104 |
|
| 105 | + ```sh |
| 106 | + cd /usr/lib/pkgconfig/ |
| 107 | + ln -sf opencv4.pc opencv.pc |
| 108 | + ``` |
115 | 109 |
|
| 110 | +[**Next, Follow Steps 4-6 from the Debian Section above**](#linux) |
| 111 | + |
| 112 | +If you see no errors, then you're ready to go! |
0 commit comments