RMBG-2 CoreML - Background Removal Model
CoreML conversion of BRIA AI's RMBG-2.0 background removal model, optimized for Apple Neural Engine (ANE).
Model Description
This is a native ML Program format CoreML model converted from RMBG-2.0 (BiRefNet architecture) for high-quality background removal on Apple devices.
Key Features
- Native CoreML ML Program format - Full ANE compatibility
- No custom layers - Uses only native CoreML operations
- 1024x1024 input resolution - High-quality segmentation
- Fast inference - ~3 seconds on Apple Silicon with ANE
Usage
With RMBG2Swift Package
import RMBG2Swift
// Simple one-liner
let rmbg = try await RMBG2()
let result = try await rmbg.removeBackground(from: image)
// Access the result
let outputImage = result.image // Image with transparent background
let mask = result.mask // Grayscale segmentation mask
Swift Package: github.com/VincentGourbin/RMBG2Swift
Manual Integration
import CoreML
// Load the model
let config = MLModelConfiguration()
config.computeUnits = .all // Enable ANE
let model = try await MLModel.load(contentsOf: modelURL, configuration: config)
// Prepare input (1024x1024, NCHW format with ImageNet normalization)
let input = MLDictionaryFeatureProvider(dictionary: ["input": inputArray])
// Run inference
let output = try model.prediction(from: input)
// Get mask from output_3 (full resolution)
let mask = output.featureValue(for: "output_3")?.multiArrayValue
Model Details
| Property | Value |
|---|---|
| Architecture | BiRefNet |
| Input Size | 1024 x 1024 |
| Input Format | RGB, NCHW [1, 3, 1024, 1024] |
| Normalization | ImageNet (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) |
| Output | 4 scales (output_0 to output_3), use output_3 for full resolution |
| Format | ML Program (.mlpackage) |
| Minimum OS | macOS 13+ / iOS 16+ |
| Compute Units | All (CPU, GPU, ANE) |
Performance
Tested on Apple Silicon:
| Device | Inference Time |
|---|---|
| M1 Pro (ANE) | ~3s |
| M1 Pro (GPU) | ~5s |
Files
RMBG-2-native.mlpackage/- CoreML ML Program model
License
Creative Commons Attribution-NonCommercial 4.0 (CC BY-NC 4.0)
- Free for non-commercial use: Research, personal projects, education
- Commercial use requires a separate license from BRIA AI
For commercial licensing, contact: bria.ai/contact-us
Attribution
This CoreML conversion is based on the RMBG-2.0 model by BRIA AI:
- Original Model: briaai/RMBG-2.0
- Architecture: BiRefNet
- Creator: BRIA AI
Related Links
- Downloads last month
- -
Model tree for VincentGOURBIN/RMBG-2-CoreML
Base model
briaai/RMBG-2.0