face-detect-annotator
is a tool to detect faces from Image file by AWS Rekognition, Google Vision, Azure Computer Vision, Face++, OpenCV, Dlib, Pigo, TensorFlow
Amazon advertise like "Our product is awesome!".
Google advocates like "Our AI is brilliant!!".
ML engineer says like "My top-noch model reach beyond the existing world!!!".
You may think, "Who is the winner?". Okay, let's decide the No.1.
At first, install golang. And install dependensies.
- OpenCV: https://gocv.io/getting-started/
- Dlib: https://github.com/Kagami/go-face
- TensorFlow: https://www.tensorflow.org/install/lang_go
Then, create binary file.
# Basic engines [pigo,azure,google,rekognition] (you can use these engines without OS dependencies or libraries)
$ go build -o face-detect-annotator ./cmd/face-detect-annotator-basic
# All engines
# $ go build -o face-detect-annotator ./cmd/face-detect-annotator-all
$ ./face-detect-annotator -h
Commands:
help show help
detect Detect faces from image file or csv list
annotate Annotate faces of image from --input TSV file
detect
command detecting faces from --input
image file or csv list file.
$ ./face-detect-annotator detect -h
Detect faces from image file or csv list
Options:
-h, --help display help information
-i, --input *image dir path --input='/path/to/image_dir'
-o, --output[=./output.tsv] *output TSV file path --output='./output.tsv'
-a, --all use all engines
-e, --engine[=opencv,dlib,tensorflow] comma separate Face Detect Engines --engine='opencv,dlib,pigo,tensorflow,rekognition,google,azure,face++'
For example, if you want to detect faces of images from the CSV file,
cat ./input,csv
path,count
myimages/foobar/001.jpg,1
myimages/foobar/002.jpg,1
myimages/foobar/003.jpg,0
With all of the engines,
$ FDA_AZURE_REGION=westus \
FDA_AZURE_SUBSCRIPTION_KEY=ZZZ \
GOOGLE_APPLICATION_CREDENTIALS=$HOME/google/service_account.json \
AWS_ACCESS_KEY_ID=XXX \
AWS_SECRET_ACCESS_KEY=ZZZ \
FACEPP_API_KEY=XXX \
FACEPP_API_SECRET=ZZZ \
./face-detect-annotator detector -i ./input.csv -o ./output.tsv -e="rekognition,google,azure,face++,tensorflow,opencv,dlib,pigo"
[INFO] Use rekognition
[INFO] Use google
[INFO] Use azure
[INFO] Use face++
[INFO] Use tensorflow
[INFO] Use opencv
[INFO] Use dlib
[INFO] Use pigo
exec #: [2]
exec #: [1]
exec #: [0]
After a while, output.tsv
will be created.
annotate
command draw rectangle lines around faces from TSV file, generated from detect
command.
$ ./face-detect-annotator annotate -h
Annotate faces of image from --input TSV file
Options:
-h, --help display help information
-i, --input *detector's output tsv file --input='/path/to/output.tsv'
$ ./face-detect-annotator annotate -i ./output.tsv
After a while, _annotated_
prefixed files will be created in the same directory of the given images.
$ tree
└── myimages
└── foobar
├── _annotated_001.jpg
├── _annotated_002.jpg
├── _annotated_003.jpg
├── 001.jpg
├── 002.jpg
└── 003.jpg
Name | Command | Description |
---|---|---|
FDA_ENGINE_ALL |
detect |
Use all of the face detection engines. |
FDA_ENGINE_DLIB |
detect |
Use Dlib. |
FDA_ENGINE_OPENCV |
detect |
Use OpenCV. |
FDA_ENGINE_PIGO |
detect |
Use Pigo. |
FDA_ENGINE_TF |
detect |
Use TensorFlow. |
FDA_ENGINE_REKOGNITION |
detect |
Use AWS Rekognition. |
FDA_ENGINE_GOOGLE |
detect |
Use Google Vision API. |
FDA_ENGINE_AZURE |
detect |
Use Azure Computer Vision API. |
FDA_DLIB_MODEL_DIR |
detect for Dlib |
Specify the directory path of model files for Dlib. |
FDA_PIGO_CASCADE_FILE |
detect for Pigo |
Specify the file path of a cascade file of Pigo. |
FDA_OPENCV_CASCADE_FILE |
detect for OpenCV |
Specify the file path of a cascade file of OpenCV. |
FDA_TF_MODEL_FILE |
detect for TensorFloe |
Specify the .pb file path of a model file for TensorFlow. |
FDA_AZURE_REGION |
detect for Azure |
Specify the region for Azure. |
FDA_AZURE_SUBSCRIPTION_KEY |
detect for Azure |
Specify the subscription key for Azure. |
This library depends on these awesome libraries,
- Dlib: github.com/Kagami/go-face by Kagami
- OpenCV: gocv.io/x/gocv
- Pigo: github.com/esimov/pigo
- TensorFlow: github.com/tensorflow/tensorflow
- Azure Computer Vision API: github.com/Azure/azure-sdk-for-go
- Google Vision API: github.com/googleapis/google-api-go-client
- AWS Rekognition: github.com/aws/aws-sdk-go
- Face++: evalphobia/go-face-plusplus