Quick Access:
- 📄 Paper: arXiv:2509.06839
- 🤖 Model: joelseytre/toonout
- 📊 Dataset: joelseytre/toonout
While state-of-the-art background removal models excel at realistic imagery, they frequently underperform in specialized domains—such as anime-style content, where complex features like hair and transparency present unique challenges.
To address this limitation, we collected and annotated a custom dataset of 1,228 high-quality anime images of characters and objects, and fine-tuned the open-sourced BiRefNet model on this dataset. The resulting model, ToonOut, shows marked improvements in background removal accuracy for anime-style images, achieving an increase in Pixel Accuracy from 95.3% to 99.5% on our test set.
├── birefnet/ # Core library code
├── scripts/ # Python scripts (training, evaluation, etc.)
├── bash_scripts/ # Bash entrypoint scripts
├── LICENSE # MIT License (code + weights)
├── LICENSE-DATASET # CC-BY 4.0 License (dataset)
└── toonout_demo.ipynb # demo running inference using fine-tuned weights
This repository is a fork of the original BiRefNet with enhanced functionality and corrected settings for anime-style background removal.
Disclaimer: this repo was used on an environment with 2x GeForce RTW 4090 instances with 24GB of VRAM. You might need to adapt some of your settings to run the same scripts we used (in particular: the number of GPUs)
- Adjusted Training Settings: Added
train_finetuning.sh
with proper configuration to avoid NaN gradient problems (switched tobfloat16
data type) - Fixed Evaluation: Added
evaluations.py
with corrected settings from the originaleval_existingOnes.py
- Reorganized Structure: Separated code into three organized folders:
scripts/
for Python scriptsbash_scripts/
for bash entrypoint scriptsbirefnet/
for core library files
Each Python script has a corresponding bash script for easy execution:
- Data Splitting: Takes original and annotated image folders → splits into train/validation/test sets
- Training: Trains the neural network → saves checkpoints to a folder
- Testing: Takes a checkpoint → generates and saves predictions
- Evaluation: Takes model predictions → computes metrics on the test set
- Visualization: Takes predictions from multiple models (fine-tuned/baseline/external) → visualizes results and ranks models by chosen metrics
- Baseline Predictions: Generate baseline model predictions from RGB input folders
- Alpha Mask Generation: Extract alpha channel masks from RGBA annotated images
- Photoroom Integration: Generate Photoroom API predictions from RGB folders
git clone https://github.com/MatteoKartoon/BiRefNet.git
cd BiRefNet
pip install -r requirements.txt
bash bash_scripts/train_finetuning.sh
python scripts/evaluations.py --checkpoint path/to/checkpoint
The dataset consists of 1,228 annotated anime images, curated and labeled for background removal tasks.
- License: CC-BY 4.0 (must credit authors)
The dataset is organized into train
, test
, and val
splits, with each split containing multiple generation folders. Within each generation folder, you'll find three subfolders:
im/
: Raw RGB imagesgt/
: Ground truth transparency masksan/
: Combined RGBA images with transparency
toonout_dataset/
├── train/
│ ├── train_generations_20250318_emotion/
│ │ ├── im/ # RGB images
│ │ ├── gt/ # Ground truth masks
│ │ └── an/ # RGBA annotated images
│ └── train_generations_*/...
├── test/
│ └── test_generations_*/...
└── val/
└── validation_generations_*/...
The fine-tuned ToonOut weights are provided for easy inference.
- License: MIT
Example usage:
coming soon
This repository accompanies the paper:
ToonOut: Fine-tuned Background Removal for Anime Characters
Matteo Muratori (University of Bologna, Kartoon AI), Joël Seytre (Kartoon AI)
If you use this work, please cite:
@misc{muratori2025toonout,
title={ToonOut: Fine-tuned Background Removal for Anime Characters},
author={Muratori, Matteo and Seytre, Joël},
year={2025},
eprint={2509.06839},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2509.06839},
doi={10.48550/arXiv.2509.06839}
}
Project by Kartoon AI, powering toongether, check us out at kartoon.ai & toongether.ai
This project is forked from BiRefNet, originally licensed under MIT.