Skip to content

[Bug]: Invalid padding for returned base64 image from API #3972

@aliencaocao

Description

@aliencaocao

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

This only happened after I updated my repo to

I can confirm that on 737eb28 it is all good.

Steps to reproduce the problem

My code uses the API for txt2img like this:

for i in response['images']:
    return Image.open(io.BytesIO(base64.b64decode(i)))

What should have happened?

No error

Commit where the problem happens

911a345

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--force-enable-xformers --listen --deepdanbooru --api --nowebui --disable-safe-unpickle --opt-channelslast

Additional information, context and logs

File "C:\Users\alien\Documents\PyCharm-Projects\koala-music\stable_diffusion.py", line 158, in imagine
    image = generate(**args)
  File "C:\Users\alien\Documents\PyCharm-Projects\koala-music\stable_diffusion.py", line 87, in generate
    return Image.open(io.BytesIO(base64.b64decode(i))), response['info']['infotexts']  # remove when adding support for multiple images
  File "C:\Program Files\Python39\lib\base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (1098649) cannot be 1 more than a multiple of 4

Image generation from the webui works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-reportReport of a bug, yet to be confirmed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions