Inpainting
Inpainting
POST https://api.novita.ai/v3/async/inpainting
Inpainting is a conservation process in which damaged, deteriorated, or missing parts of an artwork are filled in to present a complete image.
This is an asynchronous API; only the task_id will be returned. You should use the task_id to request the Task Result API to retrieve the image generation results.
Example
I have no mask
images. How do I generate mask
parameters in the body?
You can use our playground to get the mask base64 information. Please be aware that mask images should have the same resolution as the input images. Guidance can be found here: Click Here
I already have mask images. How do I convert mask
images to base64?
You can use the following code to convert mask images to base64.
import base64
# mask files path
filename_input = "mask_edited.png"
# read mask file
with open(filename_input, "rb") as f:
base64_pic = base64.b64encode(f.read()).decode("utf-8")
# write mask file
with open("input.txt", "w") as f:
f.write(base64_pic)
Start requesting inpainting.
Please set the Content-Type
header to application/json
in your HTTP request to indicate that you are sending JSON data. Currently, only JSON format is supported.
"model_name":"realisticVisionV40_v40VAE-inpainting_81543.safetensors"
in body represent inpainting models, which, can be accessed in API /v3/model with sd_name
like %inpainting%.
Request:
curl --location --request POST 'http://api.novita.ai/v3/async/inpainting' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{API Key}}' \
--data-raw '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"model_name": "realisticVisionV40_v40VAE-inpainting_81543.safetensors",
"prompt": "Leonardo DiCaprio",
"negative_prompt": "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, BadDream, UnrealisticDream",
"image_num": 1,
"steps": 25,
"seed": -1,
"clip_skip": 1,
"guidance_scale": 7.5,
"sampler_name": "Euler a",
"mask_blur": 1,
"inpainting_full_res": 1,
"inpainting_full_res_padding": 32,
"inpainting_mask_invert": 0,
"initial_noise_multiplier": 1,
"strength": 0.85,
"image_base64": "{{base64 encoded image}}",
"mask_image_base64": "{{base64 encoded mask image}}"
}
}'
Response:
{
"code": 0,
"msg": "",
"data": {
"task_id": "270f4fba-2cb0-4a56-8b82-xxxx"
}
}
````"model_name":"realisticVisionV40_v40VAE-inpainting_81543.safetensors"` in body represent inpainting models, which, can be accessed in API /v3/model with `sd_name` like %inpainting%.
`Request:`
```bash
curl --location --request POST 'http://api.novita.ai/v3/async/inpainting' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{API Key}}' \
--data-raw '{
"extra": {
"response_image_type": "jpeg"
},
"request": {
"model_name": "realisticVisionV40_v40VAE-inpainting_81543.safetensors",
"prompt": "Leonardo DiCaprio",
"negative_prompt": "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, BadDream, UnrealisticDream",
"image_num": 1,
"steps": 25,
"seed": -1,
"clip_skip": 1,
"guidance_scale": 7.5,
"sampler_name": "Euler a",
"mask_blur": 1,
"inpainting_full_res": 1,
"inpainting_full_res_padding": 32,
"inpainting_mask_invert": 0,
"initial_noise_multiplier": 1,
"strength": 0.85,
"image_base64": "{{base64 encoded image}}",
"mask_image_base64": "{{base64 encoded mask image}}"
}
}'
Response:
{
"code": 0,
"msg": "",
"data": {
"task_id": "270f4fba-2cb0-4a56-8b82-xxxx"
}
}