VincentGOURBIN/RMBG-2-CoreML
5120
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
- INT8 weight quantization - Reduced model size (233MB vs 461MB)
- No custom layers - Uses only native CoreML operations
- 1024x1024 input resolution - High-quality segmentation
- Fast inference - ~3-5 seconds on Apple Silicon
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 maskSwift 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")?.multiArrayValueModel Details
Performance
Tested on Apple Silicon:
Note: ANE performance varies by device. The INT8 quantization improves memory efficiency and model size while maintaining quality.
Files
Two model versions are available:
Recommended: Use the INT8 version for better memory efficiency and smaller download size with equivalent quality.
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
