intel / openvino-ai-plugins-gimp

GIMP AI plugins with OpenVINO Backend
Apache License 2.0
511 stars 55 forks source link

Windows stable diffusion Plugin Issues #65

Closed MadMan247 closed 11 months ago

MadMan247 commented 11 months ago

Hello,

Last night I spent some time trying to set this up. I believe that I have followed the instructions present in this Github readme adequately. I cloned the Git, I installed the GIMP version 2.99.14 that is linked. I ran the provided "openvino-ai-plugins-gimp\install.bat". The first time I ran it, during the weights setup, my PC Blue-screened, so I though it may have been a part of my issue, but re-running it (without a blue screen) did not resolve my issue.

This is essentially my issue, but for a bunch of files. This issue occurs when I attempt to use the stable-diffusion plugin in gimp, specifically after pressing "Load Models" on the UI.

Traceback (most recent call last): File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\tools\stable-diffusion-ov-server.py", line 40, in from models_ov.stable_diffusion_engine_NEW import StableDiffusionEngine File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\tools\openvino_common\models_ov\stable_diffusion_engine_NEW.py", line 22, in from diffusers.pipeline_utils import DiffusionPipeline ModuleNotFoundError: No module named 'diffusers.pipeline_utils'

From the looks of it, the path should be diffusers.pipelines.pipeline_utils.py, but every (possible exaggeration) file references diffusers.pipeline_utils.py (which does not exist). At least these files reference diffusers.pipeline_utils.py instead of diffusers.pipelines.pipeline_utils.py: stable-diffusion-ov-server.py stable_diffusion_engine_NEW.py stable_diffusion_engine_inpainting.py

I tried a symbolic link, didn't work because pipeline_utils references relative to the symbolic link, and it is formatted to properly be in the additional pipelines folder, but again, nothing references it properly in said additional folder. I also tried copy + pasting the file and removing all "from .. "(To reformat it to work not in the additional pipelines folder), but that got old fast, and I got stuck somewhere.

Image of Pipeline_utils location image

Image of where it maybe should be but isn't? At least where some files are expecting it to be. image

I assume my best call is to delete it, and re-install everything, so that's what I'm doing now.

As a side note, I am receiving this error in gimp when I attempt to use any plugins. Specifically the 'file-png-save' error for the stable diffusion too. image

I'm surely in over my head. If anyone has any information, please let me know. There is probably something very simple that I am ignoring. If you need any additional information, please let me know. Thank you dearly for your time and attention.

Python 3.9.13

PC: CPU: Ryzen 3 3200G Ram: 32 GB @ 2666 XMP GPU: A750 MoBo: Asus Prime B450M-A

gblong1 commented 11 months ago

We will be publishing a large update with some new features and several bug fixes in the next day or so. I believe it should solve the issues you are facing.

gblong1 commented 11 months ago

Hi @MadMan247 - we have published a new release which should resolve this issue. Can you please check it and let me know?

MadMan247 commented 11 months ago

Hey, I got way further this time-- The installation went smoothly, and the stable diffusion ran, but I think the error messages are the issue now. The "calling error for procedure: file-png-save" and "Execution error for procedure: gimp-file-load". After running the diffuser, I got a traceback: [ INFO ] Starting inference... [ INFO ] Prompt: bird [ INFO ] negative_prompt: [ INFO ] num_inference_steps: 32 [ INFO ] guidance_scale: 7.5 [ INFO ] strength: 1.0 [ INFO ] init_image: None [ INFO ] Random Seed: 1244062086 Image is NONE 100%|██████████████████████████████████████████████████████████████████████████████████| 32/32 [05:21<00:00, 10.04s/it] Image generated from Stable-Diffusion in 335.53828287124634 seconds. Waiting Exception in thread Thread-2 (async_sd_run_func): Traceback (most recent call last): File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 309, in run result_layer = result.get_active_layer() AttributeError: 'NoneType' object has no attribute 'get_active_layer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Edward\AppData\Local\Programs\GIMP 2.99\lib\python3.10\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Users\Edward\AppData\Local\Programs\GIMP 2.99\lib\python3.10\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 389, in async_sd_run_func runner.run(dialog) File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 312, in run result_layers = result.list_layers() AttributeError: 'NoneType' object has no attribute 'list_layers'

While this error was for CPU, the same error occurs for a CPU or GPU device. The UI sits on this screen: image

This is the provided line in the installation process that indicates the plugin folder NOTE ! >> Please add this path to Preferences --> Plug-ins in GIMP : C:\Users\Edward\gimpenv3\lib\site-packages\gimpopenvino\plugins

I am going to uninstall and re-install the GIMP 2.99.14 to see if it is the issue.

Any information or speculation is appreciated. If you need any other information from me, please let me know.

MadMan247 commented 11 months ago

Here is my gimp debug log. I hope that this can prove useful. Reinstalling GIMP did not help. Actually, the plugins were already listed under layers of the new GIMP install, so I can only assume that not everything is uninstalled when you uninstall it through control panel. If you need any other information, please let me know. Thank you for your time and this update that got me much further through the process. (also of note, whether I run the openvino setupvars.bat or not, I get the same result. Perhaps my w_openvino_toolkit_windows_2023.2.0.13089.cfd42bd2cb0_x86_64 is flawed?)

This is the log from me doing the following: Launching GIMP Creating a new file with the default settings (2001 x 1984 pixels) going to layer>openvino plugins > stable diffusion changing from CPU to GPU clicking "Load Model" clicking "Generate Image" Closing the UI:

This is a development version of GIMP. Debug messages may appear here.

(gimp-2.99.exe:4968): GLib-GIO-WARNING **: 02:24:48.590: win32 session dbus binary not found set device 'System Aggregated Pointer' to mode: disabled set device 'DJP Inc. Virtual Multitouch Device Pen stylus' to mode: screen set device 'DJP Inc. Virtual Multitouch Device Eraser' to mode: screen set device 'HUION Huion Tablet Pen stylus' to mode: screen set device 'HUION Huion Tablet Eraser' to mode: screen set device 'DJP Inc. Virtual Multitouch Device Pen stylus' to mode: screen gimp_device_info_set_device: trying to set GdkDevice 'DJP Inc. Virtual Multitouch Device Pen stylus' on GimpDeviceInfo which already has a device set device 'DJP Inc. Virtual Multitouch Device Eraser' to mode: screen gimp_device_info_set_device: trying to set GdkDevice 'DJP Inc. Virtual Multitouch Device Eraser' on GimpDeviceInfo which already has a device Skipping potential plug-in 'C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\plugin_utils.py': plug-ins must be installed in subdirectories. Skipping potential plug-in 'C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins__init__.py': plug-ins must be installed in subdirectories.

(stable-diffusion-ov.py:11152): Gtk-CRITICAL **: 02:25:16.444: gtk_grid_attach: assertion '_gtk_widget_get_parent (child) == NULL' failed No stable-diffusion model server found to kill C:\Users\Edward\gimpenv3\lib\site-packages\ngraph\helpers.py:9: FutureWarning: OpenVINO Inference Engine Python API is deprecated and will be removed in 2024.0 release.For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html from openvino.inference_engine import IENetwork # type: ignore C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\tools\openvino_common\models_ov\open_pose.py:18: FutureWarning: OpenVINO nGraph Python API is deprecated and will be removed in 2024.0 release.For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html import ngraph as ng C:\Users\Edward\gimpenv3\lib\site-packages\controlnet_aux\open_pose\body.py:7: DeprecationWarning: Please use gaussian_filter from the scipy.ndimage namespace, the scipy.ndimage.filters namespace is deprecated. from scipy.ndimage.filters import gaussian_filter C:\Users\Edward\gimpenv3\lib\site-packages\controlnet_aux\open_pose\hand.py:4: DeprecationWarning: Please use gaussian_filter from the scipy.ndimage namespace, the scipy.ndimage.filters namespace is deprecated. from scipy.ndimage.filters import gaussian_filter C:\Users\Edward\gimpenv3\lib\site-packages\controlnet_aux\mediapipe_face\mediapipe_face_common.py:7: UserWarning: The module 'mediapipe' is not installed. The package will have limited functionality. Please install it using the command: pip install 'mediapipe' warnings.warn( [ INFO ] Model Name: SD_1.4 [ INFO ] Initializing Inference Engine... [ INFO ] Model Path: C:\Users\Edward\openvino-ai-plugins-gimp\weights\stable-diffusion-ov\stable-diffusion-1.4 [ INFO ] device_name: ['GPU', 'GPU', 'GPU', 'GPU'] Text Device: GPU unet Device: GPU Vae Device: GPU Ready model load complete. Running SD async Waiting [ INFO ] Starting inference... [ INFO ] Prompt: bird [ INFO ] negative_prompt: [ INFO ] num_inference_steps: 32 [ INFO ] guidance_scale: 7.5 [ INFO ] strength: 1.0 [ INFO ] init_image: None [ INFO ] Random Seed: 1870010510 Image is NONE 100%|██████████████████████████████████████████████████████████████████████████████████| 32/32 [00:04<00:00, 7.25it/s] Image generated from Stable-Diffusion in 4.569179058074951 seconds. Waiting Exception in thread Thread-2 (async_sd_run_func): Traceback (most recent call last): File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 309, in run result_layer = result.get_active_layer() AttributeError: 'NoneType' object has no attribute 'get_active_layer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\GIMP 2.99\lib\python3.10\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Program Files\GIMP 2.99\lib\python3.10\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 389, in async_sd_run_func runner.run(dialog) File "C:\Users\Edward\gimpenv3\Lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 312, in run result_layers = result.list_layers() AttributeError: 'NoneType' object has no attribute 'list_layers'

gblong1 commented 11 months ago

Hi @MadMan247 - thanks for providing all of the detailed information. I have tried reproducing this error, but I cannot see it on my system.

Next step: The GIMP uninstall step does not remove the plugins. I have a feature request to add the uninstall steps to the README which I will do soon-ish. In the meantime, can you try completely removing C:\Users\Edward\gimpenv3 and re-running the C:\Users\Edward\openvino-ai-plugins-gimp\install.bat. It should go relatively quickly, as most of your pkgs will still be cached.

MadMan247 commented 11 months ago

Thank you for the follow up. I may attempt to set this up on a fresh, unmuddled machine to see if I can replicate my issue myself at least. It does not appear to be a gimp issue, as I installed GIMP development version 2.99.16, and an identical issue occurred. I followed your suggestion and deleted the gimpenv3 folder and reinstalled before testing, and of course I also ran the openvino setupvars.bat.

Just in case I needed to, I also followed the setup for model SD_1.4. I ran install.bat as administrator just to hopefully increase my odds of it working (cd to my home directory, so nothing should have changed other than privileges)

Thank you again. I'll try setting up on a VM and get back to you. If a VM doesn't work, I should have a fresh windows 10 machine to try it on in a few days. I may record my setup steps to embed just in case I'm doing something incorrectly.

MadMan247 commented 11 months ago

I have recorded a video of me following these steps in a virtual machine:

1.) Install Python 3.9.13 - https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe 2.) Install latest GIT - https://git-scm.com/ 3.) install GIMP 2.99.14 - https://download.gimp.org/gimp/v2.99/windows/gimp-2.99.14-setup.exe 4.) clone repo - git clone https://github.com/intel/openvino-ai-plugins-gimp.git 5.) download OpenVino 2023.2 from Archives - https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.2/windows/ 6.) Install OpenVino 2023.2 (Instructions from Documentation) - https://docs.openvino.ai/2023.2/openvino_docs_install_guides_installing_openvino_from_archive_windows.html 6a.) Make Folder C:\Program Files (x86)\Intel - mkdir "C:\Program Files (x86)\Intel" 6b.) extract contents to Intel folder -

