---
title: yijunwang2-krea2-anypaint
canonical_url: "https://www.modelscope.cn/models/hf/yijunwang2-krea2-anypaint"
md_url: "https://www.modelscope.cn/models/hf/yijunwang2-krea2-anypaint.md"
repository: hf/yijunwang2-krea2-anypaint
last_updated: 2026-08-03
license: other
pipeline_tag: image-to-image
tasks:
  - image-to-image
base_model:
  - krea/Krea-2-Turbo
base_model_relation: adapter
parameters: 114.3M
tensor_type:
  - BF16
library_name:
  - lora
  - diffusers
  - safetensors
  - pytorch
frameworks:
  - pytorch
supports_inference: img2img
downloads: 54
stars: 1
tags:
  - krea-2
  - krea2
  - anypaint
  - lora
  - inpainting
  - outpainting
  - arbitrary-mask
  - image-editing
  - image-to-image
  - diffusers
---

# yijunwang2-krea2-anypaint

> yijunwang2-krea2-anypaint - hf 在 ModelScope 开源的模型。Krea 2 AnyPaint: Arbitrary-Mask Inpainting, Outpainting, and Image Editing

hf/yijunwang2-krea2-anypaint 是 ModelScope 魔搭社区上的 114.3M 参数image-to-image模型，采用 other 许可，基于 krea/Krea-2-Turbo 构建，并支持在线推理（img2img）。

- **Repository**: hf/yijunwang2-krea2-anypaint
- **License**: other
- **Tasks**: image-to-image
- **Parameters**: 114.3M
- **Base model**: krea/Krea-2-Turbo
- **Online inference**: img2img
- **Tags**: krea-2, krea2, anypaint, lora, inpainting, outpainting, arbitrary-mask, image-editing, image-to-image, diffusers
- **Downloads**: 54
- **Stars**: 1
- **Last updated**: 2026-08-03

Source: https://www.modelscope.cn/models/hf/yijunwang2-krea2-anypaint

---

# 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](https://huggingface.co/spaces/yijunwang2/krea2-anypaint)
| [ComfyUI nodes](https://github.com/alexw5702-afk/krea2-anypaint)
| [Krea 2 functional adapters collection](https://huggingface.co/collections/yijunwang2/krea-2-functional-adapters-6a700e9e5c134888d6615a5d)

## At a glance

<table width="100%">
  <thead>
    <tr>
      <th width="33.33%">Source</th>
      <th width="33.33%">Generated mask</th>
      <th width="33.33%">AnyPaint result</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="showcase/11_product_restyle_source.webp" alt="Product source" width="100%"></td>
      <td><img src="showcase/11_product_restyle_mask.png" alt="Product edit mask" width="100%"></td>
      <td><img src="showcase/11_product_restyle_result.webp" alt="Restyled product result" width="100%"></td>
    </tr>
    <tr>
      <td><img src="showcase/14_window_view_source.webp" alt="Window source" width="100%"></td>
      <td><img src="showcase/14_window_view_mask.png" alt="Window edit mask" width="100%"></td>
      <td><img src="showcase/14_window_view_result.webp" alt="Replaced window view result" width="100%"></td>
    </tr>
    <tr>
      <td><img src="showcase/04_portrait_mixed_source.webp" alt="Portrait source" width="100%"></td>
      <td><img src="showcase/04_portrait_mixed_mask.png" alt="Portrait clothing and outpaint mask" width="100%"></td>
      <td><img src="showcase/04_portrait_mixed_result.webp" alt="Portrait clothing edit result" width="100%"></td>
    </tr>
    <tr>
      <td><img src="showcase/13_living_room_objects_source.webp" alt="Living room source" width="100%"></td>
      <td><img src="showcase/13_living_room_objects_mask.png" alt="Living room object masks" width="100%"></td>
      <td><img src="showcase/13_living_room_objects_result.webp" alt="Living room with added objects" width="100%"></td>
    </tr>
  </tbody>
</table>

> **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`, and `anypaint.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/`.

![AnyPaint showcase covering inpainting, outpainting, and arbitrary-mask image editing](showcase/contact_sheet.webp)

<!-- SHOWCASE_EXAMPLES_START -->
<details>
<summary><strong>Open the complete source / mask / result set and prompts</strong></summary>

### 01_photo_internal - Photographic internal edit

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/01_photo_internal_source.webp) | ![](showcase/01_photo_internal_mask.png) | ![](showcase/01_photo_internal_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/02_watercolor_outpaint_source.webp) | ![](showcase/02_watercolor_outpaint_mask.png) | ![](showcase/02_watercolor_outpaint_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/03_3d_outpaint_source.webp) | ![](showcase/03_3d_outpaint_mask.png) | ![](showcase/03_3d_outpaint_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/04_portrait_mixed_source.webp) | ![](showcase/04_portrait_mixed_mask.png) | ![](showcase/04_portrait_mixed_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/05_botanical_disconnected_source.webp) | ![](showcase/05_botanical_disconnected_mask.png) | ![](showcase/05_botanical_disconnected_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/07_product_narrow_source.webp) | ![](showcase/07_product_narrow_mask.png) | ![](showcase/07_product_narrow_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/08_landscape_complex_source.webp) | ![](showcase/08_landscape_complex_mask.png) | ![](showcase/08_landscape_complex_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/09_male_accessories_source.webp) | ![](showcase/09_male_accessories_mask.png) | ![](showcase/09_male_accessories_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/10_female_accessories_source.webp) | ![](showcase/10_female_accessories_mask.png) | ![](showcase/10_female_accessories_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/11_product_restyle_source.webp) | ![](showcase/11_product_restyle_mask.png) | ![](showcase/11_product_restyle_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/12_desk_objects_source.webp) | ![](showcase/12_desk_objects_mask.png) | ![](showcase/12_desk_objects_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/13_living_room_objects_source.webp) | ![](showcase/13_living_room_objects_mask.png) | ![](showcase/13_living_room_objects_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/14_window_view_source.webp) | ![](showcase/14_window_view_mask.png) | ![](showcase/14_window_view_result.webp) |

**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

| Source | Generated mask | AnyPaint result |
|:---:|:---:|:---:|
| ![](showcase/15_person_boundary_source.webp) | ![](showcase/15_person_boundary_mask.png) | ![](showcase/15_person_boundary_result.webp) |

**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

</details>
<!-- SHOWCASE_EXAMPLES_END -->

## 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

```bash
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

1. The source is placed without changing its aspect ratio.
2. The out-of-source canvas and the user mask are unioned into one generated
   region.
3. 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.
4. The denoiser uses destination-relative reference coordinates and isolated
   reference K/V caching.
5. 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.
