kurtvalcorza/kandinsky-inpainting-pipeline

Python

0

23 commits

updated Oct 4, 2026

See the code

README

Kandinsky 2.2 Inpainting Pipeline

A DIMER pipeline for two-stage image inpainting with kandinsky-community/kandinsky-2-2-decoder-inpaint and the shared Kandinsky 2.2 prior. It provides immutable snapshot verification, prompt-embedding caching, masked generation, preservation metrics, bounded LoRA adaptation, and portable safetensors artifacts.

Pinned components

ComponentRevision
kandinsky-community/kandinsky-2-2-decoder-inpaintdb790ad5cbcabed886f069ef2710774657621702
kandinsky-community/kandinsky-2-2-prior9fc51ad5732afc5d031724219d22e6c42179c5a8
laion/CLIP-ViT-B-32-laion2B-s34B-b79K1a25a446712ba5ee05982a381eed697ef9b435cf

Each snapshot is accepted only when every manifest entry matches its recorded byte count and SHA-256 digest. Executable and pickle-based model files are rejected.

Development setup

Python 3.12 is required.

uv venv --python 3.12 .venv
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
.venv\Scripts\python.exe -m pytest -q
.venv\Scripts\python.exe -m ruff check .

The package validates records before importing Torch, Diffusers, Transformers, or PEFT. An inpainting record contains id, image, caption, and optionally mask_image (255 = repaint, 0 = keep); a deterministic center mask (the middle half of each side) is used when the mask is omitted. Images and masks are resized together and center-cropped to 512 x 512. load_byod_dataset() reads a directory or zip holding captions.csv (id, file, caption, optional mask) beside the image and mask files.

evaluate() and adapt() give the UNet the same nine-channel input as the diffusers inpainting pipeline: noisy latents, masked latents, and a keep-mask channel (unet_keep_mask(), 1 = keep). The prior's sampler is seeded per caption with prompt_seed(), the first four bytes of the caption's SHA-256.

Weights

Large tensors are intentionally excluded from Git. The repository commits only manifests and small upstream configuration, tokenizer, and model-card files under weights/. Use the staging helpers with allow_download=True to fetch missing files at the pinned revisions.

Adaptation artifacts

LoRA adaptation targets only the UNet attention projections. The LoRA tensors stay in float32; on CUDA training uses float16 autocast with a gradient scaler. save_artifact() writes adapter.safetensors and a digest-bound manifest.json; load_adapter() rejects altered weights or a mismatched base-model identity.

Tutorial

Open In Colab

tutorials/kandinsky_inpainting_colab.ipynb is declared E2E / GUIDED and is standalone (DIMER Notebook Specification 2.2 §4): it is generated by tools/build_notebook.py from tools/notebook_template.py and carries, byte for byte and SHA-256-verified, the package's four modules, the stage runner tools/tutorial_stages.py, the hash-locked requirements tutorials/requirements-colab.lock.txt, the three snapshot manifests and the licence. Regenerate it with python tools/build_notebook.py; never edit it by hand. The model card is MODEL_CARD.md (DIMER Model Card Specification 1.2); weight provenance is in docs/WEIGHTS.md.

The notebook installs nothing into its own kernel. It downloads a pinned uv wheel (checked by size and SHA-256), builds an isolated CPython 3.12.12 environment, and installs the lock into it with --require-hashes --only-binary :all:; each stage (weights, prepare, encode, frozen, adapt, evaluate, reload, then the activity) runs in its own process and hands results to the next only through files. A hosted runtime's preloaded packages are never replaced, so Run all needs no restart. The lock is compiled from the pyproject.toml pins for Colab and Kaggle (uv pip compile pyproject.toml --python-version 3.12 --python-platform x86_64-manylinux_2_28 --generate-hashes --index-url https://pypi.org/simple --only-binary :all: -o tutorials/requirements-colab.lock.txt); recompile it and regenerate the notebook whenever a pin changes.

Release status

Candidate — the tutorial notebook was regenerated after the 2026-10-02 notebook review (explanations, the original-photograph reference, the BYOD minimum and small printed outputs changed), so the hosted records belong to its previous revision. That revision runs in an isolated hash-locked environment and passed Run all in one pass on Google Colab and on a strict Kaggle T4 run, plus the REL12 BYOD journey, at 507e06d. The current revision (7008428) passed one Colab CLI sequential execution on a fresh Colab T4 (2026-10-05, 11/11 code cells, 0 errors); a strict Run all and the BYOD journey of this revision are needed before it is promoted again. See docs/release-verification.md and STATUS.md.

License

Repository code is licensed under Apache-2.0. Upstream model and sample-data licenses remain governed by their respective sources and are recorded in the committed model cards and dataset metadata.

AI assistance disclosure

Development used AI-assisted implementation and review. Tests, pinned identities, manifests, and source files remain the authoritative evidence.

