Kandinsky 2 2 Inpaint

KANDINSKY_2_2_INPAINT

Kandinsky 2.2 inpainting: paints the masked part of a photo from a text prompt and leaves the rest untouched.

Image Editinginpaintingmaskkandinskyapache-2.0
Kandinsky 2 2 Inpaint: Image Editing model on Kainguru

About Kandinsky 2 2 Inpaint

Fills a masked region of a photo from a text prompt. Kandinsky 2.2 is a text-conditional diffusion model: a prior maps the prompt into image embeddings, and an inpaint decoder paints the masked pixels. White in the mask is the region to repaint.

The weights are kandinsky-community/kandinsky-2-2-decoder-inpaint at revision db790ad5cbcabed886f069ef2710774657621702 and kandinsky-community/kandinsky-2-2-prior at revision 9fc51ad5732afc5d031724219d22e6c42179c5a8. Both cards state the licence as Apache-2.0. The model was created by Arseniy Shakhmatov, Anton Razzhigaev, Aleksandr Nikolich, Igor Pavlov, Andrey Kuznetsov and Denis Dimitrov (the prior card's BibTeX also names Vladimir Arkhipkin).

Generation settings

Taken from the decoder card's "Text Guided Inpainting Generation" example at the pinned revision:

pipe = AutoPipelineForInpainting.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder-inpaint", torch_dtype=torch.float16
)
pipe.enable_model_cpu_offload()

prompt = "a hat"
# mask is 1 (white) where the image should be repainted
out = pipe(
    prompt=prompt,
    image=init_image,
    mask_image=mask,
    height=768,
    width=768,
    num_inference_steps=150,
)

The card says white pixels are the masked area (a change from older Kandinsky builds, where black was the mask). This project follows that convention.

The same example does not pass guidance_scale or a negative prompt. The decoder and prior pipelines default guidance to 4.0, and that is the guidance used here for both. The prior card's text-to-image example uses the negative prompt low quality, bad quality, and that phrase is the negative-prompt default. The prior's own step count is 25 (its pipeline default). The inpaint example does not set it.

The example asks for 150 decoder steps. Requests here accept 1 to 50 steps, so the default is 50. The example also calls CPU offload, and so does this project: each network moves to the GPU only while it runs.

The example paints at 768 x 768. A request uses the photo's own size, reduced so both sides are multiples of 64 and at most 1024. The saved PNG is the original photo size.

The same photo, mask, prompt, negative prompt, steps, guidance and seed produce the same image. Seed -1 draws a seed in 0 … 2147483647 and prints it as [kandinsky-2-2-inpaint] seed=....

Hardware

Runs on an NVIDIA A100 slice of class mig2g: 20 GB of GPU memory and 24 GiB of RAM. Both networks load in float16 with model CPU offload, so they wait in RAM (about 10 GB, which is why the 12 GiB mig1g class is too small) and only the network that is running sits on the GPU. A photo around 768 pixels at 50 decoder steps usually finishes in about a minute on that slice, plus a short prior pass of 25 steps. A smaller photo is faster. 50 steps is the slowest request this slice accepts.

Limits

One image per request. The photo and the mask must be the same size, at most 20 MB each, and at most 4096 pixels on a side. The working image is at most 1024 pixels on a side, so a larger photo is reduced and the result is scaled back. The prompt cannot be longer than 1000 characters, and the negative prompt cannot be longer than 500. Steps outside 1–50, guidance outside 0–15, and a seed outside -1 … 2147483647 are refused. The model paints only where the mask is white. It can miss fine text, counts, and anatomy. It does not return a video. The weights are public and permissively licensed; do not use the output to impersonate a real person.

Kandinsky 2 2 Inpaint inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—Photo to edit. At most 20 MB and 4096 pixels on a side. Working size is at most 1024, multiples of 64.
image/jpeg, png, webp
maskfileYes—Mask the same size as the photo. White is the region to repaint.
prompttextYes—What to paint in the white region of the mask.
Max 1000 characters
negative_prompttextNolow quality, bad qualityWhat the painted region should avoid. The prior card's text-to-image example uses this phrase.
Max 500 characters
num_inference_stepsintegerNo50Decoder steps. The model card's inpaint example uses 150; 50 is the maximum here.
1–50
guidance_scalenumberNo4.0Guidance for the prior and the decoder. The inpaint example omits this; 4.0 is the pipeline default.
0–15
seedintegerNo-1Repeat a previous result. Leave at -1 for a new one each time.
-1–2147483647

Output. Returns binary file.

Run Kandinsky 2 2 Inpaint with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=KANDINSKY_2_2_INPAINT" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "mask": "https://example.com/input.png",
    "prompt": "example",
    "guidance_scale": 4.0,
    "negative_prompt": "low quality, bad quality",
    "num_inference_steps": 50,
    "seed": -1
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "KANDINSKY_2_2_INPAINT",
        {
          "image": "https://example.com/input.png",
          "mask": "https://example.com/input.png",
          "prompt": "example",
          "guidance_scale": 4.0,
          "negative_prompt": "low quality, bad quality",
          "num_inference_steps": 50,
          "seed": -1
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Kandinsky 2 2 Inpaint pricing

Price per request: 4.076 credits ($0.04076). The price is shown again before every run; all prices are on the pricing page.

Licence and source

Kandinsky 2 2 Img2img: Image Editing model on Kainguru
Image Editing

Kandinsky 2 2 Img2img

Kandinsky 2.2 restyles a photo from a text prompt and keeps its layout; the strength sets how far the result moves…

LaMa: Image Editing model on Kainguru
Image Editing

LaMa

Removes objects, text, watermarks and blemishes from a photo: paint what to remove white on a black mask, and it fills…

Fine-tunable
Qwen-Image-Edit-2509: Image Editing model on Kainguru
Image Editing

Qwen-Image-Edit-2509

Edit a picture from a written instruction, changing objects, people, text or style while keeping the rest consistent.

Fine-tunable
DDColor: Image Editing model on Kainguru
Image Editing

DDColor

Colourises black-and-white and faded photos: it keeps each photo's own light and shade and adds natural colours.

Fine-tunable
LDSR: Image Editing model on Kainguru
Image Editing

LDSR

Enlarges a small picture 4 times with latent diffusion, drawing in new plausible detail. A creative upscale: richer…

Fine-tunable
LongCat Image Edit: Image Editing model on Kainguru
Image Editing

LongCat Image Edit

Edits a picture from an instruction in English or Chinese with LongCat-Image-Edit (6B, Apache-2.0): local and global…

Fine-tunable