classifier

package
v0.0.0-...-a71e27e Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Height:         299,
	Width:          299,
	Mean:           0,
	Scale:          255,
	InputLayer:     "Placeholder",
	OutputLayer:    "final_result",
	NumPredictions: 5,
}

DefaultConfig is used in the case where a config is not defined by the user

Functions

This section is empty.

Types

type Classifier

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

Classifier is a struct used for classifying images

func NewClassifier

func NewClassifier(graphPath, labelPath string) (*Classifier, error)

NewClassifier creates a new Classifier using the default config

func NewClassifierWithConfig

func NewClassifierWithConfig(graphPath, labelPath string,
	config Config) (*Classifier, error)

NewClassifierWithConfig creates a new image Classifier for processing image predictions

func (*Classifier) ClassifyBytes

func (c *Classifier) ClassifyBytes(img []byte, ext string) ([]Prediction, error)

ClassifyBytes classifies the passed images bytes and returns the predictions as a slice of Predictions

func (*Classifier) ClassifyImage

func (c *Classifier) ClassifyImage(img image.Image) ([]Prediction, error)

ClassifyImage takes an image Image, writes it to a bytes Buffer, performs a classification and returns a slice of predictions

func (*Classifier) ClassifyMultipart

func (c *Classifier) ClassifyMultipart(fh *multipart.FileHeader) ([]Prediction, error)

ClassifyMultipart takes a multipart Fileheader, performs a classification and returns a slice of predictions

func (*Classifier) Close

func (c *Classifier) Close() error

Close closes the Classifier by closing all it's closers ;)

type Config

type Config struct {
	Height, Width           int32
	Mean, Scale             float32
	InputLayer, OutputLayer string
	NumPredictions          int
}

Config is a struct used for configuring the classifier

type Prediction

type Prediction struct {
	Label       string  `json:"label"`
	Probability float32 `json:"probability"`
}

Prediction is a struct containing a class label and the probability of the classified image being the cooresponding label

Jump to

Keyboard shortcuts

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