stable-diffusion-webui-Layer-Divider icon indicating copy to clipboard operation
stable-diffusion-webui-Layer-Divider copied to clipboard

NameError: name 'packbits' is not defined

Open oliviea opened this issue 2 years ago • 12 comments

Using Automatic1111 image

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

oliviea avatar Apr 12 '23 06:04 oliviea

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.

jhj0517 avatar Apr 12 '23 10:04 jhj0517

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.

a-und-b avatar Apr 12 '23 11:04 a-und-b

I am using Windows

oliviea avatar Apr 12 '23 19:04 oliviea

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.

jaikydota avatar Apr 14 '23 07:04 jaikydota

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.~~

jhj0517 avatar Apr 15 '23 01:04 jhj0517

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.

jhj0517 avatar Apr 15 '23 05:04 jhj0517

pip install pytoshop==1.1.0 --no-cache-dir < done reinstall the extension < done

yet the error persists

lithatog avatar Apr 18 '23 16:04 lithatog

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.

Changesong avatar Apr 19 '23 09:04 Changesong

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 !!

jhj0517 avatar Apr 20 '23 17:04 jhj0517

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?

lithatog avatar Apr 25 '23 15:04 lithatog

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:

  1. pytoshop and pytoshop-1.1.0.dist-info
  2. pycocotools and pycocotools-2.0.6.dist-info

After removing these folders, try re-launching SD WebUI. Also, what is your OS that you're currently using?

jhj0517 avatar Apr 25 '23 21:04 jhj0517

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!

altoiddealer avatar Jun 01 '23 19:06 altoiddealer

Fixed requirements in #26. If anyone still face the error, please re-open.

jhj0517 avatar Jul 05 '24 07:07 jhj0517