stable-diffusion-webui-Layer-Divider
stable-diffusion-webui-Layer-Divider copied to clipboard
NameError: name 'packbits' is not defined
Using Automatic1111

File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict output = await app.get_blocks().process_api( File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api result = await self.call_function( File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function prediction = await anyio.to_thread.run_sync( File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\anyio_backends_asyncio.py", line 867, in run result = context.run(func, *args) File "F:\AnotherStableD\stable-diffusion-webui-master\extensions\stable-diffusion-webui-Layer-Divider\scripts\layer_divider_modules\sam.py", line 71, in generate_mask_app save_psd_with_masks(image, masks) File "F:\AnotherStableD\stable-diffusion-webui-master\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) File "F:\AnotherStableD\stable-diffusion-webui-master\extensions\stable-diffusion-webui-Layer-Divider\scripts\layer_divider_modules\mask_utils.py", line 92, in save_psd psd_file.write(output_file) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\core.py", line 269, in write self.layer_and_mask_info.write(fd, self) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\layers.py", line 1323, in write self.layer_info.write(fd, header) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\layers.py", line 1134, in write layer.write_channel_data(fd, header) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\layers.py", line 1037, in write_channel_data lengths.append(data.write(fd, header, shape)) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\layers.py", line 560, in write codecs.compress_image( File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\codecs.py", line 432, in compress_image return compressors[compression](fd, image, depth, version) File "F:\AnotherStableD\stable-diffusion-webui-master\venv\lib\site-packages\pytoshop\codecs.py", line 292, in compress_rle packed = packbits.encode(row) NameError: name 'packbits' is not defined
Hi. This pytoshop bug should have been fixed in #2, so it should no longer happen. Are using Windows? If the issue persists on other OS, I will have to use my own forked version of pytoshop.
If the issue persists on other OS, I will have to use my own forked version of pytoshop.
I can confirm that the issue persists on macOS.
I am using Windows
I executed this command in python venv
pip install pytoshop==1.1.0 -I --no-cache-dir
It works!
I see the console output
Successfully installed cython-0.29.34 numpy-1.24.2 pytoshop-1.1.0
It reinstalls new version of cython and numpy, i guess it's a problem with these two linked library versions.
I am using Windows
If you're using Windows, re-installing this extension should solve the issue. let me know if you still face same issue after reinstalling it.
pip install pytoshop==1.1.0 -I --no-cache-dir
Thanks. I hope this solution resolves the issue. However, in my case, I encountered another error
Could not install packages due to an OSError: [WinError 5] Access is denied.
~~I just made PR for this issue, but unfortunately, I cannot test whether it works or not since I don't have a macOS PC.~~
~~Can someone on macOS please test the fix-packbits-bug branch and see if it works?~~
~~You can download the repository as a zip file from~~ ~~https://github.com/jhj0517/stable-diffusion-webui-Layer-Divider/tree/fix-packbits-bug~~ ~~and unzip it in the extension folder.~~
Just forget about my previous answer.
pip install pytoshop==1.1.0 --no-cache-dir
should work fine without any problems, in macOS too.
I've updated the extension, Please reinstall the extension and let me know if you still encounter the same issue.
pip install pytoshop==1.1.0 --no-cache-dir < done reinstall the extension < done
yet the error persists
Same errors on Windows 10. I tried pip install pytoshop==1.1.0 --no-cache-dir and reinstall plugin, but neither method worked.
but after pip install pytoshop==1.1.0 -I --no-cache-dir , It works. idk why.
This error appears version conflict with python and cython. So I directly built packbits extension using cython, in #14
Please reinstall the extension, and let me know if you still encounter the same issue !!
reinstalled and error still there.
File "C:\Users\user\stable-diffusion-webui\venv\lib\site-packages\pytoshop\codecs.py", line 292, in compress_rle packed = packbits.encode(row) NameError: name 'packbits' is not defined Closing server running on port: 7860 Restarting UI... ControlNet v1.1.107 Running on local URL: http://127.0.0.1:7860
To create a public link, set share=True in launch().
Startup time: 1.2s (load scripts: 0.2s, create ui: 0.7s, gradio launch: 0.1s).
Closing server running on port: 7860
Restarting UI...
ControlNet v1.1.107
Installing Layer Divider Extension: Installing segment-anything
Installing Layer Divider Extension: Installing opencv-python
Installing Layer Divider Extension: Installing pytoshop==1.1.0
Running on local URL: http://127.0.0.1:7860
To create a public link, set share=True in launch().
Startup time: 6.4s (load scripts: 5.6s, create ui: 0.6s).
=================================
I noticed that in your requirement.txt there is "pycocotools" but seems it's not included?
Hi @lithatog . you may need to remove old dependencies of this extension from SD webui, and re-launch the WebUI.
please go to your\SDWebUI\path\venv\lib\site-packages\ folder,
and remove the following folders:
pytoshopandpytoshop-1.1.0.dist-infopycocotoolsandpycocotools-2.0.6.dist-info
After removing these folders, try re-launching SD WebUI. Also, what is your OS that you're currently using?
Ever since SD was updated to version 1.2 this extension would not work for me.
Until now, I activated venv and typed
pip install pytoshop==1.1.0 -I --no-cache-dir
...Works!
Fixed requirements in #26. If anyone still face the error, please re-open.