View Source Evision.Zoo.FaceRecognition.SFace (Evision v0.2.9)
SFace: Sigmoid-Constrained Hypersphere Loss for Robust Face Recognition
Summary
Functions
Default configuration.
Docs in smart cell.
Get feature for the input face image.
Initialize model.
Compare two faces.
Compare two face features.
Model URL and filename of predefined model.
Preprocessing the input face image.
Customizable parameters from smart cell.
Smart cell tasks.
Generate quoted code from smart cell attrs.
Functions
@spec default_config() :: map()
Default configuration.
@spec docs() :: String.t()
Docs in smart cell.
Get feature for the input face image.
Positional arguments
self:
Evision.FaceRecognizerSF.t()
.An initialized FaceRecognizerSF model.
face_image:
Evision.Mat.maybe_mat_in()
.Input face image.
bbox:
Evision.Mat.maybe_mat_in()
.Optional bounding box that specifies the face location in the given image.
Defaults to
nil
.When
bbox
is notnil
,preprocess/3
will crop the face from given image and use the cropped image as the input.Otherwise,
face_image
will be set as the input.
@spec init(binary() | :default_model | :quant_model, nil | Keyword.t()) :: {:error, String.t()} | Evision.FaceRecognizerSF.t()
Initialize model.
Positional arguments
model:
String.t()
|:default_model
|:quant_model
.
Keyword arguments
cache_dir:
String.t()
.Path to the cache directory.
Optional. Defaults to
:filename.basedir(:user_cache, "", ...)
backend:
integer()
.Specify the backend.
Optional. Defaults to
Evision.Constant.cv_DNN_BACKEND_OPENCV()
.target:
integer()
.Specify the target.
Optional. Defaults to
Evision.Constant.cv_DNN_TARGET_CPU()
.
Compare two faces.
Positional Arguments
self:
Evision.FaceRecognizerSF.t()
original:
Evision.Mat.maybe_mat_in()
.Original face.
comparison:
Evision.Mat.maybe_mat_in()
.Comparison face.
Keyword Arguments
distance_type:
atom
.Either
:cosine_similarity
or:l2_norm
. Defaults to:cosine_similarity
.cosine_threshold:
number()
.Defaults to
0.363
.l2_norm_threshold:
number()
.Defaults to
1.128
.detector_module:
module()
.Face detector module. Defaults to
Evision.Zoo.FaceDetection.YuNet
.detector_model:
String.t()
|atom()
.Face detector model name or path to model weights. Defaults to
:default_model
.detector_opts:
Keyword.t()
.Face detector initialization options. Defaults to
[]
.
Return
A map with three keys.
matched:
boolean()
true
if two faces match,false
otherwise.measure:
"cosine_score"
| "l2_norm_distance
"Distance type.
retval:
number()
- When
measure == "cosine_score"
,retval
is the cosine similarity score. - When
measure == "l2_norm_distance"
,retval
is the L2 norm distance.
- When
Compare two face features.
Positional Arguments
self:
Evision.FaceRecognizerSF.t()
face1_feat:
Evision.Mat.maybe_mat_in()
.Feature value of face 1.
face2_feat:
Evision.Mat.maybe_mat_in()
.Feature value of face 2.
Keyword Arguments
distance_type:
atom
.Either
:cosine_similarity
or:l2_norm
. Defaults to:cosine_similarity
.cosine_threshold:
number()
.Defaults to
0.363
.l2_norm_threshold:
number()
.Defaults to
1.128
.
Return
A map with three keys.
matched:
boolean()
true
if two faces match,false
otherwise.measure:
"cosine_score"
| "l2_norm_distance
"Distance type.
retval:
number()
- When
measure == "cosine_score"
,retval
is the cosine similarity score. - When
measure == "l2_norm_distance"
,retval
is the L2 norm distance.
- When
Model URL and filename of predefined model.
Preprocessing the input face image.
infer/3
will call this function automatically.
Positional arguments
self:
Evision.FaceRecognizerSF.t()
.An initialized FaceRecognizerSF model.
face_image:
Evision.Mat.maybe_mat_in()
.Input face image.
bbox:
Evision.Mat.maybe_mat_in()
.Optional bounding box that specifies the face location in the given image.
Defaults to
nil
.When
bbox
is notnil
,preprocess/3
will crop the face from given image and return the cropped image.Otherwise,
face_image
will be returned.
@spec smartcell_params() :: Evision.Zoo.smartcell_params()
Customizable parameters from smart cell.
@spec smartcell_tasks() :: Evision.Zoo.smartcell_tasks()
Smart cell tasks.
A list of variants of the current model.
Generate quoted code from smart cell attrs.