Closed testivel closed 2 months ago
Hi. Just like #5, this is the bug related to the installation of pytoshop, which is a dependency of this extension. For some reason packbits is problematic in some users, which causes some people cannot install pytoshop properly.
So this is the bug related to not being able to install pytoshop properly, I'd recommend temporary quick fix if possible:
pip install pytoshop==1.1.0 -I --no-cache-dir
As some people have successfully installed pytoshop according to https://github.com/jhj0517/stable-diffusion-webui-Layer-Divider/issues/5#issuecomment-1572676680.
If anyone knows why this packbits bug is happening and can tell me why or make a PR, I'd appreciate it.
@jhj0517
Same error while restarting UI
After running
pip install pytoshop==1.1.0 -I --no-cache-dir
The console output shows: [SD-Launcher] D:\NouvelAi>pip install pytoshop==1.1.0 -I --no-cache-dir Looking in indexes: https://mirror.baidu.com/pypi/simple Looking in links: https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html Collecting pytoshop==1.1.0 Downloading https://mirror.baidu.com/pypi/packages/39/4f/4126e638ee635014098dec2a6ec45ee19bd6d16964c3867c3b45c3d6a4c0/pytoshop-1.1.0.tar.gz (2.2 MB) ---------------------------------------- 2.2/2.2 MB 14.0 MB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting cython (from pytoshop==1.1.0) Downloading https://mirror.baidu.com/pypi/packages/c5/b6/680c6fa2122693ba16d34e6b1c3e4d4a04c3908b5f78a46c948006727bb7/Cython-3.0.6-cp310-cp310-win_amd64.whl (2.8 MB) ---------------------------------------- 2.8/2.8 MB 11.8 MB/s eta 0:00:00 Collecting numpy (from pytoshop==1.1.0) Downloading https://mirror.baidu.com/pypi/packages/24/b5/fed6f7e582937eb947369dccf6c94602598a25f23e482d1b1f2299159328/numpy-1.26.2-cp310-cp310-win_amd64.whl (15.8 MB) ---------------------------------------- 15.8/15.8 MB 11.1 MB/s eta 0:00:00 Building wheels for collected packages: pytoshop Building wheel for pytoshop (pyproject.toml) ... done Created wheel for pytoshop: filename=pytoshop-1.1.0-py2.py3-none-any.whl size=140738 sha256=5479319163e37cce5d4b5d60565be4cc6f18f62a2d301b4c29fc36034b8cc957 Stored in directory: C:\Users\julang\AppData\Local\Temp\pip-ephem-wheel-cache-j0kprh9q\wheels\8d\be\a3\8a7d44cb5727f449f60ca3e9ee1a209b6269dfd8a566e3fcaf Successfully built pytoshop Installing collected packages: numpy, cython, pytoshop Successfully installed cython-3.0.6 numpy-1.26.2 pytoshop-1.1.0
This error has been haunting me for several days... My understanding is that this happens in the StabilityMatrix application because it ships with Python on Windows without any include folders containing Python.h.
I was able to install the pytoshop by installing Python 3.10.6 globaly and then copying the Include folder to StabilityMatrix\Data\Assets\Python310.
After this I launch venv in CMD by running the shortcut I created with the command (change your paths): C:\Windows\System32\cmd.exe /k "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Scripts\activate.bat"
And finally, typing in the CMD window: pip install pytoshop==1.1.0 --config-settings I=D:\AI\StabilityMatrix\Data\Assets\Python310\include
But after installing pytoshop StabilityMatrix gave me this in the output log:
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] Version: v1.9.4 Commit hash: feee37d75f1b168768014e4634dcb156ee649c05 Installing sd-webui-controlnet requirement: changing opencv-python version from 4.10.0.84 to 4.8.0 D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\sd-webui-reactor\install.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources CUDA 12.1 Launching Web UI with arguments: --medvram --xformers --api --skip-python-version-check --gradio-allowed-path D:\AI\StabilityMatrix\Data\Images Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu. ControlNet preprocessor location: D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\sd-webui-controlnet\annotator\downloads 2024-07-04 02:01:59,595 - ControlNet - INFO - ControlNet v1.1.449 02:02:00 - ReActor - STATUS - Running v0.7.1-a1 on Device: CUDA Compiling D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\packbits.pyx because it changed. [1/1] Cythonizing D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\packbits.pyx running build_ext building 'pytoshop.packbits' extension creating build creating build\temp.win-amd64-3.10 creating build\temp.win-amd64-3.10\Release creating build\temp.win-amd64-3.10\Release\AI creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages creating build\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\include -ID:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Scripts\include -ID:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Scripts\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include -IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um /TcD:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\packbits.c /Fobuild\temp.win-amd64-3.10\Release\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\packbits.obj packbits.c D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\packbits.c(29): fatal error C1083: �� 㤠���� ������ 䠩� ����祭��: Python.h: No such file or directory, error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
So I opened venv again and entered: pip install packbits --config-settings I=D:\AI\StabilityMatrix\Data\Assets\Python310\include
This installs the Packbits package, but the error remains the same. I think it's because it uses VS BuildTools tries to compile packbits as an extension and also can't find Python.h for that. How to fix that I don't know...
So I had to uninstall pytoshop and delete Layer-Divider from extensions to get StabilityMatrix running again: pip uninstall pytoshop pip uninstall packbits
@silverfr0st Unfortunately some packages are problematic in some environments when installed programmatically when starting webui. pytoshop
is problematic when installed programmatically.
To fix this, you need to manually activate venv and install these packages before running webui.
C:\YourPath\To_SD_WebUI>venv\Scripts\activate
Then it will display (venv) in front of the terminal like this.
(venv) C:\YourPath\To_SD_WebUI>
pip uninstall -y pytoshop
pip uninstall -y packbits
pip install pytoshop
pip install packbits
It should work after running these commands. Please let me know if the problem persists.
I've just added a README about this.
Thank you very much. That fixed problem for me!
But there is another problem...
So I completely removed the old extension, uninstalled Pytoshop and Packbits, and then installed the extension again in A1111. I manually installed Pytoshop and Packbits in venv. Everything without errors.
After that I launched the webUI, got the LayerDivider tab, but when I tried to use it, the following appeared in the logs:
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] Version: v1.9.4 Commit hash: feee37d75f1b168768014e4634dcb156ee649c05 Installing sd-webui-controlnet requirement: changing opencv-python version from 4.10.0.84 to 4.8.0 D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\sd-webui-reactor\install.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources CUDA 12.1 Launching Web UI with arguments: --medvram --xformers --api --skip-python-version-check --gradio-allowed-path D:\AI\StabilityMatrix\Data\Images Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu. ControlNet preprocessor location: D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\sd-webui-controlnet\annotator\downloads 2024-07-04 18:58:21,643 - ControlNet - INFO - ControlNet v1.1.449 18:58:23 - ReActor - STATUS - Running v0.7.1-a1 on Device: CUDA Loading weights [40d4f9d626] from D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\models\Stable-diffusion\SD1.5\sardonyxREDUX_v20.safetensors Creating model from config: D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\configs\v1-inference.yaml 2024-07-04 18:58:25,361 - ControlNet - INFO - ControlNet UI callback registered. Running on local URL: http://127.0.0.1:7860
To create a public link, set share=True in launch(). Startup time: 25.7s (prepare environment: 7.5s, import torch: 3.4s, import gradio: 0.8s, setup paths: 1.1s, initialize shared: 1.8s, other imports: 0.7s, load scripts: 5.1s, create ui: 3.5s, gradio launch: 0.6s, add APIs: 0.9s). Applying attention optimization: xformers... done. Model loaded in 11.2s (load weights from disk: 0.3s, create model: 1.1s, apply weights to model: 4.5s, apply half(): 2.7s, calculate empty prompt: 2.6s).
Layer Divider Extension : applying configs to model.. Traceback (most recent call last): File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict output = await app.get_blocks().process_api( File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api result = await self.call_function( File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function prediction = await anyio.to_thread.run_sync( File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run result = context.run(func, args) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper response = f(args, **kwargs) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\stable-diffusion-webui-Layer-Divider\scripts\layer_divider_modules\sam.py", line 79, in generate_mask_app save_psd_with_masks(image, masks, output_path) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\stable-diffusion-webui-Layer-Divider\scripts\layer_divider_modules\mask_utils.py", line 100, in save_psd_with_masks save_psd(image, original_layer+mask_layers, ['Original_Image']+names, modes, output_path) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\extensions\stable-diffusion-webui-Layer-Divider\scripts\layer_divider_modules\mask_utils.py", line 92, in save_psd psd_file.write(output_file) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\core.py", line 281, in write self.layer_and_mask_info.write(fd, self) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\layers.py", line 1430, in write self.layer_info.write(fd, header) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\layers.py", line 1226, in write layer.write_channel_data(fd, header) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\layers.py", line 1120, in write_channel_data lengths.append(data.write(fd, header, shape)) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\layers.py", line 602, in write codecs.compress_image( File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\codecs.py", line 488, in compress_image return compressors[compression](fd, image, depth, version) File "D:\AI\StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\pytoshop\codecs.py", line 331, in compress_rle packed = packbits.encode(row) NameError: name 'packbits' is not defined
Which is strange because venv gives me with pip list
the following:
absl-py 2.1.0 accelerate 0.21.0 addict 2.4.0 aenum 3.1.15 aiofiles 23.2.1 aiohttp 3.9.5 aiosignal 1.3.1 albumentations 1.4.3 altair 5.3.0 antlr4-python3-runtime 4.9.3 anyio 3.7.1 async-timeout 4.0.3 attrs 23.2.0 beautifulsoup4 4.12.3 blendmodes 2022 certifi 2024.6.2 cffi 1.16.0 chardet 5.2.0 charset-normalizer 3.3.2 clean-fid 0.1.35 click 8.1.7 clip 1.0 colorama 0.4.6 coloredlogs 15.0.1 colorlog 6.8.2 contourpy 1.2.1 cssselect2 0.7.0 cycler 0.12.1 Cython 3.0.10 defusedxml 0.7.1 deprecation 2.1.0 depth_anything 2024.1.22.0 diffusers 0.29.2 diskcache 5.6.3 dsine 2024.3.23 easydict 1.13 einops 0.4.1 embreex 2.17.7.post4 exceptiongroup 1.2.1 ez-setup 0.9 facexlib 0.3.0 fastapi 0.94.0 ffmpy 0.3.2 filelock 3.15.4 filterpy 1.4.5 flatbuffers 24.3.25 fonttools 4.53.0 frozenlist 1.4.1 fsspec 2024.6.1 ftfy 6.2.0 fvcore 0.1.5.post20221221 gdown 5.2.0 geffnet 1.0.2 gitdb 4.0.11 GitPython 3.1.32 glob2 0.5 gradio 3.41.2 gradio_client 0.5.0 h11 0.12.0 handrefinerportable 2024.2.12.0 httpcore 0.15.0 httpx 0.24.1 huggingface-hub 0.23.4 humanfriendly 10.0 idna 3.7 imageio 2.34.2 importlib_metadata 8.0.0 importlib_resources 6.4.0 inflection 0.5.1 insightface 0.7.3 iopath 0.1.9 jax 0.4.30 jaxlib 0.4.30 Jinja2 3.1.4 joblib 1.4.2 jsonmerge 1.8.0 jsonschema 4.22.0 jsonschema-specifications 2023.12.1 kiwisolver 1.4.5 kornia 0.6.7 lark 1.1.2 lazy_loader 0.4 lightning-utilities 0.11.3.post0 llvmlite 0.43.0 loguru 0.7.2 lxml 5.2.2 mapbox-earcut 1.0.1 markdown-it-py 3.0.0 MarkupSafe 2.1.5 matplotlib 3.9.0 mdurl 0.1.2 mediapipe 0.10.14 ml-dtypes 0.4.0 mpmath 1.3.0 multidict 6.0.5 networkx 3.3 numba 0.60.0 numpy 1.26.2 omegaconf 2.2.3 onnx 1.16.1 onnxruntime-gpu 1.18.1 open-clip-torch 2.20.0 opencv-contrib-python 4.10.0.84 opencv-python 4.10.0.84 opencv-python-headless 4.10.0.84 opt-einsum 3.3.0 orjson 3.10.5 packaging 24.1 packbits 0.6 pandas 2.2.2 piexif 1.1.3 Pillow 9.5.0 pillow-avif-plugin 1.4.3 pip 24.1.1 platformdirs 4.2.2 pooch 1.8.2 portalocker 2.10.0 prettytable 3.10.0 protobuf 3.20.3 psutil 5.9.5 py-cpuinfo 9.0.0 pycocotools 2.0.8 pycollada 0.8 pycparser 2.22 pydantic 1.10.17 pydantic_core 2.20.0 pydub 0.25.1 Pygments 2.18.0 PyMatting 1.1.12 pyparsing 3.1.2 pyreadline3 3.4.1 PySocks 1.7.1 python-dateutil 2.9.0.post0 python-multipart 0.0.9 pytorch-lightning 1.9.4 pytoshop 1.2.1 pytz 2024.1 PyWavelets 1.6.0 pywin32 306 PyYAML 6.0.1 referencing 0.35.1 regex 2024.5.15 rembg 2.0.50 reportlab 4.2.2 requests 2.32.3 resize-right 0.0.2 rich 13.7.1 rpds-py 0.18.1 Rtree 1.2.0 safetensors 0.4.2 scikit-image 0.21.0 scikit-learn 1.5.0 scipy 1.14.0 seaborn 0.13.2 segment-anything 1.0 semantic-version 2.10.0 Send2Trash 1.8.3 sentencepiece 0.2.0 setuptools 69.5.1 shapely 2.0.4 six 1.16.0 smmap 5.0.1 sniffio 1.3.1 sounddevice 0.4.7 soupsieve 2.5 spandrel 0.1.6 starlette 0.26.1 supervision 0.21.0 svg.path 6.3 svglib 1.5.1 sympy 1.12.1 tabulate 0.9.0 termcolor 2.4.0 threadpoolctl 3.5.0 tifffile 2024.6.18 timm 0.9.5 tinycss2 1.3.0 tokenizers 0.13.3 tomesd 0.1.3 tomli 2.0.1 toolz 0.12.1 torch 2.1.2+cu121 torchdiffeq 0.2.3 torchmetrics 1.4.0.post0 torchsde 0.2.6 torchvision 0.16.2+cu121 tqdm 4.66.4 trampoline 0.1.2 transformers 4.30.2 trimesh 4.4.1 triton 2.1.0 typing_extensions 4.12.2 tzdata 2024.1 ultralytics 8.2.48 ultralytics-thop 2.0.0 urllib3 2.2.2 uvicorn 0.30.1 vhacdx 0.0.8.post1 wcwidth 0.2.13 webencodings 0.5.1 websockets 11.0.3 wheel 0.43.0 win32-setctime 1.1.0 xatlas 0.0.9 xformers 0.0.23.post1 xxhash 3.4.1 yacs 0.1.8 yapf 0.40.2 yarl 1.9.4 zipp 3.19.2
Maybe there are still incorrect calls in the code?
@silverfr0st Can you try again with these commands? (While activating the venv)
pip uninstall -y pytoshop
pip uninstall -y packbits
pip install pytoshop --no-cache-dir
pip install packbits --no-cache-dir
The error says packbits
is not properly installed.
Thank you. I tried that too, but it still generates an error.
I was finally able to fix it by changing \StabilityMatrix\Data\Packages\Stable Diffusion WebUI\venv\Lib\site-packages\pytoshop\codecs.py line 25 from:
from . import packbits # type: ignore
to:
import packbits # type: ignore
This solution was mentioned here: https://github.com/mdboom/pytoshop/issues/9#issuecomment-534904333
Thanks. Fixed requirements in #26. If anyone still face the error, please re-open.
Error while restarting UI after Installation
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu. [AddNet] Updating model hashes... [AddNet] Updating model hashes... dirname: D:\NouvelAi\localizations localizations: {'zh_CN': 'D:\NouvelAi\extensions\stable-diffusion-webui-localization-zh_CN\localizations\zh_CN.json'} ControlNet preprocessor location: D:\NouvelAi\extensions\sd-webui-controlnet\annotator\downloads 2023-12-14 09:59:43,833 - ControlNet - INFO - ControlNet v1.1.422 2023-12-14 09:59:43,982 - ControlNet - INFO - ControlNet v1.1.422 Installing Layer Divider Extension: Installing segment-anything Installing Layer Divider Extension: Installing opencv-python Installing Layer Divider Extension: Installing pytoshop==1.1.0 INFO:root:running build_ext INFO:root:building 'pytoshop.packbits' extension INFO:root:"E:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -ID:\NouvelAi\py310\include -ID:\NouvelAi\py310\Include "-IE:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IE:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" /TcD:\NouvelAi\py310\Lib\site-packages\pytoshop\packbits.c /Fobuild\temp.win-amd64-cpython-310\Release\NouvelAi\py310\Lib\site-packages\pytoshop\packbits.obj packbits.c D:\NouvelAi\py310\Lib\site-packages\pytoshop\packbits.c(29): fatal error C1083: �������ļ�: ��Python.h��: No such file or directory error: command 'E:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe' failed with exit code 2