Face Anonymization

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-DETR for face detection.
  • Implemented a custom task for optimal face blurring.

Usage

Python

  1. First, deploy the workflow.

  2. Install Python library:

    pip install ikomia-client
  3. Integrate the workflow into your Python code:

    Process an image

    from ikclient.core.client import Client
    from ikclient.core.io import ImageIO, StorageObjectIO
    with 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 Client
    from ikclient.core.io import StorageObjectIO
    with 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

  1. First, deploy the workflow.

  2. Install JavaScript library:

    npm install @ikomia/ikclient
  3. 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.