Stability-AI / stablediffusion

High-Resolution Image Synthesis with Latent Diffusion Models
MIT License
39.26k stars 5.06k forks source link

can't decode multipart body #358

Open sbkobaidze opened 9 months ago

sbkobaidze commented 9 months ago

Hey,

I am trying to upscale image using API and I'm passing base64 png image without head, but I'm still getting this error {"id":"60fed0801d25b2362f63365c8dbd1d5d","message":"can't decode multipart body","name":"bad_request"} here's the code

export const sdxlUpscale = async ({
  imageString,
  width,
}: {
  imageString: string
  width: number
    }) => {
  //   const req = await fetch(imageUrl)

  //   console.log(imageUrl)

  //   const blob = await req.arrayBuffer()
  //   console.log(blob)
  const formData = new FormData()
  formData.append("image", imageString)
  formData.append("width", 1024)
  const response = await fetch(
    `${apiHost}/v1/generation/esrgan-v1-x2plus/image-to-image/upscale`,
    {
      method: "POST",
      headers: {
        "Content-Type": "multipart/form-data",
        Accept: "image/png",

        Authorization: `Bearer ${apiKey}`,
      },
      body: formData,
    }
  )

  if (!response.ok) {
    throw new Error(`Non-200 response: ${await response.text()}`)
  }

  const data = await response.json()

  return data
}
ripon52 commented 7 months ago

i am also facing the same error for the text-to-image

eric-aerrober commented 7 months ago

Same, the example on the docs is broken