huchenlei / sd-webui-api-payload-display

Display the corresponding API payload after each generation on WebUI
MIT License
160 stars 18 forks source link

Image masks? #14

Closed silentpatrik closed 7 months ago

silentpatrik commented 7 months ago

When choosing an image mask and uploading it through img2img, inpaint upload the mask is not visible in the ouput, or maybe this is correct? (Trying to figure out how to attach masks to api when i noticed this, but im a novice so dont feel ashamed to close and trash this issue.)

huchenlei commented 7 months ago

The mask is merged as a part of init_images object when A1111 handles the input payload, so in the payload dump you don't see mask as a standalone parameter. There is a mask parameter you can attach on base A1111 payload.

See following A1111 API endpoint.

    def img2imgapi(self, img2imgreq: models.StableDiffusionImg2ImgProcessingAPI):
        init_images = img2imgreq.init_images
        if init_images is None:
            raise HTTPException(status_code=404, detail="Init image not found")

        mask = img2imgreq.mask
        if mask:
            mask = decode_base64_to_image(mask)
silentpatrik commented 7 months ago

yea, i figured it out. I actually provide a mask key in the root of the apibody and it works, would have saved me a little time if the mask variable was in the request initially. But all is good