What the tool does:
- Generates binary masks using semantic segmentation (e.g., for people, vehicles, sky, etc.).
- Can use the masks for anonymization.
In our experience, the available open anonymization tools (for faces, license plates, ...) are not very robust on real-world data and require a lot of manual interventions. This tool:
- Masks entire people and vehicles (larger objects easier to segment).
- Uses a union of masks from multiple off-the-shelf Mask2Former models (to limit failures of individual models).
Torch, NumPy, and Hatchling are needed at build time. You can either install them manually and then install the easy_anon package, which defines the runtime dependencies:
pip install torch numpy hatchling
pip install git+https://github.com/spatial-intelligence-group/easy_anon.git --no-build-isolationor you can use the complete (tested) environment defined in requirements.txt and then install just the easy_anon package:
pip install -r requirements.txt
pip install git+https://github.com/spatial-intelligence-group/easy_anon.git --no-build-isolation --no-deps- 💚 Mask2Former is installed automatically as a dependency.
⚠️ Mask2Former needs CUDA installed on the system.- If your installation of the CUDA toolkit is not in
/usr/local/cuda, you need to set the environment variableCUDA_HOMEbefore installing Mask2Former.
- If your installation of the CUDA toolkit is not in
- 💡 We recommend using uv and replacing the
pipcalls withuv pip. It's much faster!
The tool does two separate things:
- Generates masks using Mask2Former models.
- Anonymizes images using the generated masks.
The most basic way to run the two is:
easy-mask <input_image_dir> <mask_dir>
easy-anon <input_image_dir> <mask_dir> <anonymized_image_dir>![]() |
![]() |
| input image (by Anton Bielousov CC BY-SA 3.0) | generated mask |
The parts of the image that are masked can be specified using the --labels argument. Current options contain labels for people (person), vehicles (vehicle), sky (sky), and more. These are groups of segmentation IDs of the individual Mask2Former models, which are defined in the labels config files in src/easy_anon/configs. Multiple label groups can be used at once (just specify a list of the label groups --labels person vehicle). New label groups can be specified by changing the config files - just clone the repository, adjust the config files, and install the package from the local copy (pip install <path to the cloned repo>).
Mask2Former models used for the segmentation can be specified using the --model argument. Multiple models can be used at once (just specify a list of the model names --model ADE20k-ResNet101 ADE20k-Swin-L-IN21k). By default, the union of individual masks (from different models) is used to generate the final mask. The models should be automatically downloaded when used for the first time.
Use help to get all the available options:
easy-mask --helpThe way how the masked areas are filled in can be specified with the --infill_mode argument. The available options are:
![]() |
![]() |
average color in the masked areaaverage_inside |
average color on the mask borderaverage_border |
![]() |
![]() |
single specified colorsingle_color |
inpainted by [Telea, 2004]inpaint |
![]() |
![]() |
blurred with box filterblur_box |
blurred with Gaussian filterblur_gauss |
The color for the single_color infill mode can be specified using the --single_color argument (supports alpha). The blurring and inpainting can be adjusted with the --size_param argument.
Use help to get all the available options:
easy-anon --helpIf you use the tool in your scientific work, please cite it as:
@misc{easyanon,
title = {{easy-anon - An Easy-to-Use Image Masking and Anonymization Tool}},
author = {Vojtech Panek and contributors},
URL = {github.com/spatial-intelligence-group/easy_anon},
year = {2025}
}Please also cite the Mask2Former line of work:
@inproceedings{cheng2021mask2former,
title={Masked-attention Mask Transformer for Universal Image Segmentation},
author={Bowen Cheng and Ishan Misra and Alexander G. Schwing and Alexander Kirillov and Rohit Girdhar},
journal={CVPR},
year={2022}
}
@inproceedings{cheng2021maskformer,
title={Per-Pixel Classification is Not All You Need for Semantic Segmentation},
author={Bowen Cheng and Alexander G. Schwing and Alexander Kirillov},
journal={NeurIPS},
year={2021}
}The inpaint infill uses the algorithm from:
@article{telea2004image,
title={An Image Inpainting Technique Based on the Fast Marching Method},
author={Telea, Alexandru},
journal={Journal of graphics tools},
volume={9},
number={1},
pages={23--34},
year={2004},
publisher={Taylor \& Francis}
}This project is licensed under the MIT License - see the LICENSE file for details. Also, check the NOTICE file for additional information.
This project uses:
- Mask2Former for semantic segmentation
- OpenCV for image processing
- Rich for CLI
- and otters







