Instructions to use yijunwang2/krea2-anypaint with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use yijunwang2/krea2-anypaint with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("krea/Krea-2-Turbo", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("yijunwang2/krea2-anypaint") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- Krea 2 AnyPaint: Arbitrary-Mask Inpainting, Outpainting, and Image Editing
- At a glance
- Capabilities
- Showcase
- 01_photo_internal - Photographic internal edit
- 02_watercolor_outpaint - Watercolor downward outpainting
- 03_3d_outpaint - Stylized 3D horizontal outpainting
- 04_portrait_mixed - Original-character mixed edit
- 05_botanical_disconnected - Disconnected honeybee insertion
- 07_product_narrow - Narrow cable recolor
- 08_landscape_complex - Complex semantic landscape edit
- 09_male_accessories - Male portrait accessories
- 10_female_accessories - Female disconnected accessories
- 11_product_restyle - Shoes and bag local redesign
- 12_desk_objects - Two desktop object insertions
- 13_living_room_objects - Living-room multi-region insertion
- 14_window_view - Complete window-view replacement
- 15_person_boundary - Boundary completion of an adult man
- Input contract
- Recommended settings
- Usage
- How it works
- Limitations
- Responsible use
- License
- At a glance
Krea 2 AnyPaint: Arbitrary-Mask Inpainting, Outpainting, and Image Editing
Krea 2 AnyPaint provides arbitrary-mask inpainting, outpainting, and image editing for Krea 2 Turbo. One runtime handles internal edits, canvas extension, disconnected regions, narrow structures, and mixed masks that cross the source boundary.
Interactive ZeroGPU Space | ComfyUI nodes | Krea 2 functional adapters collection
At a glance
| Source | Generated mask | AnyPaint result |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Important: The Hugging Face auto-generated Diffusers snippet and ordinary LoRA importers are not compatible with this functional adapter. Use the included
example.py,pipeline.py, andanypaint.py.
Capabilities
- arbitrary-shape and freehand mask image editing;
- same-canvas inpainting;
- one-pass outpainting into a larger canvas;
- multiple disconnected edit regions;
- narrow, curved, and boundary-crossing masks;
- combined inpainting and outpainting in one request;
- preservation of unmasked regions through timestep-matched latent constraints.
White mask pixels are generated or edited. Black mask pixels are preserved. The helper also marks every pixel outside the placed source as generated, so the same input contract covers both inpainting and outpainting.
Showcase
All showcase sources are synthetic, generated from the unmodified Krea 2 base model with original prompts. They contain no real-person identity, brand, existing fictional character, or other third-party character IP. Each listed result is the first output from its recorded prompt and fixed seed; unsuccessful runs were not silently removed.
The release candidate includes a diverse fixed-seed set covering photographic,
illustrated, 3D, indoor, outdoor, object, and human-subject compositions. Every
case ships with its source, exact binary mask, output, and generation metadata
under showcase/.
Open the complete source / mask / result set and prompts
01_photo_internal - Photographic internal edit
Prompt: a sunlit modern kitchen interior with a handmade ceramic bowl of fresh lemons on the center island, coherent morning light, complete architectural photograph
02_watercolor_outpaint - Watercolor downward outpainting
Prompt: an original watercolor greenhouse and coastal garden, the path and flowering plants continuing naturally downward, airy washes, complete vertical composition
03_3d_outpaint - Stylized 3D horizontal outpainting
Prompt: an original retro-futuristic exploration rover crossing a colorful alien desert, distant mineral formations extending to the right, stylized 3D cinematic render
04_portrait_mixed - Original-character mixed edit
Prompt: an original adult woman with short silver hair wearing a richly textured coral coat in a spacious contemporary gallery, complete full-body fashion photograph
05_botanical_disconnected - Disconnected honeybee insertion
Prompt: an original botanical field illustration of blue and white meadow flowers with three small honeybees hovering naturally between the blossoms, delicate wings, fine paper texture, naturalistic painted details
07_product_narrow - Narrow cable recolor
Prompt: an original sculptural brushed aluminum desk lamp with a vivid orange braided power cable extending from the lamp across the tabletop, premium neutral product photography
08_landscape_complex - Complex semantic landscape edit
Prompt: an original alpine valley after rain with clusters of luminous rainbow-colored fantasy mushrooms growing along the winding riverbanks and foreground rocks, subtle magical glow reflected in wet stone, coherent wide cinematic landscape photograph
09_male_accessories - Male portrait accessories
Prompt: a realistic editorial portrait of an adult man with short dark hair wearing thin rectangular silver eyeglasses and a small silver ear cuff, plain navy shirt, coherent soft daylight and neutral studio background
10_female_accessories - Female disconnected accessories
Prompt: a polished portrait of an adult woman with shoulder-length auburn hair, a dark green enamel hair clip above her left ear and matching small geometric earrings, simple cream blouse, coherent natural daylight and pale gray studio background
11_product_restyle - Shoes and bag local redesign
Prompt: an overhead catalog photograph with a pair of deep forest-green suede sneakers on the left and a cobalt-blue structured leather shoulder bag on the right, refined minimal hardware, balanced composition, coherent soft studio shadows
12_desk_objects - Two desktop object insertions
Prompt: a clean oak writing desk in a softly lit home office with a handmade dark green ceramic mug on the left side and a small potted succulent in a matte white planter on the right, coherent restrained contemporary interior photograph
13_living_room_objects - Living-room multi-region insertion
Prompt: a bright neutral living room with a tall brushed-brass floor lamp beside the left end of the cream sofa and a round woven storage basket beside the right end, simple coffee table, coherent warm daylight and understated architectural photography
14_window_view - Complete window-view replacement
Prompt: a quiet contemporary reading room whose large central picture window overlooks a snowy mountain lake beneath a clear pale-blue winter sky, armchair in the foreground, coherent daylight, reflections and realistic interior photography
15_person_boundary - Boundary completion of an adult man
Prompt: a complete full-body photograph of an adult man wearing a charcoal field jacket, gray shirt, straight dark trousers and practical brown boots, standing naturally on a quiet railway platform in coherent soft cloudy daylight
Input contract
The runtime takes:
- one RGB source image;
- one binary mask, either source-sized or canvas-sized;
- an output canvas whose dimensions are multiples of 16;
- an optional source bounding box
(x0, y0, x1, y1)in output pixels; - a prompt describing the complete desired output image.
The source bounding box must stay inside the canvas and preserve the source aspect ratio. A source-sized mask is resized and placed with the source. A canvas-sized mask is used directly. Areas outside the source box are always generated.
The complete masked canvas is encoded as one maximum-edge-384 reference whose rotary coordinates cover the full target canvas. A full-resolution known image and keep mask separately preserve reliable unmasked latent tokens after every flow step. A 32-pixel boundary band is deliberately left for the model to redraw and blend. The returned image is the raw decoded model output; there is no hidden post-generation source composite.
Recommended settings
| Setting | Value |
|---|---|
| Inference base | krea/Krea-2-Turbo |
| Steps | 8 |
| Guidance scale | 0.0 |
| LoRA scale | 1.0 |
| Reference maximum edge | 384 px |
| Boundary redraw band | 32 px |
| Reference VLM encoding | enabled |
| Reference K/V cache | enabled |
The adapter was trained at rank/alpha 32/32 against Krea 2 Raw and is intended for distilled inference with Krea 2 Turbo.
Usage
pip install -r requirements.txt
python example.py \
--source input.webp \
--mask mask.png \
--output result.webp \
--width 1536 \
--height 1024 \
--bbox 0 0 1024 1024 \
--prompt "a bright modern studio, complete coherent composition"
For pure inpainting, omit --bbox and use a source image matching the output
canvas. For outpainting, provide the source location in the larger canvas. The
mask may additionally select any internal areas to regenerate.
How it works
- The source is placed without changing its aspect ratio.
- The out-of-source canvas and the user mask are unioned into one generated region.
- Generated pixels in the semantic reference are replaced by the median color of known pixels; the complete reference is encoded at a 384-pixel maximum edge.
- The denoiser uses destination-relative reference coordinates and isolated reference K/V caching.
- After every flow step, reliable known tokens are restored at the next noise level while the mask boundary remains free for coherent blending.
Limitations
- Large generated fractions may introduce unrelated subjects or structures.
- Very thin mask features may be coarsened by VAE and patch tokenization.
- Ambiguous prompts can change more context near the 32-pixel redraw band.
- The model may reproduce semantic biases present in the Krea 2 base model.
- The portable BF16 example favors reproducibility over the fastest hardware-specific quantized runtime.
Responsible use
Use reference images only when you have the subject's consent or another lawful basis to use them. Do not use this model for deceptive impersonation, fraud, harassment, non-consensual intimate imagery, biometric identification, or misleading political or media content.
Deployments must follow the Krea 2 Acceptable Use Policy, implement appropriate content moderation, and disclose AI-generated content where required.
License
The LoRA weights are a derivative of Krea 2 and are released under the Krea 2
Community License in LICENSE.pdf. Pipeline and helper code are distributed
under Apache License 2.0 in PIPELINE_LICENSE. This is an unofficial community
release and is not endorsed by Krea or Ostris. Training data is not included.
- Downloads last month
- 136










