tar -xf openvino_2023.2.0.zip ren w_openvino_toolkit_windows_2023.2.0.13089.cfd42bd2cb0_x86_64 openvino_2023.2.0 move openvino_2023.2.0 "C:\Program Files (x86)\Intel"

6c.) Symbolic Link -

cd C:\Program Files (x86)\Intel mklink /D openvino_2023 openvino_2023.2.0

6d.) Run Setupvars.bat - "C:\Program Files (x86)\Intel\openvino_2023\setupvars.bat" 7.) Run Installer - openvino-ai-plugins-gimp\install.bat 8.) Prompts: Y, Y, 0 (whichever is no)? 9.) Launch Gimp (With or without Setupvars? It seems unneeded for this step, I will not use it.) 10.) Edit>Prefrences>Folders>Plug-ins add folder C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins 11.) apply Changes 12.) close GIMP 13a.) Launch Gimp with Setupvars.bat -

call "C:\Program Files (x86)\Intel\openvino_2023\setupvars.bat" cd "C:\Program Files\GIMP 2.99\bin" .\gimp-2.99.exe

13b.) use Stable Diffusion File>New default values Layer>Openvino-ai-gimp>stable diffusion

14.) Profit?

I am not profiting.

As this is a new virtual machine, I can rule out outside or improperly configured interference. I have encountered the same issue on a real (work) computer too (I had free time). Please let me know which instruction I am missing / I am doing incorrectly. I am unable to set it up correctly to make it past this point to see if I can achieve what I have on my main rig... Really, how'd I do it? At least I didn't get the file-png errors. (I followed these instructions twice to identical results, but the first recording was about 25 mins, and I recorded it incorrectly, so the edges of the VM were cropped out.)

Stable Diffusion Error:

(stable-diffusion-ov.py:2328): LibGimp-WARNING **: 16:15:43.621: gimp_procedure_run: no return values, shouldn't happen C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py:1220: Warning: g_error_new: assertion 'domain != 0' failed Gimp.main(StableDiffusion.gtype, sys.argv) gimp_plug_in_destroy_proxies: ERROR: GimpImage proxy with ID 1 was refed by plug-in, it MUST NOT do that! gimp_plug_in_destroy_proxies: ERROR: GimpLayer proxy with ID 2 was refed by plug-in, it MUST NOT do that!

gblong1 commented 11 months ago

Hi @MadMan247 - thanks for the video. at about time 4:06, it looks like you skipped step 6d (Run Setupvars.bat). This is necessary so that the version of OpenVINO used is the runtime which has been downloaded and installed in the 6c step.

Otherwise everything looks good. I think the one thing that might be missing is the MSFT Visual C++ Runtime Redist. I believe this will resolve the Stable Diffusion issue.

For the super resolution problem at ~14:29, it looks like your VM is running out of memory. You are starting with a large resolution image (2000x1994) and you are trying to do a 2x upscale. However, your VM only has 6GB of DDR allocated. You can try with a smaller starting image (512x512?) and it should fit in the 6GB DDR.

MadMan247 commented 11 months ago

Thank you again for your response. I am aware that this is not an issue that you need to keep up with, and I really do appreciate your time here.

You were absolutely correct about the Super Resolution issue -- I did not understand the error message produced, and by following your instruction in reducing the file resolution (or increasing the ram), it now functions. Thank you again.

In regard to the C++ Runtime, simply installing the latest version (14.38.33130) after the fact did not solve the issue.

I re-performed my steps and again recorded it. (But this time success!) It should be noted that I installed BOTH VCREDISTx64 12.0.40664 and 14.38.33130, so I can not say yet which is required (glad that you updated the readme.txt).

