Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tofull/faas_facebox
OpenFaaS anonymize function. Use MachineBox service.
https://github.com/tofull/faas_facebox
docker face-detection machine-learning machinebox openfaas serverless
Last synced: about 1 month ago
JSON representation
OpenFaaS anonymize function. Use MachineBox service.
- Host: GitHub
- URL: https://github.com/tofull/faas_facebox
- Owner: Tofull
- Created: 2018-01-17T23:10:23.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T03:47:59.000Z (almost 7 years ago)
- Last Synced: 2024-04-24T02:53:38.141Z (8 months ago)
- Topics: docker, face-detection, machine-learning, machinebox, openfaas, serverless
- Language: Go
- Homepage:
- Size: 670 KB
- Stars: 35
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenFaaS function : faceBox from MachineBox [![GitHub stars](https://img.shields.io/github/stars/Tofull/faas_facebox.svg?style=social&label=Star)](https://GitHub.com/Tofull/faas_facebox/stargazers/)
[![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?logo=twitter&style=social&label=_Tofull)](https://twitter.com/_Tofull) [![Github URL](https://img.shields.io/badge/style--green.svg?logo=github&style=social&label=tofull)](https://github.com/tofull)
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](#apply-effect-on-face)
:-------------------------:|:-------------------------:|:-------------------------:
![my profile picture](https://avatars3.githubusercontent.com/u/15694700?s=400&u=cccde5aa45d3d40fd4c00794bba3b74cce88488b&v=4) | ![who is this ?](assets_for_documentation/anonymized_profile.jpg) | [![who is this ?](assets_for_documentation/blur_face.jpg)](#apply-effect-on-face)## Technical instructions
### Installation
1. You need the [OpenFaas CLI](https://github.com/openfaas/faas-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 :thumbsup: .
By the way, you still have to get your own MachineBox key. Just [sign in on MachineBox](https://machinebox.io/login?return_url=%2Faccount).
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)*:
#### Via the OpenFaaS UI :
1. On you browser (*http://localhost:8080*), you should get something like :
![deployed openfaas stack](assets_for_documentation/deployed_openfaas_stack.png)2. Select the Download option and paste your image URL :
![ui_function_invoke](assets_for_documentation/ui_function_invoke.png)3. Press **Invoke** button!
Your anonymized picture is downloading.4. Open your anonymized picture with your favorite image viewer ! That rocks !
#### Via the OpenFaaS API :
Because OpenFaaS provides a REST API, you can invoke this function programmatically :```bash
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 :
```bash
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.
```yaml
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.
```yaml
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](https://twitter.com/openfaas/status/953356175919271936?ref_src=twsrc) :
The function source code is strongly inspired from [this MachineBox blog post](https://blog.machinebox.io/how-i-built-an-image-proxy-server-to-anonymise-images-in-twenty-minutes-e550466ea09e).
## Details
For more details about [Machine Box](https://machinebox.io/).For more details about [OpenFaaS](https://www.openfaas.com/).
Give this repository a star (because it's my first golang function hack) : [![GitHub stars](https://img.shields.io/github/stars/Tofull/faas_facebox.svg?logo=github&style=social&label=Star)](https://GitHub.com/Tofull/faas_facebox/stargazers/)
Follow my activities : [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?logo=twitter&style=social&label=_Tofull)](https://twitter.com/_Tofull) [![Github URL](https://img.shields.io/badge/style--green.svg?logo=github&style=social&label=tofull)](https://github.com/tofull) [![Blog URL](https://img.shields.io/badge/style--green.svg?style=social&label=on%20my%20blog)](https://tofull.github.io/)