[GH-ISSUE #25] TypeError: a bytes-like object is required, not 'str' #17

Closed
opened 2026-10-30 21:08:24 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @Json-exe on GitHub (Jun 26, 2023).
Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/25

When trying to do anything with this extension I get the error TypeError: a bytes-like object is required, not 'str'. Does anyone have a solution for this problem? Or maybe someone has the same problem?

Originally created by @Json-exe on GitHub (Jun 26, 2023). Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/25 When trying to do anything with this extension I get the error TypeError: a bytes-like object is required, not 'str'. Does anyone have a solution for this problem? Or maybe someone has the same problem?
Author
Owner

@mdkberry commented on GitHub (Jun 29, 2023):

Yes but I only get that error message when I try to Send it img2img, or inpaint, or extras.

It still works to remove backgrounds before and after the error message, but it wont send anywwhere. so I have to open the image in a browser tab and save it manually and then reload it elsewhere.

I am using it installed from the Extensions tab inside SD which is running in Conda environment on Windows 10.

version: stable-diffusion-webui-rembg | https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git | master | 3d9eedbb | Sun Jun 4 13:35:24 2023

here is my error:

Traceback (most recent call last):
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
data = self.postprocess_data(fn_index, result["prediction"], state)
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1260, in postprocess_data
prediction_value = block.postprocess(prediction_value)
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 1864, in postprocess
return processing_utils.encode_pil_to_base64(y)
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 85, in encode_pil_to_base64
bytes_data = encode_pil_to_bytes(pil_image)
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 80, in encode_pil_to_bytes
pil_image.save(output_bytes, format, pnginfo=get_pil_metadata(pil_image))
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\Image.py", line 2432, in save
save_handler(self, fp, filename)
File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1318, in _save
data = name + b"\0\0" + zlib.compress(icc)
TypeError: a bytes-like object is required, not 'str'

<!-- gh-comment-id:1612381314 --> @mdkberry commented on GitHub (Jun 29, 2023): Yes but I only get that error message when I try to Send it img2img, or inpaint, or extras. It still works to remove backgrounds before and after the error message, but it wont send anywwhere. so I have to open the image in a browser tab and save it manually and then reload it elsewhere. I am using it installed from the Extensions tab inside SD which is running in Conda environment on Windows 10. version: stable-diffusion-webui-rembg | https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git | master | 3d9eedbb | Sun Jun 4 13:35:24 2023 here is my error: > > Traceback (most recent call last): > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict > output = await app.get_blocks().process_api( > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api > data = self.postprocess_data(fn_index, result["prediction"], state) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1260, in postprocess_data > prediction_value = block.postprocess(prediction_value) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 1864, in postprocess > return processing_utils.encode_pil_to_base64(y) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 85, in encode_pil_to_base64 > bytes_data = encode_pil_to_bytes(pil_image) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 80, in encode_pil_to_bytes > pil_image.save(output_bytes, format, pnginfo=get_pil_metadata(pil_image)) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\Image.py", line 2432, in save > save_handler(self, fp, filename) > File "C:\Users\admin\Documents\Python\stablediffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1318, in _save > data = name + b"\0\0" + zlib.compress(icc) > TypeError: a bytes-like object is required, not 'str'
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AUTOMATIC1111/stable-diffusion-webui-rembg#17
No description provided.