Error

[Error] binascii.Error: Invalid base64-encoded string

nam-willow 2024. 12. 21. 01:39

오류

decode_base64_to_image() 메서드만 실행하면 계속 오류가 뜬다


■ decode_base64_to_image() | 동작시작 
*** Error running process: /경로/경로/extensions/sd-webui-controlnet/scripts/controlnet.py
    Traceback (most recent call last):
      File "/경로/경로/modules/api/api.py", line 466, in decode_base64_to_image
        image = Image.open(BytesIO(base64.b64decode(encoding)))
      File "/usr/lib/python3.10/base64.py", line 87, in b64decode
        return binascii.a2b_base64(s)
    binascii.Error: Incorrect padding

    The above exception was the direct cause of the following exception:

    (... 중간 생략)

decode_base64_to_image
        raise HTTPException(status_code=500, detail="Invalid encoded image") from e
    fastapi.exceptions.HTTPException: 500: Invalid encoded image

13:21:34 - ReActor - STATUS - Working: source face index [0], target face index [0]
*** Error running postprocess: /경로/경로/extensions/sd-webui-reactor/scripts/reactor_faceswap.py
    Traceback (most recent call last):
      File "/경로/경로/modules/scripts.py", line 654, in postprocess
        script.postprocess(p, processed, *script_args)
      File "/경로/경로/extensions/sd-webui-reactor/scripts/reactor_faceswap.py", line 297, in postprocess
        result, output, swapped = swap_face(
      File "/경로/경로/extensions/sd-webui-reactor/scripts/reactor_swapper.py", line 359, in swap_face
        img_bytes = base64.b64decode(source_img)
      File "/usr/lib/python3.10/base64.py", line 87, in b64decode
        return binascii.a2b_base64(s)
    binascii.Error: Invalid base64-encoded string: number of data characters (5) cannot be 1 more than a multiple of 4



원인, 해결

  • text2img를 실행하는 프로세스 였는데
  • payload를 사용할때 controlnet이랑 reactor를 사용을 true로 해놓은 payload를 사용해서 오류가 난거였음
  • false로 변경함*


오류를 확인해보면 내가 사용하지 않은 항목들에서 오류가 발생해서 해결할 수 있었음

★fastapi.exceptions.HTTPException: 500: Invalid encoded image
인코딩이 잘못되었다.

★File "/경로/경로/extensions/sd-webui-controlnet/scripts/controlnet.py", line 1073, in process
controlnet.py에서의 오류

★File "/경로/경로/extensions/sd-webui-reactor/scripts/reactor_faceswap.py", line 297, in postprocess
reactor_faceswap.py에서의 오류