Also, I encountered an error when I tried to just install SD_1.4. Installing a 1.5 model resolved this.

Here is my notepad of instructions: 1.) Install Python 3.9.13 - https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe 2.) Install latest GIT - https://git-scm.com/ 3.) install GIMP 2.99.14 - https://download.gimp.org/gimp/v2.99/windows/gimp-2.99.14-setup.exe 4.) Install Microsoft Visual C++ Redistributable (Version?) 5.) clone repo - git clone https://github.com/intel/openvino-ai-plugins-gimp.git 6.) downlod OpenVino 2023.2 from Archives - https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.2/windows/ 7.) Install OpenVino 2023.2 (Instructions from Documentation) - https://docs.openvino.ai/2023.2/openvino_docs_install_guides_installing_openvino_from_archive_windows.html 7a.) Make Folder C:\Program Files (x86)\Intel - mkdir "C:\Program Files (x86)\Intel" 7b.) extract contents to Intel folder -

tar -xf openvino_2023.2.0.zip ren w_openvino_toolkit_windows_2023.2.0.13089.cfd42bd2cb0_x86_64 openvino_2023.2.0 move openvino_2023.2.0 "C:\Program Files (x86)\Intel"

7c.) Symbolic Link -

cd C:\Program Files (x86)\Intel mklink /D openvino_2023 openvino_2023.2.0

7d.) Run Setupvars.bat - "C:\Program Files (x86)\Intel\openvino_2023\setupvars.bat" 8.) Run Installer - openvino-ai-plugins-gimp\install.bat 9.) Prompts: Y, Y, 0. (Correct to Y, Y, 1, 0, includes model 1.5 setup) 10.) Launch Gimp (With Setupvars.bat (see 14)) 11.) Edit>Prefrences>Folders>Plug-ins add folder C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins 12.) apply Changes 13.) close GIMP 14.) Launch Gimp with Setupvars.bat -

call "C:\Program Files (x86)\Intel\openvino_2023\setupvars.bat" cd "C:\Program Files\GIMP 2.99\bin" .\gimp-2.99.exe

15.) Profit?

Error Recieved:

Traceback (most recent call last): File "C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 443, in run list_models(config_path_output["weight_path"],"SD_1.5") + File "C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py", line 184, in list_models for file in os.scandir(dir_path): #, recursive=True): FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\Users\jake\openvino-ai-plugins-gimp\weights\stable-diffusion-ov\stable-diffusion-1.5'

(stable-diffusion-ov.py:3536): LibGimp-WARNING **: 16:33:42.063: gimp_procedure_run: no return values, shouldn't happen C:\Users\jake\gimpenv3\lib\site-packages\gimpopenvino\plugins\stable-diffusion-ov\stable-diffusion-ov.py:1220: Warning: g_error_new: assertion 'domain != 0' failed Gimp.main(StableDiffusion.gtype, sys.argv) gimp_plug_in_destroy_proxies: ERROR: GimpImage proxy with ID 1 was refed by plug-in, it MUST NOT do that! gimp_plug_in_destroy_proxies: ERROR: GimpLayer proxy with ID 2 was refed by plug-in, it MUST NOT do that!

Steps Taken After Error: Re-run Installer - openvino-ai-plugins-gimp\install.bat Prompts: Y N 1 0 (Install model 1.5 Square) call "C:\Program Files (x86)\Intel\openvino_2023\setupvars.bat" cd "C:\Program Files\GIMP 2.99\bin" .\gimp-2.99.exe new 512x512 Stable Diffusion It worked.

Thank you again for your time and dedication. Now that I have instructions that are proven to work, I can troubleshoot my computer for that file-png-save and gimp-file-load error that I encounter, but that's probably something outside of the scope of this issue, so I'll mark as this closed for now.

EDIT: the file-png-save and gimp-file-load errors were fixed by taking the time to uninstall gimp, and locating and deleting the gimp files in my appdata folder, probably some misconfigured setting.