djbielejeski / a-person-mask-generator

Extension for Automatic1111 and ComfyUI to automatically create masks for Background/Hair/Body/Face/Clothes in Img2Img
MIT License
247 stars 30 forks source link

API support #9

Closed MitPitt closed 8 months ago

MitPitt commented 8 months ago

Would be insanely useful to me.

djbielejeski commented 8 months ago

That already works, just include this in your post body

"alwayson_scripts": {
        "A Person Mask Generator": {
            "args": [
                true,
                [
                    "hair"
                ],
                true,
                4,
                0,
                1,
                0,
                32
            ]
        }
    }

Here is an example request

{
    "prompt": "red hair",
    "negative_prompt": "",
    "styles": [],
    "seed": -1,
    "subseed": -1,
    "subseed_strength": 0,
    "seed_resize_from_h": -1,
    "seed_resize_from_w": -1,
    "sampler_name": "Euler",
    "batch_size": 1,
    "n_iter": 1,
    "steps": 30,
    "cfg_scale": 7,
    "width": 512,
    "height": 704,
    "restore_faces": false,
    "tiling": false,
    "do_not_save_samples": false,
    "do_not_save_grid": false,
    "eta": 0,
    "denoising_strength": 0.75,
    "s_min_uncond": 0,
    "s_churn": 0,
    "s_tmax": 0,
    "s_tmin": 0,
    "s_noise": 0,
    "override_settings": {},
    "override_settings_restore_afterwards": true,
    "refiner_checkpoint": "sd_xl_base_1.0_0.9vae.safetensors",
    "refiner_switch_at": 0,
    "disable_extra_networks": false,
    "comments": {},
    "init_images": ["data:image/png;base64,iVB...snipped..."],
    "resize_mode": 0,
    "image_cfg_scale": 0,
    "mask": "",
    "mask_blur_x": 4,
    "mask_blur_y": 4,
    "mask_blur": 0,
    "inpainting_fill": 0,
    "inpaint_full_res": true,
    "inpaint_full_res_padding": 0,
    "inpainting_mask_invert": 0,
    "initial_noise_multiplier": 0,
    "latent_mask": "",
    "sampler_index": "Euler",
    "include_init_images": false,
    "script_name": "",
    "script_args": [],
    "send_images": true,
    "save_images": false,
    "alwayson_scripts": {
        "A Person Mask Generator": {
            "args": [
                true,
                [
                    "hair"
                ],
                true,
                4,
                0,
                1,
                0,
                32
            ]
        }
    }
}

And all the options

// Args
[
    // Value (boolean): true/false.  Description: Use the extension or not
    enabled,

    // Value (string[]): ['background', 'hair', 'body (skin)', 'face (skin)', 'clothes'].  Description: List of masks you want to generate
    mask_targets,

    // Value (boolean): true/false.  Description: Override img2img settings
    override_inpaint_enabled, 

    // Value (int): 0 - 64. Description: Mask pixel blur.
    mask_blur,

    // Value (int): 0=dont invert, 1=invert the mask
    inpainting_mask_invert,

    // Value (int): 0='fill', 1='original', 2='latent noise', 3='latent nothing'.
    inpainting_fill,

    // Value (int): 0='Whole picture', 1='Only masked'
    inpaint_full_res,

    // Value (int): 0 - 256.  Description: Only masked padding, pixels.
    inpaint_full_res_padding,
]

example

{
    "A Person Mask Generator": {
        "args": [
            true,                       // enabled
            ['body (skin)', 'face (skin)'],     // mask_targets
            true,                       // override_inpaint_enabled
            4,                          // mask_blur
            0,                          // inpainting_mask_invert
            1,                          // inpainting_fill
            0,                          // inpaint_full_res
            32,                     // inpaint_full_res_padding
        ]
    }
}
slonce70 commented 6 months ago

Good afternoon, I use your parameters, scanned parameters in the browser, but does not work correctly!? In the browser everything is fine, through the api query it seems that denoising is underestimated, although it is 0.9 - in the browser everything is perfect.