Abstract
Running "AI" on PC requires rich computational resources as GPU with VRAM, and storage for its model. "bes-dev/stable_diffusion.openvino"*1 made running Stable Diffusion on poor consumer PC.
And "intel/openvino-ai-plugins-gimp" allows an user to operate Stable Diffusion via GUI of GIMP plugin. It provides 5 plugins including Stable Diffusion.
github.com
This post introduce how to run it on Windows PC only with 8GB RAM without GPU, and its performance. Even Microsoft Surface Pro 4 with specs below can run and output a single image per 10~12min.
OS | Windows 11 Pro 22H2 |
CPU | Intel Core i7-6650U |
RAM | 8GB |
Storage | SSD: 256GB SD card: 32GB (D drive in this post) |
Container and WSL are not used in this post. On limited resource environment, it is better run SDOV directly than to use them. Actually, SDOV can run stably even on a PC with RAM=8GB.
Computational resource assignment is done by Windows OS to them, and it sometime causes OOM kill, which a process is killed forcibly due to out of memory. Although there are workaround to avoid it, they are not recommended.
You should not try to circumvent these safeguards by manually setting --oom-score-adj to an extreme negative number on the daemon or a container, or by setting --oom-kill-disable on a container.
Runtime options with Memory, CPUs, and GPUs | Docker Documentation
Tools
To proceed the work below, following tools are required. "version" is the one in this post.
version | |
---|---|
GIMP | 2.99.14 |
Visual Studio 2022 | 17.5.1 |
Python | 3.10.11 |
GitHub Desktop Git command |
3.2.0 |
GIMP
Use GIMP of development release, not stable version. This plugin doesn't work in stable version. The latest version of the development release at the moment of this post is 2.99.14.
A development release doesn't overwrite a stable version. It can be used in parallel with a stable version.
Visual Studio and C++ build tools
C++ builder is required to install Python packages. This tool is included in Visual Studio, or "Build Tools for Visual Studio". In advance of starting procedure below, one of both must be installed with appropriate options.
In case of Visual Studio, access the next menu item, and install "Desktop development with C++" with default options.
Tools > Get Tools and Features...
Python
Python can be directly downloaded and installed from Microsoft Store. This time, install version "3.10". The version at this post is "3.10.10"
Although the latest one is version 3.11, it has not been supported by Intel OpenVINO*2 yet. The next version of OpenVINO may support 3.11.
Python 3.11 is in progress and will be available in 2023.0 release.
GitHub Desktop or Git command
This is required to download "bes-dev/stable_diffusion.openvino" (hereinafter SDOV). If Git command is not available, download and install GitHub Desktop.
desktop.github.com
Folders
Although the body of "intel/openvino-ai-plugins-gimp" is Python virtual, its folder structure should be defined as normal exist files and folders for working as GIMP plugin.
This program provides a bat file (install.bat) for its install. It defines environment values and Python packages, but subsequent install processes are also defined in other Python scripts. And they also defines required packages and install folders there. A user should not insert own settings into them.
This post follows default configuration excepting the working folders.
path | |
---|---|
working folder | c:\myapp |
git cloneed folder install folder |
c:\myapp\openvino-ai-plugins-gimp |
Python virtual environment | c:\myapp\openvino-ai-plugins-gimp\gimpenv3 |
weightse | %userprofile%\openvino-ai-plugins-gimp\weights\ |
model | %userprofile%\openvino-ai-plugins-gimp\weights\stable-diffusion-ov\stable-diffusion-1.4 |
plugins | C:\myapp\openvino-ai-plugins-gimp\gimpopenvino\plugins |
"intel/openvino-ai-plugins-gimp"
Download program
Move to the working folder and download program with Git command or GitHub Desktop.
git clone git clone https://github.com/intel/openvino-ai-plugins-gimp.git
Edit "install.bat" and run it
Open "install.bat" in the install folder, and rewrite the next line as
🔎before rewritten
gimpenv3\Scripts\python.exe -m pip install openvino-ai-plugins-gimp\.
🔎after rewritten
gimpenv3\Scripts\python.exe -m pip install C:\myapp\openvino-ai-plugins-gimp.
The relational path initially written has risk to install files and folders to unexpected location depending on the location it run. To void this risk, it should be rewritten as absolute path.
Run the edited bat file.
Copy weighes
After the install process of "install.bat", copy all data under the source below to the destination.
🔎source
C:\myapp\openvino-ai-plugins-gimp\weights\
🔎destination
%userprofile%\openvino-ai-plugins-gimp\weights\
GitHub introduces xcopy command including Windows environment variable "%userprofile%". Running this command from Command Prompt is no problem, but from PowerShell is not. Description manner of environment variable there is different as "$env:userprofile".
Just copy and paste all data in a folder, it is enough to perform manually on File Explorer.
Download and copy Stable-Diffusion-1.4 model
Download model with Git command or GitHub Desktop.
git clone https://huggingface.co/bes-dev/stable-diffusion-v1-4-openvino/tree/main
Copy all files downloaded to the next folder.
%userprofile%\openvino-ai-plugins-gimp\weights\stable-diffusion-ov\stable-diffusion-1.4
Copy "gimp_openvino_config.json"
Copy "gimp_openvino_config.json" in the source folder below to the destination.
🔎source
C:\myapp\openvino-ai-plugins-gimp\gimpopenvino\tools\
🔎destination
C:\myapp\openvino-ai-plugins-gimp\gimpenv3\Lib\site-packages\gimpopenvino\tools\
Configure GIMP plugin and restart GIMP
Launch GIMP and follow next menu and settings.
Edit > Preferences Folders > Plug-ins
Add the next folder and restart GIMP.
C:\myapp\openvino-ai-plugins-gimp\gimpopenvino\plugins
Creating new image after relaunching GIMP, and OpenVINO-AI-Plugins are enabled. They can be accessed at the next menu item.
Layer > OpenVINO-AI-Plugins
Run Stable Diffusion
Below is major items of Stable Diffusion.
Enter text to generate image | prompt explain expected factors |
Negative Prompt | explain unexpected/unnecessary factors |
Number of Inference steps | the more times, the longer it takes to process |
Seed | random number seed reproduce random number generation |
In assumption with performance of consumer PC as Surface Pro 4, Number of inference and time for image output are
inference | image output (min) |
---|---|
8 | 3 |
16 | 6 |
32 | 10 |
50 | 15 |
To generate image efficiently, repeat inference with small number as possible until determining direction, then finish with larger inference number as possible and the last random seed number. Next images were output with inference = 8, 16, 32, 50.
prompt | Cleopatra, art of Mucha and Utamaro, in style of movie |
negative prompt | ugly, deformed |
In inference to render Cleopatra in style of MuCha and Utamaro, a image becomes from rough to detailed in accordance with larger inference number. It is understandable that the characteristics of specific areas become clearer as
- decoration and background become more MuCha-tic
- facial features become as mixed race between European and Asian
Fine tuning prompt to render close-up of the face, and the image at the top of this post after 50 inferences outputs.