Skip to main content

Image To Inpaint

Perform inpainting on an image directly without diffusion

First, let's generate an image to be processed.

Request Body:

{"requestId":"unique_key", "stages":[{"type":"INPUT_INITIALIZE", "inputInitialize":{"seed":"933011881", "count":1}}, {"type":"DIFFUSION", "diffusion":{"width":512, "height":768, "prompts":[{"text":"wide shot"}, {"text":"(depth of field)"}, {"text":"global illumination"}, {"text":"soft shadows"}, {"text":"grand scene"}, {"text":"backlight"}, {"text":"lens flare"}, {"text":"((colorful refraction))"}, {"text":"((cinematic lighting))"}, {"text":"in the market"}, {"text":"looking outside"}, {"text":"with butterfly"}, {"text":"1girl with lightblue long hair and blue aqua eyes"}, {"text":"hair flowers"}, {"text":"hime cut"}, {"text":"sunlight"}, {"text":"blurry background"}, {"text":"blurry"}, {"text":"White Dress"}, {"text":"full of flowers"}, {"text":"light bule butterfly"}, {"text":" from side"}, {"text":"floating hair"}], "negativePrompts":[{"text":" (worst quality"}, {"text":" low quality:1.4)"}, {"text":" negative_hand Negative Embedding"}, {"text":"verybadimagenegative_v1.3"}, {}], "sdModel":"681693017352010007", "sdVae":"None", "sampler":"DPM++ 3M SDE Karras", "steps":25, "cfgScale":5, "clipSkip":2, "denoisingStrength":0.4, "lora":{}}}, {"type":"IMAGE_TO_UPSCALER", "imageToUpscaler":{"hrUpscaler":"4x-AnimeSharp", "hrResizeX":1536, "hrResizeY":2304, "hrSecondPassSteps":10, "denoisingStrength":0.4}}]}
tip

Please remember to replace the 'requestId' in the request with your own unique ID.

We have obtained an image

Then we need a mask image

You can use some image editing tools to draw a black background image and paint the parts that need to be redrawn in white.

tip

Remember that the mask image format should be JPEG, and the resolution of the mask image should be exactly the same as that of the original image.

Let's do a partial redraw of the face and get a masked image that has the face region selected.

Perform inpainting

Our goal is to redraw the face with a crying expression, red pupils, and eyes. The structure of inpainting is:

{
"imageToInpaint": {
"resizeMode": "JUST_RESIZE",
"maskImageResourceId": "48203af7-6b07-4f1c-8506-f3f545613653",
"maskBlur": 4,
"inpaintingFill": "ORIGINAL",
"inpaintFullRes": true,
"inpaintFullResPadding": 32,
"diffusion": {
"width": 512,
"height": 768,
"prompts": [
{
"text": "crying"
},
{
"text": " (red eyes:1.5)"
}
],
"negativePrompts": [
{
"text": " (worst quality, low quality:1.4)"
},
{
"text": " negative_hand Negative Embedding"
},
{
"text": "verybadimagenegative_v1.3"
},
{}
],
"sdModel": "681693017352010007",
"sdVae": "None",
"sampler": "DPM++ 3M SDE Karras",
"steps": 25,
"cfgScale": 5,
"clipSkip": 2,
"denoisingStrength": 0.4,
"lora": {}
}
}
}

Complete request example:

{"requestId":"685205102316761513","stages":[{"type":"INPUT_INITIALIZE","inputInitialize":{"seed":"-1","imageResourceId":"67f8de0b-4949-4f88-abb4-cf57b16459da","count":1}},{"type":"IMAGE_TO_INPAINT","imageToInpaint":{"resizeMode":"JUST_RESIZE","maskImageResourceId":"48203af7-6b07-4f1c-8506-f3f545613653","maskBlur":4,"inpaintingFill":"ORIGINAL","inpaintFullRes":true,"inpaintFullResPadding":32,"diffusion":{"width":512,"height":768,"prompts":[{"text":"crying"},{"text":" (red eyes:1.5)"}],"negativePrompts":[{"text":" (worst quality"},{"text":" low quality:1.4)"},{"text":" negative_hand Negative Embedding"},{"text":"verybadimagenegative_v1.3"},{}],"sdModel":"681693017352010007","sdVae":"None","sampler":"DPM++ 3M SDE Karras","steps":25,"cfgScale":5,"clipSkip":2,"denoisingStrength":0.4,"lora":{}}}}]}

The final resulting image is as follows: