MODNet
Xenova/modnet
published Feb 2024 · updated Oct 2025
MODNet is a real-time portrait matting model that removes backgrounds from images without requiring a trimap.
specs
| Task | Image Segmentation (Portrait Matting) |
| Architecture | MODNet (MobileNetV2-based) |
| License | Apache-2.0 |
about this model
MODNet is a segmentation model for real-time, trimap-free portrait matting that predicts an alpha matte from a single RGB image. Designed for efficient inference, it performs matting without requiring a trimap, reducing preprocessing overhead. The model is optimized for practical deployment and has been widely adopted in the community.
Architecture and Output
MODNet uses a lightweight CNN architecture to produce a high-quality alpha matte. The following example shows an input portrait and the corresponding output mask:
| Input image | Output mask |
|---|---|
![]() |
![]() |
Strengths
- Trimap-free operation: No user-provided trimap is needed; the model directly predicts the matte from the RGB image.
- Real-time performance: Suitable for live applications such as video matting and background replacement.
- Single input: Requires only a standard RGB image, simplifying integration into existing pipelines.
Additional Information
This Hugging Face hosted version provides ONNX weights for cross-platform compatibility. The model is licensed under Apache-2.0. With over 54,000 monthly downloads and 84 community likes, it is a proven choice for portrait matting tasks. For further details, see the AAAI 2022 paper and the official repository.
best for
- ·Removing backgrounds from portrait photos for e-commerce or social media
- ·Real-time virtual background replacement in video conferencing
- ·Automated photo editing for headshots and ID photos
FAQ
It takes a single RGB image. No trimap or additional input is required.
It outputs an alpha matte (a grayscale mask) that separates foreground (person) from background.
Yes, the model is designed for real-time portrait matting on common PCs and mobile devices, with the research demo supporting real-time video.
The model is licensed under Apache-2.0, allowing commercial use with attribution.
Send an image to the gigarouter OpenAI-compatible endpoint with your API key. The response will contain the alpha matte.
We're benchmarking and onboarding MODNet as a hosted, OpenAI-compatible API. Sign in for free credit and be ready when it lands, or tell us you want it and we'll prioritize it.

