Face Anonymization

About
This workflow blurs all faces in an image or video.
Capabilities
- Face anonymization by blurring detected faces.
- Robust face detection in various conditions, including large occlusions and varying lighting conditions.
- Suitable for both images and videos.
Known limitations
- May miss faces in crowded scenes when too many faces are present.
Recommendations
- Best results are achieved with high-resolution images and videos.
- On critical applications, implement guardrails to verify anonymization quality.
Model information
- Based on a custom fine-tuned version of
RF-DETRfor face detection. - Implemented a custom task for optimal face blurring.
Usage
Python
-
First, deploy the workflow.
-
Install Python library:
pip install ikomia-client -
Integrate the workflow into your Python code:
Process an image
from ikclient.core.client import Clientfrom ikclient.core.io import ImageIO, StorageObjectIOwith Client(url="https://your.scale.endpoint.url",token="your-api-token", # default to os.environ.get("IKOMIA_TOKEN")) as face_blur:results = face_blur.run("path/to/your/image.jpg")image_output = results.get_output(assert_type=ImageIO)image_output.to_pil().save("blurred_faces_image.jpg")Process a video
from ikclient.core.client import Clientfrom ikclient.core.io import StorageObjectIOwith Client(url="https://your.scale.endpoint.url",token="your-api-token", # default to os.environ.get("IKOMIA_TOKEN")) as face_blur:results = face_blur.run("path/to/your/video.mp4")video_output = results.get_output(assert_type=StorageObjectIO)with face_blur.storage.read(video_output["metadata"], streaming=True) as stream, \open("blurred_faces_video.mp4", "wb") as out_file:for chunk in stream.iter_bytes():out_file.write(chunk)For more details, refer to the documentation.
JavaScript
-
First, deploy the workflow.
-
Install JavaScript library:
npm install @ikomia/ikclient -
Integrate the workflow into your JavaScript code:
Process an image
import { Client, ImageIO } from "@ikomia/ikclient";import fs from "fs/promises";const client = new Client({url: "https://your.scale.endpoint.url",token: "your-api-token", // default to process.env.IKOMIA_TOKEN});const results = await client.run({inputs: ["https://your.image.url/image.jpg",],});const imageOutput = results.getOutput(0, ImageIO);await fs.writeFile('blurred_faces_image.png',Buffer.from(imageOutput.toArrayBuffer()));Process a video
import { Client, StorageObjectIO } from "@ikomia/ikclient";import fs from "fs/promises";const client = new Client({url: "https://your.scale.endpoint.url",token: "your-api-token", // default to process.env.IKOMIA_TOKEN});const results = await client.run({inputs: ["https://your.video.url/video.mp4",],});const videoOutput = results.getOutput(0, StorageObjectIO);const response = await client.storage.read(videoOutput.data.metadata);await fs.writeFile('blurred_faces_video.mp4',Buffer.from(response.arrayBuffer()));For more details, refer to the documentation.
REST API
Refer to the documentation for integration using the REST API.