On-device, license-clean cinematic background blur driven by a monocular depth map — near stays sharp, far goes soft, with a real gradual falloff (not a hard person cutout, and it works on any scene).
DepthEstimator— wraps Apple's Depth Anything V2 Core ML model (Apache), ~50 MB, image → depth map via Vision (~tens of ms warm on the Neural Engine).DepthBlurFilter— turns the depth into a per-pixel blur mask (sharp at the focal plane, blurrier with distance) and runsCIMaskedVariableBlur.DepthBlur— Codable settings:amount,focalPlane,falloff.
let estimator = try DepthEstimator(modelURL: modelURL) // DepthAnythingV2SmallF16.mlpackage
if let filter = DepthBlurFilter(settings: DepthBlur(amount: 0.6), estimator: estimator) {
let out = filter.apply(sourceImage) // per-frame; source space
}Model: apple/coreml-depth-anything-v2-small on Hugging Face (not committed).
Requirements: macOS 26 / iOS 26, Swift 6.2.
MIT — see LICENSE.
Bundled or downloaded models keep their own licences; see the notes above where a model is named.