BiRefNet ToonOut: Anime Background Removal With 99.5% Accuracy
Overviewbirefnet-toonout is a fine-tuned version of BiRefNet specialized for anime-style background 2026-7-21 05:37:30 Author: hackernoon.com(查看原文) 阅读量:2 收藏

Overview

birefnet-toonout is a fine-tuned version of BiRefNet specialized for anime-style background removal. Created by sprited, this model packages work by Matteo Muratori and Joël Seytre that improves pixel accuracy from 95.3% to 99.5% on anime test sets by fine-tuning on 1,228 curated anime images. The model accepts any image as input and outputs either RGBA cutouts or raw alpha mattes at configurable resolutions from 256 to 2048 pixels (default 1024, matching training resolution). It runs on Replicate and is MIT-licensed, making it suitable for both commercial and non-commercial use. The core innovation addresses a critical gap: while general-purpose segmentation models like the original BiRefNet excel on photographs, they fail on stylized content with hair wisps, line art, and translucent elements common in anime. This fine-tune recovers detail in exactly those failure modes.

Best use cases

Anime character asset extraction for game development. Extract clean character sprites from anime frames or official artwork for use in 2D games, visual novels, or sprite animation pipelines. The model's 99.5% pixel accuracy on anime test data ensures minimal manual cleanup of hair strands and clothing edges that would require tedious hand-painting in traditional tools like Photoshop. This is particularly valuable when sourcing characters from fan art or promotional images where quality varies.

AI-generated anime illustration cleanup. Process outputs from text-to-image models trained on anime datasets (Stable Diffusion anime checkpoints, NovelAI, etc.) to remove backgrounds automatically. These generated images often have messy or inconsistent backgrounds, and the model's anime specialization means it preserves the stylization and line quality better than general-purpose segmentation. The refinement options (mask blur, foreground refinement) further polish edges for seamless compositing.

Sticker and emoji sheet generation. Batch-process manga panels, comic strips, or character illustrations to create transparent PNG assets for sticker packs or custom emoji sets. The model handles the small details in hands, facial features, and overlapping visual elements that often trip up general models, producing assets ready for direct use without per-frame manual masking.

Sprite animation frame preparation. Prepare individual frames from anime sequences or hand-drawn animation for sprite sheet assembly. Since animation frames may have anti-aliased edges and semi-transparent overlays (shadows, glow effects), the refine_fg option removes background color bleed while preserving the intentional transparency, critical for animation quality.

Merchandise and fan art processing. Clean up high-resolution fan artwork or official illustrations for merchandise printing, social media, or portfolio use. The model preserves fine details in hair texture, clothing patterns, and subtle color gradations that define anime aesthetics, unlike general segmentation that may oversimplify or flatten these elements.

Limitations

The model is trained exclusively on 1,228 anime images, so performance on non-anime stylized art (Western comic books, cartoons, vector art, 3D renders) is not guaranteed and likely inferior to the original BiRefNet. The maximum resolution is 2048 pixels; very high-resolution artwork or multi-character scenes may require downsampling, tiling, or multiple passes. Inference resolution defaults to 1024, matching training—going significantly higher (2048) may introduce artifacts or slow inference substantially. The model produces binary segmentation (foreground/background) only; it does not separate characters from objects within the foreground or perform semantic understanding beyond "character vs. not character." Complex scenes with overlapping characters, occlusion, or intricate background elements within anime (e.g., detailed room interiors) may produce imperfect boundaries. The refine_fg parameter uses FB blur fusion for edge cleanup but can over-smooth fine details if applied too aggressively. Since this is an unofficial community packaging (not maintained by the original authors), long-term support and updates are dependent on the packager's availability. The output is a single-channel alpha matte or RGBA image; there is no multi-class segmentation (e.g., separating hair from skin or clothing).

How it compares

birefnet by sprited is the complete BiRefNet family including all 10 official variants plus ToonOut. Choose birefnet-toonout if you work exclusively with anime and want the fastest, most specialized endpoint; choose the full birefnet model if you need flexibility across photographic, medical, camouflaged object, salient object, and anime segmentation in a single deployment. The full model adds negligible latency overhead but gives you variant selection at runtime.

vtoonify by 412392713 performs portrait style transfer rather than background removal. If your goal is to stylize a photograph into cartoon/anime appearance while keeping the background, use VToonify; if you need clean foreground extraction from existing anime-styled content, use birefnet-toonout. These models solve different problems and are often used in sequence (stylize then extract).

birefnet by men1scus is the standard BiRefNet on Replicate without anime fine-tuning. The tradeoff is simplicity and speed (one model) versus specialization; men1scus's version handles photographic images slightly better, but birefnet-toonout produces dramatically better results on anime (99.5% vs 95.3% pixel accuracy on anime test sets). If your pipeline includes both photos and anime, the full birefnet variant selector is more cost-effective than running both endpoints.

birefnet/v2 by fal-ai is hosted on a different platform (Fal instead of Replicate) and uses the standard BiRefNet architecture without anime fine-tuning. It may have different latency characteristics and pricing. Choose fal-ai's version if you are already in that ecosystem or if their cold-start guarantees matter; choose Replicate's birefnet-toonout if you need anime specialization and prefer Replicate's pricing model and API.

Technical specifications

Architecture and training: Fine-tuned BiRefNet using 1,228 high-quality curated anime images. Training data is open-sourced; the fine-tune was specifically designed to address failure modes in hair, translucency, and line art segmentation common in anime-style content.

Input and output: The model accepts images in any standard format (JPEG, PNG, WebP, etc.) via URI. It outputs either RGBA PNG (default, with background removed and transparency applied) or raw alpha matte (grayscale PNG when output_format: mask is set, though this parameter is not exposed in the current schema).

Resolution handling: Inference resolution is configurable from 256 to 2048 pixels (square, default 1024). The 1024 resolution matches the training resolution; increasing beyond this may improve detail on very large inputs but at the cost of increased memory and latency. The model internally resizes input images to the specified resolution, processes, and returns output at that resolution.

Post-processing options:

  • mask_blur (0–64, default 0): Gaussian blur radius applied to the alpha matte for softer edges. Useful for smoothing hard artifacts or preparing output for compositing.
  • mask_offset (−64 to +64, default 0): Grow (positive values) or shrink (negative values) the matte boundary by pixel distance. Helpful for fine-tuning edge tightness without regenerating.
  • refine_fg (boolean, default false): Enables FB blur fusion to refine foreground colors and remove background color bleed on soft edges. Recommended when compositing onto transparent backgrounds or when edge color purity matters.

Platform: Runs on Replicate (cog_version 0.20.0, latest version deployed June 12, 2026). License: MIT, permissive for commercial and non-commercial use.

Model inputs and outputs

Inputs

  • image (URI, required): Input image URL. Accepts any standard image format (JPEG, PNG, WebP, etc.).
  • resolution (integer, 256–2048, default 1024): Inference resolution in pixels (square). 1024 matches training; increase for larger inputs or finer detail.
  • mask_blur (integer, 0–64, default 0): Gaussian blur radius applied to the alpha matte for softer edges.
  • mask_offset (integer, −64 to +64, default 0): Grow (+) or shrink (−) the matte boundary in pixels.
  • refine_fg (boolean, default false): Refine foreground colors using FB blur fusion to remove background bleed on soft edges.

Outputs

  • Output (URI, string): URL to the output image (RGBA PNG with transparent background, or alpha matte PNG if output format is set to mask).

Getting started

import replicate

client = replicate.Replicate()

output = client.run(
    "sprited/birefnet-toonout:35f7c78ef6338bf4cb94b41a83407ab44e2de7b436b8feafba547235d366a2bb",
    input={
        "image": "https://example.com/anime-character.png",
        "resolution": 1024,
        "mask_blur": 2,
        "mask_offset": 0,
        "refine_fg": True,
    },
)

print(output)  # Returns URL to output image

For batch processing or higher-resolution inputs:

import replicate

client = replicate.Replicate()

output = client.run(
    "sprited/birefnet-toonout:35f7c78ef6338bf4cb94b41a83407ab44e2de7b436b8feafba547235d366a2bb",
    input={
        "image": "https://example.com/high-res-anime.png",
        "resolution": 2048,  # Higher resolution for fine detail
        "mask_blur": 1,
        "mask_offset": -2,  # Slightly shrink boundary to remove edge artifacts
        "refine_fg": True,
    },
)

print(output)

Frequently asked questions

Q: What happens if I use this model on Western cartoon or comic book art instead of anime?

A: The model will still attempt segmentation, but accuracy degrades significantly because it was fine-tuned on 1,228 anime images only. Non-anime stylized art (American comics, vector cartoons, 3D renders) should use the standard BiRefNet or a general-purpose segmentation model. The anime fine-tune optimizes for features like hair wisps and line art that may not apply to other styles.

Q: Should I increase resolution to 2048 for better quality?

A: Not necessarily. The model was trained at 1024 resolution, so that is the "native" operating point. Increasing to 2048 may capture finer detail on very large inputs but also increases latency and memory usage, and may introduce artifacts due to distribution shift. Start at 1024 and increase only if visible detail is lost in your output.

Q: Can I use this model commercially?

A: Yes. The model weights are MIT-licensed, permissive for commercial use without attribution (though attribution is appreciated). You pay only the Replicate compute fees; there are no licensing royalties. Check the LICENSE file in the GitHub repository for full terms.

Q: What is the difference between refine_fg and mask_blur?

A: mask_blur applies Gaussian blur to the alpha matte, softening all edges uniformly (good for anti-aliasing). refine_fg uses FB blur fusion to remove background color bleed specifically—it adjusts foreground pixel colors where the background has bled through, preserving edge sharpness while improving color purity. Use both for the best results on soft edges like hair and translucency.

Q: How long does inference take?

A: The README and schema do not specify latency. Since this runs on Replicate's shared infrastructure, speed depends on hardware load and resolution. Default 1024 resolution should be fast (seconds); 2048 will take longer. Test with your own images to measure.

Q: What output format does this return?

A: By default, an RGBA PNG file with the background transparent and the foreground preserved. The schema does not expose an output_format parameter for selecting raw alpha matte output, so you always receive a full RGBA image. If you need a grayscale alpha matte only, you can extract the alpha channel post-hoc from the RGBA output using image processing libraries.

Q: Is this model still maintained?

A: This is unofficial community packaging by Sprited. The original ToonOut model and weights (joelseytre/toonout) are maintained by the authors on Hugging Face. The Replicate endpoint is maintained as long as the packager chooses; no formal SLA or update guarantee exists. For critical production use, monitor the GitHub repository and Replicate endpoint status.

Q: How does mask_offset interact with mask_blur?

A: mask_offset is applied first (shrinking or growing the boundary), then mask_blur softens the result. Use offset to adjust tightness (shrink for edge artifacts, grow to include slightly more foreground), and blur to anti-alias. A common safe default is mask_offset: 0, mask_blur: 1, refine_fg: true.

This is a simplified guide to an AI model called birefnet-toonout maintained by sprited. If you like these kinds of analysis, join AIModels.fyi or follow us on Twitter.


文章来源: https://hackernoon.com/birefnet-toonout-anime-background-removal-with-995percent-accuracy?source=rss
如有侵权请联系:admin#unsafe.sh