Documentation
¶
Overview ¶
Package insightface provides pure-Go image processing and dynamic ONNX Runtime loading for SCRFD face detection and ArcFace embeddings.
Model weights and the ONNX Runtime shared library are supplied by the application. Similarity scores returned by this package are cosine similarities, not probabilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyEmbedding = errors.New("insightface: embedding is empty") ErrZeroNormEmbedding = errors.New("insightface: embedding has zero L2 norm") ErrInvalidEmbeddingValue = errors.New("insightface: embedding contains non-finite value") ErrEmbeddingDimensionMismatch = errors.New("insightface: embedding dimension mismatch") )
var ( ErrInvalidConfig = errors.New("insightface: invalid engine config") ErrInvalidContext = errors.New("insightface: context is nil") ErrInvalidImage = errors.New("insightface: invalid image") ErrInvalidLandmarks = errors.New("insightface: invalid landmarks") ErrEngineClosed = errors.New("insightface: engine is closed") ErrInitialization = errors.New("insightface: engine initialization failed") ErrInference = errors.New("insightface: model inference failed") ErrInvalidRuntimeFS = errors.New("insightface: runtime fs is nil") )
var ( ErrEmptyGallery = errors.New("insightface: gallery is empty") ErrEmptyIdentity = errors.New("insightface: identity is empty") ErrIdentityHasNoSample = errors.New("insightface: identity has no samples") ErrDuplicateIdentity = errors.New("insightface: duplicate identity") ErrInvalidMatcherConfig = errors.New("insightface: invalid matcher config") ErrNilMatcher = errors.New("insightface: matcher is nil") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
RuntimeLibrary string
DetectorModel string
RecognizerModel string
DetectorInputWidth int
DetectorInputHeight int
DetectionThreshold float32
NMSThreshold float32
IntraOpThreads int
}
Config identifies the ONNX Runtime library and the two model files. DetectionThreshold and NMSThreshold default to 0.5 and 0.4 when zero. DetectorInputWidth and DetectorInputHeight default to 640 when zero.
type Embedding ¶
type Embedding struct {
// contains filtered or unexported fields
}
Embedding is an immutable, L2-normalized face embedding.
func NewEmbedding ¶
NewEmbedding validates, copies, and L2-normalizes a raw embedding vector.
func (Embedding) CosineSimilarity ¶
CosineSimilarity returns the cosine similarity between two normalized embeddings.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns the ONNX Runtime environment and detector/recognizer sessions. Its inference methods are safe for concurrent use.
func NewFromFS ¶ added in v0.2.0
NewFromFS creates an Engine whose model files and runtime library are read from source. Models are loaded directly from source; the runtime library is materialized because operating-system dynamic loaders require a file path. Config path fields are interpreted as fs.ValidPath names in source.
func (*Engine) Close ¶
Close waits for in-flight inference, then releases both sessions and the ONNX Runtime environment. Repeated calls return the first close result.
type GalleryIdentity ¶
GalleryIdentity stores all enrolled samples for one identity.
type MatchCandidate ¶
MatchCandidate is an identity-level search candidate.
type MatchResult ¶
type MatchResult struct {
Best MatchCandidate
SecondBestDifferent MatchCandidate
Margin float32
Accepted bool
}
MatchResult contains the best identity, second-best different identity, and acceptance decision.
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher performs exact identity-level search over an immutable gallery snapshot.
func NewMatcher ¶
func NewMatcher(config MatcherConfig, gallery []GalleryIdentity) (*Matcher, error)
NewMatcher validates the configuration and installs a copied gallery snapshot.
func (*Matcher) Match ¶
func (m *Matcher) Match(query Embedding) (MatchResult, error)
Match searches the gallery using a normalized query embedding.
func (*Matcher) MatchVector ¶
func (m *Matcher) MatchVector(raw []float32) (MatchResult, error)
MatchVector validates and normalizes a raw query vector before matching.
func (*Matcher) ReplaceGallery ¶
func (m *Matcher) ReplaceGallery(gallery []GalleryIdentity) error
ReplaceGallery swaps the matcher gallery with a copied immutable snapshot.
type MatcherConfig ¶
MatcherConfig controls similarity and margin acceptance for identity matching.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
insightface-assets
command
Command insightface-assets downloads verified ONNX Runtime and model assets during an application's build or packaging stage.
|
Command insightface-assets downloads verified ONNX Runtime and model assets during an application's build or packaging stage. |
|
internal
|
|