Skip to content

OpenFaaS anonymize function. Use MachineBox service.

Notifications You must be signed in to change notification settings

Tofull/faas_facebox

Repository files navigation

OpenFaaS function : faceBox from MachineBox GitHub stars

Twitter URL Github URL

This repository provides an OpenFaaS function to remove faces on pictures thanks to online machine learning service called MachineBox.

Input Output Output with blur effect
my profile picture who is this ? who is this ?

Technical instructions

Installation

  1. You need the OpenFaas CLI to build and deploy the function. So, first of all, you need to download it.

    curl -sL https://cli.openfaas.com | sudo sh

  2. This function is based on a MachineBox service called FaceBox. You can host your own facebox server with docker run -p 8081:8080 -e "MB_KEY=${MB_KEY}" machinebox/facebox. No worry, I already added this service for you in the OpenFaaS stack 👍 .

    By the way, you still have to get your own MachineBox key. Just sign in on MachineBox.

  3. Set your MachineBox key as environment variable :

    MB_KEY="ThIsIsThEKeYiGeTfRoMhTtPs://mAcHiNeBoX.Io/aCcOuNt"

  4. Init your docker swarm cluster :

    docker swarm init

  5. Deploy the OpenFaaS stack (embedded machinebox service on port 8081) :

    MB_KEY=${MB_KEY} docker stack deploy func --compose-file docker-compose.yml

  6. Build the anonymizer function :

    ./build_all.sh

  7. Deploy the function on OpenFaaS :

    faas-cli deploy -f func_facebox.yml

Anonymize your pictures !

I arbitrary chose this picture for the test (first Google Images item for keyword people):

people

Via the OpenFaaS UI :

  1. On you browser (http://localhost:8080), you should get something like : deployed openfaas stack

  2. Select the Download option and paste your image URL : ui_function_invoke

  3. Press Invoke button! Your anonymized picture is downloading.

  4. Open your anonymized picture with your favorite image viewer ! That rocks !

example_anonymized_people

Via the OpenFaaS API :

Because OpenFaaS provides a REST API, you can invoke this function programmatically :

URL="http://epilepsyu.com/wp-content/uploads/2014/01/happy-people-1050x600.jpg"
curl http://localhost:8080/function/anonymize -d "${URL}" > example_anonymized_people_curl.jpg

Cleanup :

docker stack rm func
docker swarm leave --force

Options :

Use another FaceBox server url

If you want to use another FaceBox server url, simply change the facebox environment variable in file func_facebox.yml to fit with yours.

functions:
  anonymize:
    lang: Dockerfile
    handler: ./faas_anonymizer
    image: functions/faas_anonymizer:latest
    environment:
      facebox: https://myFaceBoxServer

Apply effect on face

Remove faces is too much for you ? Why not just blur the people ? Just set the environment effect to blur, or simply use the blur function I added for you.

functions:
  blur:
    lang: Dockerfile
    handler: ./faas_blur
    image: functions/faas_blur:latest
    environment:
      facebox: http://localhost:8081
      effect: blur

Motivation

This challenge was given on Twitter :

motivation

The function source code is strongly inspired from this MachineBox blog post.

Details

For more details about Machine Box.

For more details about OpenFaaS.

Give this repository a star (because it's my first golang function hack) : GitHub stars

Follow my activities : Twitter URL Github URL Blog URL

Releases

No releases published

Packages

No packages published