
On-device face anonymisation: app-supplied model detects faces, opaque masks applied, metadata-stripped JPEG output, fail-closed behaviour, no network code, file and in-memory modes.
FaceBlur finds faces in a photo with a face-detection model that your app provides, covers each face with an opaque
mask, and writes the result as a new JPEG without the source file's metadata. It runs on the device, for Android and
for iOS, as a Kotlin Multiplatform library (io.github.shishark:faceblur). Swift apps use the Swift package
faceblur-swift.
FaceBlur is a tool for data minimisation: it reduces what a photo shows before you store or share it. Detection can miss faces, and masks cover only the faces that the model finds. Check the result before you share a photo.
Bitmap (Android), a CGContext or a pixel buffer (iOS) in place.FaceMaskException and does not hand out an image that
looks masked. An output that fails the library's own structure and metadata check is not kept.DetectorProfile, bundles it and
hard-codes its SHA-256; a file with another hash is refused before it is parsed. The model, its licence and its
training data are your responsibility.| Platform | Requirements | Install |
|---|---|---|
| Android |
minSdk 30 (Android 11) |
Maven Central: implementation("io.github.shishark:faceblur:0.1.0")
|
| Kotlin Multiplatform (Android and iOS) | Kotlin Multiplatform project |
api("io.github.shishark:faceblur:0.1.0") in commonMain; iOS also needs the ONNX Runtime bridge, see the KMP guide
|
| iOS (Swift) | iOS 18 or newer | Swift Package Manager: .package(url: "https://github.com/shiSHARK/faceblur-swift", .upToNextMinor(from: "0.1.0"))
|
Input formats are JPEG, HEIC and PNG, decoded by the platform decoder; the output is always JPEG. The Android build uses ONNX Runtime 1.31.0 and the iOS build ONNX Runtime 1.20.0.
Add the dependency, bundle your model in the app's assets and put its SHA-256 (shasum -a 256 model.onnx) in your
code. Then, off the main thread:
import io.github.shishark.faceblur.maskFile
// plus the other FaceBlur imports, see the Android guide
val bytes = context.assets.open("model.onnx").use { it.readBytes() }
val profile = DetectorProfile(
format = DetectionFormat.YuNetLayout(), // the output layout of YOUR model
inputWidth = 640,
inputHeight = 640,
scoreThreshold = 0.5f, // example value: choose it with your own photos
expectedSha256 = MODEL_SHA256, // hard-coded in your app
)
val model = DetectorModel.load(ModelSource.fromBytes(bytes), profile)
FaceMasker(model).use { masker ->
val result = masker.maskFile(context, sourceUri, AndroidOutputTargets.newFile(targetUri))
// result.masks.size faces were covered; detection can miss faces, so let the person check the result.
}Every call blocks: run it on a background thread and offer cancellation. On any error treat the photo as not masked and never publish the original instead. The full walk-through, with Java and in-memory mode, is in the guides below.
Bitmap mode, targets and
overwrite rules, apps without network permission, errors, limits.faceblur-swift package on iOS.samples/android is a small Android app that shows file mode and the in-memory pipeline end to end. See its
README. The Swift package has a SwiftUI demo in its repository.
Version 0.1.0 accepts issues, not pull requests. See CONTRIBUTING.md.
FaceBlur is licensed under the Apache License, Version 2.0 (see LICENSE and NOTICE). The licences of the third-party
components that FaceBlur depends on are listed in licenses/INDEX.txt, and the licence texts are in licenses/; they
travel inside the published artifacts. ONNX Runtime is a dependency under the MIT licence.
FaceBlur does not include a face-detection model and does not download one. The model that your app uses, the licence of that model and the licence and origin of the data it was trained on are separate from the licence of FaceBlur. They are your responsibility, and FaceBlur does not check or assess them.
FaceBlur finds faces in a photo with a face-detection model that your app provides, covers each face with an opaque
mask, and writes the result as a new JPEG without the source file's metadata. It runs on the device, for Android and
for iOS, as a Kotlin Multiplatform library (io.github.shishark:faceblur). Swift apps use the Swift package
faceblur-swift.
FaceBlur is a tool for data minimisation: it reduces what a photo shows before you store or share it. Detection can miss faces, and masks cover only the faces that the model finds. Check the result before you share a photo.
Bitmap (Android), a CGContext or a pixel buffer (iOS) in place.FaceMaskException and does not hand out an image that
looks masked. An output that fails the library's own structure and metadata check is not kept.DetectorProfile, bundles it and
hard-codes its SHA-256; a file with another hash is refused before it is parsed. The model, its licence and its
training data are your responsibility.| Platform | Requirements | Install |
|---|---|---|
| Android |
minSdk 30 (Android 11) |
Maven Central: implementation("io.github.shishark:faceblur:0.1.0")
|
| Kotlin Multiplatform (Android and iOS) | Kotlin Multiplatform project |
api("io.github.shishark:faceblur:0.1.0") in commonMain; iOS also needs the ONNX Runtime bridge, see the KMP guide
|
| iOS (Swift) | iOS 18 or newer | Swift Package Manager: .package(url: "https://github.com/shiSHARK/faceblur-swift", .upToNextMinor(from: "0.1.0"))
|
Input formats are JPEG, HEIC and PNG, decoded by the platform decoder; the output is always JPEG. The Android build uses ONNX Runtime 1.31.0 and the iOS build ONNX Runtime 1.20.0.
Add the dependency, bundle your model in the app's assets and put its SHA-256 (shasum -a 256 model.onnx) in your
code. Then, off the main thread:
import io.github.shishark.faceblur.maskFile
// plus the other FaceBlur imports, see the Android guide
val bytes = context.assets.open("model.onnx").use { it.readBytes() }
val profile = DetectorProfile(
format = DetectionFormat.YuNetLayout(), // the output layout of YOUR model
inputWidth = 640,
inputHeight = 640,
scoreThreshold = 0.5f, // example value: choose it with your own photos
expectedSha256 = MODEL_SHA256, // hard-coded in your app
)
val model = DetectorModel.load(ModelSource.fromBytes(bytes), profile)
FaceMasker(model).use { masker ->
val result = masker.maskFile(context, sourceUri, AndroidOutputTargets.newFile(targetUri))
// result.masks.size faces were covered; detection can miss faces, so let the person check the result.
}Every call blocks: run it on a background thread and offer cancellation. On any error treat the photo as not masked and never publish the original instead. The full walk-through, with Java and in-memory mode, is in the guides below.
Bitmap mode, targets and
overwrite rules, apps without network permission, errors, limits.faceblur-swift package on iOS.samples/android is a small Android app that shows file mode and the in-memory pipeline end to end. See its
README. The Swift package has a SwiftUI demo in its repository.
Version 0.1.0 accepts issues, not pull requests. See CONTRIBUTING.md.
FaceBlur is licensed under the Apache License, Version 2.0 (see LICENSE and NOTICE). The licences of the third-party
components that FaceBlur depends on are listed in licenses/INDEX.txt, and the licence texts are in licenses/; they
travel inside the published artifacts. ONNX Runtime is a dependency under the MIT licence.
FaceBlur does not include a face-detection model and does not download one. The model that your app uses, the licence of that model and the licence and origin of the data it was trained on are separate from the licence of FaceBlur. They are your responsibility, and FaceBlur does not check or assess them.