model

package
v0.0.0-...-2ad892a Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Height = 100
	Width  = 100
)
View Source
var (
	LPPFeatureType = "LPP"
	PCAFeatureType = "PCA"
	LDAFeatureType = "LDA"
)
View Source
var MAX_FLOAT_VALUE = 10000000.

Functions

func AssignLabel

func AssignLabel(trainingSet []*ProjectedTrainingMatrix, testFace *algorithm.Matrix, k int, computeDistance func(a, b *algorithm.Matrix) float64) (string, float64)

func Classify

func Classify(neighbors []*ProjectedTrainingMatrix) (string, float64)

func GetIndexesOfKEigenvalues

func GetIndexesOfKEigenvalues(d []float64, k int) []int

func NewMix

func NewMix(i int, v float64) *mix

func Resize

func Resize(img image.Image) *image.NRGBA

func SaveImageTo

func SaveImageTo(img *image.Gray16, path string)

func SetConfigFile

func SetConfigFile(filepath string)

func StreamToVector

func StreamToVector(img image.Image) []float64

func SumPixels

func SumPixels(face []float64, width int, height int) float64

func ToImage

func ToImage(face *algorithm.Matrix) *image.Gray16

func ToMatrix

func ToMatrix(path string) *algorithm.Matrix
func ToMatrix(width, height int, face []float64) *algorithm.Matrix {
	m := height
	n := width
	fmt.Println(face)
	mat := algorithm.NewMatrix(n * m,1)
	for p:= 0; p < n; p++ {
		for  q := 0; q < m; q++ {
			mat.A[p*m +q][0] = face[q*p]
		}
	}
	fmt.Println(mat)
	return mat
}

func ToPgm

func ToPgm(path string) string

func ToVector

func ToVector(path string) (int, int, []float64)

Types

type Config

type Config struct {
	FaceDetectionConfigurationFile string `json:"opencvfile"`
	FaceRecognitionBasePath        string `json:"facerecognitionbasepath"`
}

func GetConfig

func GetConfig() *Config

func SetAndLoad

func SetAndLoad(filepath string) *Config

func (*Config) GetDataLib

func (conf *Config) GetDataLib() string

func (*Config) GetFaceRecognitionBasePath

func (conf *Config) GetFaceRecognitionBasePath() string

func (*Config) GetTmpDirectory

func (conf *Config) GetTmpDirectory() string

type CosineDissimilarity

type CosineDissimilarity struct {
}

func (*CosineDissimilarity) GetDistance

func (c *CosineDissimilarity) GetDistance(a, b *algorithm.Matrix) float64

type Euclidean

type Euclidean struct {
}

func (*Euclidean) GetDistance

func (e *Euclidean) GetDistance(a, b *algorithm.Matrix) float64

type FaceRecognitionItem

type FaceRecognitionItem struct {
	User           User     `json:"user"`
	TrainingImages []string `json:"_"`
}

func NewFaceRecognitionItem

func NewFaceRecognitionItem() *FaceRecognitionItem

func (*FaceRecognitionItem) DetectFaces

func (fi *FaceRecognitionItem) DetectFaces(images []string) int

func (*FaceRecognitionItem) DetectFacesFromImages

func (fi *FaceRecognitionItem) DetectFacesFromImages(images []image.Image)

func (*FaceRecognitionItem) GetKey

func (fi *FaceRecognitionItem) GetKey() string

type FaceRecognitionLib

type FaceRecognitionLib struct {
	Items                  map[string]*FaceRecognitionItem `json:"facerecognition_lib"`
	MinimalNumOfComponents int
	Width                  int
	Height                 int
}

func GetFaceRecognitionLib

func GetFaceRecognitionLib() *FaceRecognitionLib

func NewFaceRecognitionLib

func NewFaceRecognitionLib() *FaceRecognitionLib

func (*FaceRecognitionLib) AddUserFace

func (fl *FaceRecognitionLib) AddUserFace(u *FaceRecognitionItem)

func (*FaceRecognitionLib) FindFace

func (fl *FaceRecognitionLib) FindFace(img *image.Image) ([]*algorithm.Matrix, []string)

func (*FaceRecognitionLib) GetTrainer

func (fl *FaceRecognitionLib) GetTrainer(featureType string) *Trainer