kurtvalcorza/kandinsky-inpainting-pipeline

Python

0

23 commits

updated Oct 4, 2026

See the code

README

Kandinsky 2.2 Inpainting Pipeline

A DIMER pipeline for two-stage image inpainting with kandinsky-community/kandinsky-2-2-decoder-inpaint and the shared Kandinsky 2.2 prior. It provides immutable snapshot verification, prompt-embedding caching, masked generation, preservation metrics, bounded LoRA adaptation, and portable safetensors artifacts.

Pinned components

ComponentRevision
kandinsky-community/kandinsky-2-2-decoder-inpaintdb790ad5cbcabed886f069ef2710774657621702
kandinsky-community/kandinsky-2-2-prior9fc51ad5732afc5d031724219d22e6c42179c5a8
laion/CLIP-ViT-B-32-laion2B-s34B-b79K1a25a446712ba5ee05982a381eed697ef9b435cf

Each snapshot is accepted only when every manifest entry matches its recorded byte count and SHA-256 digest. Executable and pickle-based model files are rejected.

Development setup

Python 3.12 is required.

uv venv --python 3.12 .venv
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
.venv\Scripts\python.exe -m pytest -q
.venv\Scripts\python.exe -m ruff check .

The package validates records before importing Torch, Diffusers, Transformers, or PEFT. An inpainting record contains id, image, caption, and optionally mask_image (255 = repaint, 0 = keep); a deterministic center mask (the middle half of each side) is used when the mask is omitted. Images and masks are resized together and center-cropped to 512 x 512. load_byod_dataset() reads a directory or zip holding captions.csv (id, file, caption, optional mask) beside the image and mask files.

evaluate() and adapt() give the UNet the same nine-channel input as the diffusers inpainting pipeline: noisy latents, masked latents, and a keep-mask channel (unet_keep_mask(), 1 = keep). The prior's sampler is seeded per caption with prompt_seed(), the first four bytes of the caption's SHA-256.

Weights

Large tensors are intentionally excluded from Git. The repository commits only manifests and small upstream configuration, tokenizer, and model-card files under weights/. Use the staging helpers with allow_download=True to fetch missing files at the pinned revisions.

Adaptation artifacts

LoRA adaptation targets only the UNet attention projections. The LoRA tensors stay in float32; on CUDA training uses float16 autocast with a gradient scaler. save_artifact() writes adapter.safetensors and a digest-bound manifest.json; load_adapter() rejects altered weights or a mismatched base-model identity.

Tutorial

Open In Colab

tutorials/kandinsky_inpainting_colab.ipynb is declared E2E / GUIDED and is standalone (DIMER Notebook Specification 2.2 §4): it is generated by tools/build_notebook.py from tools/notebook_template.py and carries, byte for byte and SHA-256-verified, the package's four modules, the stage runner tools/tutorial_stages.py, the hash-locked requirements tutorials/requirements-colab.lock.txt, the three snapshot manifests and the licence. Regenerate it with python tools/build_notebook.py; never edit it by hand. The model card is MODEL_CARD.md (DIMER Model Card Specification 1.2); weight provenance is in docs/WEIGHTS.md.

The notebook installs nothing into its own kernel. It downloads a pinned uv wheel (checked by size and SHA-256), builds an isolated CPython 3.12.12 environment, and installs the lock into it with --require-hashes --only-binary :all:; each stage (weights, prepare, encode, frozen, adapt, evaluate, reload, then the activity) runs in its own process and hands results to the next only through files. A hosted runtime's preloaded packages are never replaced, so Run all needs no restart. The lock is compiled from the pyproject.toml pins for Colab and Kaggle (uv pip compile pyproject.toml --python-version 3.12 --python-platform x86_64-manylinux_2_28 --generate-hashes --index-url https://pypi.org/simple --only-binary :all: -o tutorials/requirements-colab.lock.txt); recompile it and regenerate the notebook whenever a pin changes.

Release status

Candidate — the tutorial notebook was regenerated after the 2026-10-02 notebook review (explanations, the original-photograph reference, the BYOD minimum and small printed outputs changed), so the hosted records belong to its previous revision. That revision runs in an isolated hash-locked environment and passed Run all in one pass on Google Colab and on a strict Kaggle T4 run, plus the REL12 BYOD journey, at 507e06d. The current revision (7008428) passed one Colab CLI sequential execution on a fresh Colab T4 (2026-10-05, 11/11 code cells, 0 errors); a strict Run all and the BYOD journey of this revision are needed before it is promoted again. See docs/release-verification.md and STATUS.md.

License

Repository code is licensed under Apache-2.0. Upstream model and sample-data licenses remain governed by their respective sources and are recorded in the committed model cards and dataset metadata.

AI assistance disclosure

Development used AI-assisted implementation and review. Tests, pinned identities, manifests, and source files remain the authoritative evidence.