FaceRecognize[{example1name1,example2name2,…}]
generates a ClassifierFunction[…] based on the face examples and names given.
FaceRecognize[{example1,example2,…}{name1,name2,…}]
also generates a ClassifierFunction[…] based on the examples and names given.
FaceRecognize[name1{example11,…},name2{example21,…},…]
uses an association of names with their examples.
FaceRecognize[training,image]
attempts to find faces present in an image and classify them with the given training set.
FaceRecognize[training,image,prop]
returns the specified property prop.
FaceRecognize
FaceRecognize[{example1name1,example2name2,…}]
generates a ClassifierFunction[…] based on the face examples and names given.
FaceRecognize[{example1,example2,…}{name1,name2,…}]
also generates a ClassifierFunction[…] based on the examples and names given.
FaceRecognize[name1{example11,…},name2{example21,…},…]
uses an association of names with their examples.
FaceRecognize[training,image]
attempts to find faces present in an image and classify them with the given training set.
FaceRecognize[training,image,prop]
returns the specified property prop.
Details and Options
- FaceRecognize can be trained to be used for recognizing occurrences of people's faces in images.
- FaceRecognize[training,{image1,image2,…}], returns recognized faces in all imagei.
- By default, FaceRecognize gives a list of names associated with faces it recognizes.
- Possible settings for property prop are:
-
"BoundingBox" bounding Rectangle of the face "Image" a crop of image corresponding to the face "Name" name associated to a face "Position" the position of each face given as {x,y} "Probability" probability for a specific match "RarerProbability" probability to generate a sample with lower PDF than faces in image {prop1,prop2,…} a list of property specifications - The following options can be given:
-
AcceptanceThreshold Automatic threshold to consider an example anomalous ClassPriors Automatic prior probability for a match Method Automatic method to use - By default, a uniform prior is assumed over all the names. Use ClassPriors<|name1p1,…|> to specify different priors.
- By default, the faces are detected automatically. Use Method{"FaceBoxes"boxes} to specify bounding boxes around faces.
- Possible values for boxes can be any of the following:
-
Automatic use FindFaces to find the face boxes (default) Full the whole image is assumed to be one face {bbox1,…} a list of bounding boxes for faces - FaceRecognize uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.
- FaceRecognize may download resources that will be stored in your local object store at $LocalBase, and that can be listed using LocalObjects[] and removed using ResourceRemove.
Examples
open all close allBasic Examples (3)
Recognize if a given person is present in an image:
FaceRecognize[{[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"}, [image]]Create a ClassifierFunction from a set of images:
cf = FaceRecognize[{[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"}]Apply the classifier to a face:
cf[[image]]If a face is not among the training examples, Missing is returned:
cf[[image]]i = [image];
faces = FaceRecognize[{[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"}, i, {"Image", "Name", "BoundingBox"}];
Dataset[faces]Highlight the faces on the original image:
HighlightImage[i, Lookup[faces, "BoundingBox"], ImageLabels -> Lookup[faces, "Name"], PlotRangePadding -> Scaled[.05]]Scope (6)
Create a ClassifierFunction that can recognize faces:
cf = FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}]cf[[image]]FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, [image]]If the face is not recognized, Missing is returned:
FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, [image]]Provide multiple references for the same person:
FaceRecognize[{[image] -> "Dad", [image] -> "Dad", [image] -> "Mom"}, [image]]Group the references in an Association:
FaceRecognize[<|"Dad" -> {[image], [image]}, "Mom" -> {[image]}|>, [image]]FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, [image], {"Name", "Probability"}]Return all supported properties:
FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, [image], All]Recognize multiple faces in an image:
FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, [image], {"Image", "Name"}]//DatasetRecognize multiple faces in a list of images:
Dataset /@ FaceRecognize[{[image] -> "Dad", [image] -> "Mom"}, {[image], [image]}, {"Image", "Name"}]Options (3)
AcceptanceThreshold (1)
Specify AcceptanceThreshold to control how many faces are recognized:
training = {[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"};
test = [image];FaceRecognize[training, test, {"Image", "Name", "RarerProbability"}, AcceptanceThreshold -> .5]//DatasetUse a lower value to recognize faces far from the training distribution:
FaceRecognize[training, test, {"Image", "Name", "RarerProbability"}, AcceptanceThreshold -> .1]//DatasetUsing AcceptanceThreshold0 always returns the nearest class to the test image:
FaceRecognize[training, test, {"Image", "Name", "RarerProbability"}, AcceptanceThreshold -> 0]//DatasetClassPriors (1)
By default, FaceRecognize assumes uniform probability among the classes:
FaceRecognize[<|"Dad" -> {[image]}, "Mom" -> [image], "Daughter" -> [image]|>, [image], All]//DatasetFaceRecognize[{[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"}, [image], All, ClassPriors -> <|"Dad" -> 0.45, "Mom" -> 0.45, "Daughter" -> 0.1|>]//DatasetMethod (1)
By default, faces are detected and extracted from the test image:
training = {[image] -> "Dad", [image] -> "Son1", [image] -> "Son2", [image] -> "Daughter"};test = [image];FaceRecognize[training, test, {"Image", "Name"}]//DatasetUse Method{"FaceBoxes"Full} to assume the test image is a single face crop:
FaceRecognize[training, [image], Method -> {"FaceBoxes" -> Full}]Use Method{"FaceBoxes"bboxes} to recognize faces in the specified bounding boxes bboxes:
bboxes = FindFaces[test, PaddingSize -> Scaled[.1]];
HighlightImage[test, bboxes]FaceRecognize[training, test, {"Image", "Name"}, Method -> {"FaceBoxes" -> bboxes}]//DatasetApplications (4)
Verify whether two faces belong to the same person:
cf = FaceRecognize[<|"Dad" -> {[image], [image]}, "Son" -> {[image], [image]}|>];
SameFaceQ[x_] := SameQ@@cf[x]SameFaceQ[{[image], [image]}]SameFaceQ[{[image], [image]}]Create a function that detects whether an image contains a specified person:
training = <|"Dad" -> {[image], [image]}, "Mom" -> {[image]}|>;ContainsFaceQ[x_, name_] := MemberQ[FaceRecognize[training, x], name]Test whether a person appears in an image:
i = [image];
ContainsFaceQ[i, "Dad"]ContainsFaceQ[i, "Mom"]FaceRecognize can be used to find the face nearest to the test image:
training = {[image] -> "Dad", [image] -> "Mom", [image] -> "Daughter"};
FaceRecognize[training, [image], {"Image", "Name"}, AcceptanceThreshold -> 0]//DatasetBuild a face-search function that returns the position of images that contain a specific person:
cf = FaceRecognize[<|"Dad" -> {[image]}, "Mom" -> {[image]}|>];
ImageFaceSearch[list_, name_] := Flatten@Position[FaceRecognize[cf, list], _ ? (ContainsAny[#, {name}]&), 1]ImageFaceSearch[{[image], [image]}, "Mom"]Possible Issues (2)
Training is still performed with images that may not be faces:
FaceRecognize[<|"name" -> {[image]}, "Dad" -> [image]|>]Testing can also be done with images that may not be faces:
FaceRecognize[<|"Dad" -> {[image]}, "Mom" -> {[image]}|>, [image], Method -> {"FaceBoxes" -> Full}]FaceRecognize expects face crops for all training face samples:
FaceRecognize[{[image] -> "Son", [image] -> "Daughter"}]Compare with already-cropped face samples:
FaceRecognize[{[image] -> "Son", [image] -> "Daughter"}]See Also
FindFaces Classify FaceAlign FacialFeatures ImageIdentify ImageContents TextRecognize ImageKeypoints ImageAlign
Classifiers: NotablePerson
Related Guides
History
Text
Wolfram Research (2020), FaceRecognize, Wolfram Language function, https://reference.wolfram.com/language/ref/FaceRecognize.html.
CMS
Wolfram Language. 2020. "FaceRecognize." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FaceRecognize.html.
APA
Wolfram Language. (2020). FaceRecognize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FaceRecognize.html
BibTeX
@misc{reference.wolfram_2026_facerecognize, author="Wolfram Research", title="{FaceRecognize}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/FaceRecognize.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_facerecognize, organization={Wolfram Research}, title={FaceRecognize}, year={2020}, url={https://reference.wolfram.com/language/ref/FaceRecognize.html}, note=[Accessed: 13-June-2026]}