gildasai

package module
v0.0.0-...-1f5ce45 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MIT Imports: 15 Imported by: 0

README

gildas-ai

GoDoc Build Status Coverage Status Go Report Card

Easy access to AI tasks (starting with object detection) as a web interface, a JSON API and the command line.

wine

faces

faceswap

masks

With Tensorflow and the Go bindings installed, run it with:

go run cmd/gildas-ai/main.go web

Using Docker:

docker run -p 8080:8080 gildasch/gildas-ai

With Tensorflow and the Go bindings installed, run the example:

$ go run examples/classification.go pictures/objects/BrahmaBullFeria09.JPG
2019-02-02 15:59:02.660915: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: ./models/tfhub_imagenet_pnasnet_large_classification/pnasnet_tf_1.8.0
2019-02-02 15:59:02.736106: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { myTag }
2019-02-02 15:59:02.820830: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-02-02 15:59:04.324800: I tensorflow/cc/saved_model/loader.cc:162] Restoring SavedModel bundle.
2019-02-02 15:59:04.940743: I tensorflow/cc/saved_model/loader.cc:138] Running MainOp with key legacy_init_op on SavedModel bundle.
2019-02-02 15:59:04.940778: I tensorflow/cc/saved_model/loader.cc:259] SavedModel load for tags { myTag }; Status: success. Took 2279873 microseconds.
[{pnasnet_tf_1.8.0 0.8123116 oxcart} {pnasnet_tf_1.8.0 0.07762623 ox} {pnasnet_tf_1.8.0 0.0015942967 water_buffalo} {pnasnet_tf_1.8.0 0.0011714806 plow} {pnasnet_tf_1.8.0 0.0009417561 horse_cart} {pnasnet_tf_1.8.0 0.00047737645 amphibian} {pnasnet_tf_1.8.0 0.0003411291 jinrikisha} {pnasnet_tf_1.8.0 0.00033297544 Siamese_cat} {pnasnet_tf_1.8.0 0.00033248836 garbage_truck} {pnasnet_tf_1.8.0 0.0003175597 scabbard}]

Models used for object detection on ImageNet:

Models used for face detection and recognition:

Model used for object detection and segmentation on COCO:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoFaceDetected = errors.New("no face detected")
)

Functions

func DrawMasks

func DrawMasks(dst image.Image, masks []Mask) image.Image

func ExtractFacesFromFolder

func ExtractFacesFromFolder(path string, extractor *Extractor, store FaceStore) (current chan string, errs chan error, done chan bool, total int, err error)

func FaceSwap

func FaceSwap(extractor *Extractor, detector Landmark, dest, src image.Image, blur float64) (image.Image, error)

Types

type Batch

type Batch struct {
	Sources       map[string]image.Image
	Items         []*BatchItem
	Errors        []*BatchError
	Progress      Progress
	Notifications chan Progress
}

func (*Batch) Distances

func (b *Batch) Distances() [][]float32

func (*Batch) Process

func (b *Batch) Process(extractor *Extractor, jobs map[string]image.Image) *Batch

type BatchError

type BatchError struct {
	Name   string
	Source image.Image
	Error  error
}

type BatchItem

type BatchItem struct {
	Name        string
	Source      image.Image
	Cropped     image.Image
	Descriptors Descriptors
}

type Classifier

type Classifier interface {
	Classify(input image.Image) (Predictions, error)
}

type Descriptor

type Descriptor interface {
	Compute(img image.Image) (Descriptors, error)
}

type Descriptors

type Descriptors []float32

func (Descriptors) DistanceTo

func (d Descriptors) DistanceTo(d2 Descriptors) (float32, error)

type Detection

type Detection struct {
	Box   image.Rectangle
	Score float32
	Class float32
}

func Above

func Above(allDetections []Detection, threshold float32) []Detection

type Detector

type Detector interface {
	Detect(img image.Image) ([]Detection, error)
}

type Extractor

type Extractor struct {
	Network    string
	Detector   Detector
	Landmark   Landmark
	Descriptor Descriptor
}

func (*Extractor) Extract

func (e *Extractor) Extract(img image.Image) ([]image.Image, []Descriptors, error)

func (*Extractor) ExtractLandmarks

func (e *Extractor) ExtractLandmarks(img image.Image) ([][]image.Point, []image.Image, error)

func (*Extractor) ExtractPrimitives

func (e *Extractor) ExtractPrimitives(img image.Image) ([]Detection, []Landmarks, []Descriptors, error)

type FaceDistanceStore

type FaceDistanceStore interface {
	StoreFaceDistance(item1, item2 *FaceItem, distance float32) error
	GetFaceDistance(item1, item2 *FaceItem) (float32, bool, error)
}

type FaceItem

type FaceItem struct {
	Identifier  string
	Network     string
	Detection   Detection
	Landmarks   Landmarks
	Descriptors Descriptors
}

type FaceStore

type FaceStore interface {
	StoreFace(item *FaceItem) error
	GetFaces(id string) ([]*FaceItem, bool, error)
	GetAllFaces() ([]*FaceItem, error)
}

type Landmark

type Landmark interface {
	Detect(img image.Image) (*Landmarks, error)
}

type Landmarks

type Landmarks struct {
	Coords []float32
}

func (*Landmarks) Center

func (l *Landmarks) Center(cropped, full image.Image) image.Image

func (*Landmarks) Confidence

func (l *Landmarks) Confidence() float32

func (*Landmarks) DrawOnFullImage

func (l *Landmarks) DrawOnFullImage(cropped, full image.Image) image.Image

func (*Landmarks) DrawOnImage

func (l *Landmarks) DrawOnImage(img image.Image) image.Image

func (*Landmarks) PointsOnImage

func (l *Landmarks) PointsOnImage(img image.Image) []image.Point

type Mask

type Mask struct {
	Mask  image.Image
	Box   image.Rectangle
	Score float32
	Label string
}

type MaskDetector

type MaskDetector interface {
	Detect(img image.Image) ([]Mask, error)
}

type Prediction

type Prediction struct {
	Network string
	Score   float32
	Label   string
}

type PredictionItem

type PredictionItem struct {
	Identifier  string
	Predictions Predictions
}

type PredictionStore

type PredictionStore interface {
	GetPrediction(id string) (*PredictionItem, bool, error)
	StorePrediction(id string, item *PredictionItem) error
	SearchPrediction(query, after string, n int) ([]*PredictionItem, error)
}

type Predictions

type Predictions []Prediction

func (Predictions) Above

func (p Predictions) Above(threshold float32) []Prediction

func (Predictions) Best

func (p Predictions) Best(n int) []Prediction

type Progress

type Progress struct {
	Count  int
	OK     int
	Errors int
}

Jump to

Keyboard shortcuts

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