fda

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 21 Imported by: 0

README

face-detect-annotator

GoDoc Release Build Status Go Report Card Code Climate BCH compliance

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

What's for?

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.

Quick Usage

At first, install golang. And install dependensies.

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

Subcommands

detect

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

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

Example output

_annotated_01

_annotated_02

Environment variables

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.

Credit

This library depends on these awesome libraries,

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEngines

func AddEngines(engine ...engine.Engine)

func Run

func Run()

Types

type CSVHandler

type CSVHandler struct {
	// contains filtered or unexported fields
}

CSVHandler handles CSV file.

func NewCSVHandler

func NewCSVHandler(file string) (*CSVHandler, error)

NewCSVHandler returns initialized *CSVHandler

func (*CSVHandler) ReadAll

func (f *CSVHandler) ReadAll() ([]map[string]string, error)

ReadAll reads all lines from CSV file.

type Config

type Config struct {
	InputPath  string
	OutputPath string

	UseEngineAzureVision  bool
	UseEngineGoogleVision bool
	UseEngineRekognition  bool
	UseEngineFacePlusPlus bool
	UseEnginePigo         bool
	UseEngineDlib         bool
	UseEngineOpenCV       bool
	UseEngineTensorFlow   bool

	AzureRegion           string
	AzureSubscriptionKey  string
	PigoCascadeFilePath   string
	DlibModelDir          string
	OpneCVCascadeFilePath string
	TensorFlowModelPath   string
}

func NewConfig

func NewConfig(useAll bool) Config

func (Config) GetAzureRegion

func (c Config) GetAzureRegion() string

func (Config) GetAzureSubscriptionKey

func (c Config) GetAzureSubscriptionKey() string

func (Config) GetDlibModelDir

func (c Config) GetDlibModelDir() string

func (Config) GetOpenCVCascadeFile

func (c Config) GetOpenCVCascadeFile() string

func (Config) GetPigoCascadeFile

func (c Config) GetPigoCascadeFile() string

func (Config) GetTensorFlowModelFile

func (c Config) GetTensorFlowModelFile() string

type FileHandler

type FileHandler struct {
	// contains filtered or unexported fields
}

FileHandler handles list file.

func NewFileHandler

func NewFileHandler(file string) (*FileHandler, error)

NewFileHandler returns initialized *FileHandler

func (*FileHandler) WriteAll

func (f *FileHandler) WriteAll(lines []string) error

WriteAll writes lines into file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL