Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

lunatech-labs/lunatech-scala-anonymization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lunatech-Scala-Anonymization

Scala implementation of the understand.ai Anonymizer

Table of contents

  1. Introduction
  2. Global Architecture
  3. Configuration
  4. Build
  5. Run
  6. Attributions

Prerequisites

1. Download models

You have two solutions to download models:

  • Download pre-trained models from Google drive

  • Use your own models

You have to put both models in the folder /src/main/resources/models with the following names:

  • face.pb: detection model for face
  • plate.pb: detection model for plate

2. Protocol Buffers compiler

To use Tensorflow for Scala, you need to install the Protocol Buffers compiler (at least version 3).

With apt: apt-get install protobuf-compiler

With brew: brew install protoc

Feel free to check this link for more information.

Introduction

Anonymization allows you to blur face and plate to improve the privacy of each other. See an exemple below of an image presenting several cars and faces before and after anonymization. Image example cars before Image example cars after

Global Architecture

Four important steps to anonymize our images:

  1. First of all, we use Tensorflow Scala to detect plates and faces.
  2. We create a mask with image size. This mask is the area who need to be blurred.
  3. We use a convolution with gaussian kernel and our image to blur everything.
  4. Using our previous mask we keep only the detection boxes area blurred and all other parts as initial.

In addition, we use a mean kernel to have smooth border around the blurred area. Diagram Global architecture

Configuration

There are multiple options to run the anonymizer. For the documentation, please use: --help.

Name Value Required
--input Path to the input folder X
--output Path to the output folder X
--image-extensions Comma-separated list of file types that will be anonymized (e.g. jpg, png)
--face-threshold Detection confidence needed to anonymize a detected face. Must be in [0.001, 1.0]
--plate-threshold Detection confidence needed to anonymize a license plate. Must be in [0.001, 1.0]
--kernel-size Size of the gaussian kernel. Must be odd
--sigma Standard deviation.
--box-kernel-size Size of the kernel used to smooth transitions. Must be odd

Build

Inside the root folder, use sbt assembly.

Run

Once you have built your jar, use java -jar <name_of_your_jar> <options>

Otherwise, if you want to test quickly, in the root folder, you can use sbt "run --input <inputPath> --output <outputPath>"

Attributions

As said in the initial python project:

"An image for one of the test cases was taken from the COCO dataset. The pictures in this README are under an Attribution 4.0 International license."

About

Anonymization with scala-tensorflow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages