Skip to content

Commit

Permalink
Merge pull request #66 from intel/2_99_R1
Browse files Browse the repository at this point in the history
Merge the release branch for 2.99-R1 into main
  • Loading branch information
RyanMetcalfeInt8 authored Dec 8, 2023
2 parents feec859 + c5b3175 commit 532127c
Show file tree
Hide file tree
Showing 30 changed files with 4,803 additions and 1,502 deletions.
88 changes: 66 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This branch is currently under development. <br>Dedicated for GIMP 3, Python 3 a
[2] Style-Transfer <br>
[3] Inpainting <br>
[4] Semantic-Segmentation <br>
[5] Stable-Diffusion (Suppports - SD 1.4, SD 1.5 (landscape & portrait), SD 1.5 Inpainting, SD 1.5 Controlnet-OpenPose, SD 1.5 Controlnet-CannyEdge) <br>
[5] Stable-Diffusion (Suppports - SD 1.4, SD 1.5 (landscape, portrait, and Latent Consistency Model), SD 1.5 Inpainting, SD 1.5 Controlnet-OpenPose, SD 1.5 Controlnet-CannyEdge, SD 1.5 Controlnet-Scribble) <br>

# Objectives
[1] Provides a set of OpenVino based plugins that add AI features to GIMP. <br>
Expand All @@ -35,8 +35,7 @@ Skip steps 1 and 2 if you already have Python3 and Git on Windows
#### 2. Install Git
- Download and install [GIT](https://git-scm.com/)

#### 3. Install the GIMP Plugin

#### 3. Install the GIMP Plugin
1. Install [GIMP 2.99.10 (revision 2)](https://download.gimp.org/gimp/v2.99/windows/gimp-2.99.10-setup-2.exe) or Install [GIMP 2.99.14](https://download.gimp.org/gimp/v2.99/windows/gimp-2.99.14-setup.exe) <br>
2. Clone and run install script: <br>

Expand All @@ -51,53 +50,92 @@ Skip steps 1 and 2 if you already have Python3 and Git on Windows
Example: ```Plug-ins in GIMP : <path\to>\gimpenv3\lib\site-packages\gimpopenvino\plugins``` Add this path to [Edit-> Preferences-> Folders-> Plugins] in GIMP <br>
4. Restart GIMP, and you should see 'OpenVINO-AI-Plugins' show up in 'Layer' menu <br>

### Linux (Tested on Ubuntu 20.04)
1. Install flatpak distribution of GIMP development package -- instructions here: [GIMP Development Downloads](https://www.gimp.org/downloads/devel/) <br>
2. Clone, run install script, copy weights: <br>
### Linux
This plugin is tested on Ubuntu 22.04.
Building GIMP from source is recommended.

#### 1. Install Dependencies
```
# clone this repo:
git clone https://github.com/intel/openvino-ai-plugins-gimp.git
sudo apt update
sudo apt install -y cmake libgflags-dev patchelf python3-pip gettext git git-lfs build-essential meson ninja-build autoconf libcairo2-dev libxt-dev libgdk-pixbuf-2.0-dev libgexiv2-dev libgtk-3-dev libmypaint-dev mypaint-brushes libbz2-dev libatk1.0-dev libgirepository1.0-dev libx11-xcb-dev libwmf-dev libxcb-glx0-dev libxcb-dri2-0-dev libxxf86vm-dev valgrind libappstream-glib-dev libpugixml-dev libxmu-dev libpoppler-glib-dev xsltproc librsvg2-dev libopencv-dev
```

#### 2. Clone, build, and install babl
```
git clone https://gitlab.gnome.org/GNOME/babl
cd babl
git checkout tags/BABL_0_1_98
meson _build
ninja -C _build
sudo ninja -C _build install
```
#### 3. Clone, build, and install gegl
```
git clone https://gitlab.gnome.org/GNOME/gegl
cd gegl
git checkout tags/GEGL_0_4_46
meson _build
ninja -C _build
sudo ninja -C _build install
```

#### 4. Clone, build, and install Gimp
```
git clone https://gitlab.gnome.org/GNOME/gimp
cd gimp
git checkout tags/GIMP_2_99_16
meson _build
ninja -C _build
sudo ninja -C _build install
```
#### 5. Install Plugins
1. Clone, run install script, and download models. The following steps will create the virtual environment "gimpenv3", install all required packages and will also walk you through models setup.

# run install script - this will create the virtual environment "gimpenv3", install all required packages and will also walk you through models setup.
openvino-ai-plugins-gimp/install.sh
```
git clone https://github.com/intel/openvino-ai-plugins-gimp.git
chmod +x openvino-ai-plugins-gimp/install.sh
./openvino-ai-plugins-gimp/install.sh
```
*You can re-run "run install script" step later again to install & setup models that you may have missed.* <br>
2. Setup the environment Note that you will need to do these steps everytime you start GIMP
```
source /opt/intel/openvino/setupvars.sh
export GI_TYPELIB_PATH=/usr/lib/x86_64-linux-gnu/girepository-1.0:/usr/local/lib/x86_64-linux-gnu/girepository-1.0
```
4. Start the GIMP application (```gimp-2.99```), and add the gimpenv3 path that was printed when running the above step to the list of plugin folders [Edit-> Preferences-> Folders-> Plugins]. <br>
5. Restart GIMP, and you should see 'OpenVINO-AI-Plugins' show up in 'Layer' menu <br>

3. Start the GIMP application (```flatpak run org.gimp.GIMP```), and add the gimpenv3 path that was printed when running the above step to the list of plugin folders [Edit-> Preferences-> Folders-> Plugins]. <br>
4. Restart GIMP, and you should see 'OpenVINO-AI-Plugins' show up in 'Layer' menu <br>

### OpenVINO™ Image Generator Plugin with Stable Diffusion - This GIF doesn't represent the current GUI
# OpenVINO™ Image Generator Plugin with Stable Diffusion
#### A. Prompt to Image
1. Create or choose a layer <br>
2. Select Stable Diffusion from the drop down list in layers -> OpenVINO-AI-Plugins <br>
3. Choose the desired model and device from the drop down list.<br>
- note that the [Latent Consistency Model](https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7) is now supported. Choose `SD_1.5_square_lcm`
4. Click on "Load Models" to compile & load the model on the selected device. Wait for it to complete. Please note that you need to perform this step only if you change the model or device or both. For any subsequent runs just click "Run Inference" <br>
5. Enter prompt and other parameters <br>
6. Click on “Run Inference”. Wait for the total inference steps to get completed. <br>
6. Click on “Generate”. Wait for the total inference steps to get completed. <br>

#### B. Image to Image
1. Create or choose a layer or open an image <br>
2. Follow steps 2,3,4,5 from section A. <br>
3. Select "Use Initial Image"
4. By default the opened image in canvas will be used as initial image to the model. You can also select a different image by browsing from files.
5. Click on “Run Inference”. Wait for the total inference steps to get completed. <br>
5. Click on “Generate”. Wait for the total inference steps to get completed. <br>

#### C. Stable-Diffusion-1.5 Inpainting - Make sure to download and convert the model during install process.
1. Choose a layer or Open an image of size 512x512. (Currently works best with this resolution) <br>
2. Use "Free select tool" to select the area in your image that you wish to change. <br>
3. Right click on your image and click on "Add layer mask". Then choose "Selection" in "Initalize layer Mask to". This should create a mask with your selection.
4. Follow steps 2,3,4,5 from section A. Please note that you will only see "SD_1.5_Inpainting" in model options if you added a mask layer to your image. <br>
5. Click on “Run Inference”. Wait for the total inference steps to get completed. <br>

5. Click on “Generate”. Wait for the total inference steps to get completed. <br>

#### D. Stable-Diffusion-1.5 Controlnet-Openpose - Make sure to download and convert the model during install process.
1. Open an image with some pose that you want to see in new image. <br>
2. Select Stable Diffusion from the drop down list in layers -> OpenVINO-AI-Plugins <br>
3. Choose the controlnet_openpose model and device from the drop down list.<br>
4. Make sure to select -- "Use Initial Image" option from the GUI. If not selected then it will fail.
5. Follow steps 4,5 from section A. <br>
5. Click on “Run Inference”. Wait for the total inference steps to get completed. <br>
6. Click on “Generate”. Wait for the total inference steps to get completed. <br>

![](gifs/controlnet-openpose.png)

Expand All @@ -108,12 +146,18 @@ Skip steps 1 and 2 if you already have Python3 and Git on Windows
3. Choose the controlnet_canny model and device from the drop down list.<br>
4. Make sure to select -- "Use Initial Image" option from the GUI. If not selected then it will fail.
5. Follow steps 4,5 from section A. <br>
5. Click on “Run Inference”. Wait for the total inference steps to get completed. <br>
6. Click on “Generate”. Wait for the total inference steps to get completed. <br>


*If create gif option is selected, please note that performance will reduce. The generated gif is located in below path. You can play it in GIMP by going to Filters -> Animations -> Playback* <br>
```C:\Users\<user_name>\openvino-ai-plugins-gimp\gif\stable_diffusion.gif``` <br>
#### F. Stable-Diffusion-1.5 Controlnet-Scribble - Make sure to download and convert the model during install process.
1. Open an image that you want to use for generating the new image. <br>
2. Select Stable Diffusion from the drop down list in layers -> OpenVINO-AI-Plugins <br>
3. Choose the controlnet_scribble model and device from the drop down list.<br>
4. Make sure to select -- "Use Initial Image" option from the GUI. If not selected then it will fail.
5. Follow steps 4,5 from section A. <br>
6. Click on “Generate”. Wait for the total inference steps to get completed. <br>

_Note that the screenshots below are based on the previous UI_
![](gifs/stable-diffusion.png)
![](gifs/stable-diffusion.webp)

Expand Down
73 changes: 0 additions & 73 deletions choose_sd_model.py

This file was deleted.

Loading

0 comments on commit 532127c

Please sign in to comment.