Skip to content

Commit

Permalink
Merge branch 'main' into dev/diffusers
Browse files Browse the repository at this point in the history
  • Loading branch information
keturn authored Jan 2, 2023
2 parents faa30e4 + 9091b6e commit 4c9d796
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 82 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ the desired release's zip file, which you can find by clicking on the green
This point release removes references to the binary installer from the
installation guide. The binary installer is not stable at the current
time. First time users are encouraged to use the "source" installer as
described in [Installing InvokeAI with the Source Installer](installation/INSTALL_SOURCE.md)
described in [Installing InvokeAI with the Source Installer](installation/deprecated_documentation/INSTALL_SOURCE.md)

With InvokeAI 2.2, this project now provides enthusiasts and professionals a
robust workflow solution for creating AI-generated and human facilitated
Expand Down
151 changes: 74 additions & 77 deletions docs/installation/060_INSTALL_PATCHMATCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,111 @@
title: Installing PyPatchMatch
---

# :octicons-paintbrush-16: Installing PyPatchMatch
# :material-image-size-select-large: Installing PyPatchMatch

pypatchmatch is a Python module for inpainting images. It is not
needed to run InvokeAI, but it greatly improves the quality of
inpainting and outpainting and is recommended.
pypatchmatch is a Python module for inpainting images. It is not needed to run
InvokeAI, but it greatly improves the quality of inpainting and outpainting and
is recommended.

Unfortunately, it is a C++ optimized module and installation
can be somewhat challenging. This guide leads you through the steps.
Unfortunately, it is a C++ optimized module and installation can be somewhat
challenging. This guide leads you through the steps.

## Windows

You're in luck! On Windows platforms PyPatchMatch will install
automatically on Windows systems with no extra intervention.
You're in luck! On Windows platforms PyPatchMatch will install automatically on
Windows systems with no extra intervention.

## Macintosh

PyPatchMatch is not currently supported, but the team is working on
it.
PyPatchMatch is not currently supported, but the team is working on it.

## Linux

Prior to installing PyPatchMatch, you need to take the following
steps:
Prior to installing PyPatchMatch, you need to take the following steps:

### Debian Based Distros


1. Install the `build-essential` tools:

```
sudo apt update
sudo apt install build-essential
```
```sh
sudo apt update
sudo apt install build-essential
```

2. Install `opencv`:

```
sudo apt install python3-opencv libopencv-dev
```
```sh
sudo apt install python3-opencv libopencv-dev
```

3. Fix the naming of the `opencv` package configuration file:

```
cd /usr/lib/x86_64-linux-gnu/pkgconfig/
ln -sf opencv4.pc opencv.pc
```

4. Activate the environment you use for invokeai, either with
`conda` or with a virtual environment.

5. Do a "develop" install of pypatchmatch:

```
pip install "git+https://github.com/invoke-ai/[email protected]#egg=pypatchmatch"
```

6. 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 follwing:

```
Python 3.9.5 (default, Nov 23 2021, 15:27:38)
[GCC 9.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 ...
```

```sh
cd /usr/lib/x86_64-linux-gnu/pkgconfig/
ln -sf opencv4.pc opencv.pc
```

4. Activate the environment you use for invokeai, either with `conda` or with a
virtual environment.

5. Install pypatchmatch:

```sh
pip install "git+https://github.com/invoke-ai/[email protected]#egg=pypatchmatch"
```

6. 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 follwing:

```py
Python 3.9.5 (default, Nov 23 2021, 15:27:38)
[GCC 9.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 ...
```

### Arch Based Distros

1. Install the `base-devel` package:
```
sudo pacman -Syu
sudo pacman -S --needed base-devel
```

```sh
sudo pacman -Syu
sudo pacman -S --needed base-devel
```

2. Install `opencv`:
```
sudo pacman -S opencv
```
or for CUDA support
```
sudo pacman -S opencv-cuda
```

3. Fix the naming of the `opencv` package configuration file:
```
cd /usr/lib/pkgconfig/
ln -sf opencv4.pc opencv.pc
```
```sh
sudo pacman -S opencv
```

**Next, Follow Steps 4-6 from the Debian Section above**
or for CUDA support

```sh
sudo pacman -S opencv-cuda
```

If you see no errors, then you're ready to go!
3. Fix the naming of the `opencv` package configuration file:

```sh
cd /usr/lib/pkgconfig/
ln -sf opencv4.pc opencv.pc
```

[**Next, Follow Steps 4-6 from the Debian Section above**](#linux)

If you see no errors, then you're ready to go!
2 changes: 1 addition & 1 deletion docs/installation/INSTALL_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ command-line completion.
If you have already downloaded the weights file(s) for another Stable
Diffusion distribution, you may skip this step (by selecting "skip" when
prompted) and configure InvokeAI to use the previously-downloaded files. The
process for this is described in [here](INSTALLING_MODELS.md).
process for this is described in [here](050_INSTALLING_MODELS.md).
```bash
python scripts/configure_invokeai.py
Expand Down
2 changes: 1 addition & 1 deletion installer/install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ do
ROOTDIR=${input:=$HOME}/invokeai

# This is surprisingly hard to do in plain Bash; easier in ZSH. Just running python in subshell is easiest.
ROOTDIR=$(python -c "from pathlib import Path; print(Path('${ROOTDIR}').expanduser().resolve())")
ROOTDIR=$($PYTHON -c "from pathlib import Path; print(Path('${ROOTDIR}').expanduser().resolve())")

read -e -p "InvokeAI will be installed into $ROOTDIR. OK? [y]: " input
RESPONSE=${input:='y'}
Expand Down
2 changes: 2 additions & 0 deletions ldm/invoke/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from omegaconf import OmegaConf
from pathlib import Path
import pyparsing
import ldm.invoke

# global used in multiple functions (fix)
infile = None
Expand Down Expand Up @@ -56,6 +57,7 @@ def main():
print(f'** This script will now exit.')
sys.exit(-1)

print(f'>> {ldm.invoke.__app_name__} {ldm.invoke.__version__}')
print(f'>> InvokeAI runtime directory is "{Globals.root}"')

# loading here to avoid long delays on startup
Expand Down
2 changes: 1 addition & 1 deletion ldm/invoke/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__app_id__= 'invoke-ai/InvokeAI'
__app_name__= 'InvokeAI'
__version__='2.2.4'
__version__='2.2.5'
2 changes: 1 addition & 1 deletion scripts/invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
import os
if sys.platform == 'Darsin':
if sys.platform == 'darwin':
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"

import ldm.invoke.CLI
Expand Down

0 comments on commit 4c9d796

Please sign in to comment.