func (*FaceRecognitionLib) ImportIntoDB

func (*FaceRecognitionLib) MatrixNVectorize

func (fl *FaceRecognitionLib) MatrixNVectorize(img *image.Image) *algorithm.Matrix

func (*FaceRecognitionLib) NormalizeImageLength

func (fl *FaceRecognitionLib) NormalizeImageLength()

func (*FaceRecognitionLib) Save

func (fl *FaceRecognitionLib) Save()

func (*FaceRecognitionLib) Train

func (fl *FaceRecognitionLib) Train(featureType string)

type FeatureExtraction

type FeatureExtraction struct {
	TrainingSet          []*algorithm.Matrix
	Labels               []string
	NumOfComponents      int
	MeanMatrix           *algorithm.Matrix
	W                    *algorithm.Matrix
	ProjectedTrainingSet []*ProjectedTrainingMatrix
}

func NewFeatureExtraction

func NewFeatureExtraction() *FeatureExtraction

type L1

type L1 struct {
}

func (*L1) GetDistance

func (l *L1) GetDistance(a, b *algorithm.Matrix) float64

type LDA

type LDA struct {
	FeatureExtraction *FeatureExtraction
}

func NewLDA

func NewLDA(trainingSet []*algorithm.Matrix, labels []string, numOfComponents int) *LDA

func (*LDA) GetMean

func (l *LDA) GetMean(m []algorithm.Matrix) *algorithm.Matrix

type LPP

type LPP struct {
	FeatureExtraction *FeatureExtraction
}

func NewLPP

func NewLPP(trainingSet []*algorithm.Matrix, labels []string, numOfComponents int) *LPP

type MixArray

type MixArray struct {
	Mixes []*mix
}

func NewMixArrays

func NewMixArrays(n int) *MixArray

func (*MixArray) Len

func (m *MixArray) Len() int

func (*MixArray) Less

func (m *MixArray) Less(i, j int) bool

func (*MixArray) Swap

func (m *MixArray) Swap(i, j int)

func (*MixArray) Tostring

func (m *MixArray) Tostring() string

type PCA

type PCA struct {
	FeatureExtraction *FeatureExtraction
}

func NewPCA

func NewPCA(trainingSet []*algorithm.Matrix, labels []string, numOfComponents int) *PCA

func (*PCA) GetFeature

func (p *PCA) GetFeature(input []*algorithm.Matrix, k int) *algorithm.Matrix

func (*PCA) GetMean

func (p *PCA) GetMean(input []*algorithm.Matrix) *algorithm.Matrix

type ProjectedTrainingMatrix

type ProjectedTrainingMatrix struct {
	Matrix   *algorithm.Matrix
	Label    string
	Distance float64
}

func FindKNN

func FindKNN(trainingSet []*ProjectedTrainingMatrix, testFace *algorithm.Matrix, k int, computeDistance func(a, b *algorithm.Matrix) float64) []*ProjectedTrainingMatrix

func NewProjectedTrainingMatrix

func NewProjectedTrainingMatrix(m *algorithm.Matrix, l string) *ProjectedTrainingMatrix

func NewSliceProjectedTrainingMatrix

func NewSliceProjectedTrainingMatrix(input []*ProjectedTrainingMatrix) []*ProjectedTrainingMatrix

type Trainer

type Trainer struct {
	Metric            func(a, b *algorithm.Matrix) float64
	FeatureType       string
	FeatureExtraction *FeatureExtraction
	NumOfComponents   int
	K                 int
	TrainingSet       []*algorithm.Matrix
	TrainingLabels    []string
	Model             []*ProjectedTrainingMatrix
}

func NewTrainer

func NewTrainer() *Trainer

func NewTrainerArgs

func NewTrainerArgs(featureType string, k int, numOfComponents int, distanceFunction func(a, b *algorithm.Matrix) float64) *Trainer

func (*Trainer) Add

func (t *Trainer) Add(m *algorithm.Matrix, label string)

func (*Trainer) Recognize

func (t *Trainer) Recognize(matrix *algorithm.Matrix) (string, float64)

func (*Trainer) Train

func (t *Trainer) Train()

type User

type User struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

func (*User) Key

func (u *User) Key() string

func (*User) ToString

func (u *User) ToString() string

Jump to

Keyboard shortcuts

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