- MOSS 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
- 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
- Input contract
- Recommended settings
- Usage
- ComfyUI usage
- How it works
- Limitations
- Responsible use
- License
- At a glance
MOSS AnyPaint: Arbitrary-Mask Inpainting, Outpainting, and Image Editing
MOSS AnyPaint provides arbitrary-mask inpainting, outpainting, and image editing for MOSS-Image-Base. One runtime handles internal edits, canvas extension, disconnected regions, narrow structures, and mixed masks that cross the source boundary.
Download the LoRA | ComfyUI nodes | ComfyUI releases
At a glance
| Source | Generated mask | AnyPaint result |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Important: Generic 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. The sources are also used in the Krea 2 AnyPaint showcase; the results here use MOSS AnyPaint.
The showcase covers 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
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
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.
Use a source bounding box with the source's aspect ratio to avoid stretching. A source-sized mask follows the source's scaling, offset and clipping. A canvas-sized mask is used directly; if source and canvas sizes are equal, canvas coordinates take priority. Areas outside the source box are always generated. Other mask sizes are rejected.
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. Exterior source seams have a 32-pixel inward redraw band; internal masks are exact. The returned image is the raw decoded model output; there is no hidden post-generation source composite. The text encoder receives only the prompt, without VLM image encoding.
Recommended settings
| Setting | Value |
|---|---|
| Inference base | OpenMOSS-Team/MOSS-Image-Base + Base 8-step DMD2 |
| Steps | 8 |
| CFG / shift | 1 / 5 |
| LoRA scale | 1.0 for both adapters |
| Frozen DiT / text weights | Quanto qfloat8 |
| Compute / task adapter | BF16 |
| VAE / DMD2 adapter | FP32; DMD2 remains unmerged |
| Reference maximum edge | 384 px |
| Boundary redraw band | 32 px at exterior source seams; 0 px for internal masks |
| Reference VLM encoding | disabled |
| Reference K/V cache | enabled |
Use lora_dmd2.safetensors from the Base 8-step DMD2 repository, rather than
SFT weights or its earlier lora.safetensors. Required upstream revisions and
dependencies are recorded in runtime_lock.json.
Usage
Use Python 3.11+ and a CUDA GPU with BF16 support. Install the PyTorch wheel appropriate for your CUDA environment before the remaining requirements.
pip install huggingface_hub
hf download yijunwang2/moss-anypaint --local-dir moss-anypaint
cd moss-anypaint
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.
The first run downloads the Base components and Base 8-step DMD2 adapter.
Already-downloaded assets can be supplied with --model-dir and --distillation.
Use moss_anypaint_rank32.safetensors as the task adapter. An ordinary
text-to-image LoRA loader alone does not implement the AnyPaint input contract.
ComfyUI usage
See the step-by-step ComfyUI instructions for same-canvas inpainting, outpainting, SAM/other MASK nodes, Mask Editor and separate mask images. The default workflow uses one Load Image node for its IMAGE and MASK outputs; all padding defaults to 0. Existing saved workflows retain their saved padding.
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 exterior redraw band.
- Masks must cover the complete object or edge to be replaced.
- Small-object counts, exact positioning and geometry can vary by seed.
- Unmasked RGB pixels can differ slightly through VAE decoding.
- The model may reproduce semantic biases present in the MOSS base model.
- The included runtime uses qfloat8 frozen weights with BF16 compute; other precision configurations may produce different results.
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 applicable upstream terms, implement appropriate content moderation, and disclose AI-generated content where required.
License
The LoRA weights and included runtime are released under Apache License 2.0. See LICENSE, PIPELINE_LICENSE, NOTICE, and component licenses and attribution.
Base: OpenMOSS-Team/MOSS-Image-Base. Runtime dependency: DiffSynth-Studio. Distillation: Base 8-step DMD2. This is an unofficial community release and is not endorsed by those authors. Training data is not included.
Model tree for yijunwang2/moss-anypaint
Base model
OpenMOSS-Team/MOSS-Image-Base



































