High level api

Face detection and attributes estimation

High level api is represented VLFaceDetection and VLFaceDetector classes.

VLFaceDetection is container for a face detection. It has properties which are corresponding face estimations. Every property is a singleton which estimates corresponding attribute once and remembers it for next calling.

VLFaceDetector is a wraper on FaceDetector which convert FaceDetection to VLFaceDetection. Class contains a face estimator collection as a class attribute for a detections attributes estimation. If you want specify an unique VLFaceEngine for the instance of VLFaceDetector you should set the FaceEngine in the init of the class.

Example

>>> from lunavl.sdk.luna_faces import VLFaceDetector
>>> from lunavl.sdk.luna_faces import VLImage
>>> detector = VLFaceDetector()
>>> image = VLImage.load(
...         url='https://cdn1.savepice.ru/uploads/2019/4/15/aa970957128d9892f297cdfa5b3fda88-full.jpg')
>>> detection = detector.detectOne(image)
>>> detection.basicAttributes.age
16.0
>>> detection.emotions.predominateEmotion.name
'Happiness'

Module realize hight level api for estimate face attributes

class lunavl.sdk.luna_faces.VLFaceDetection(coreDetection, image, estimatorCollection)[source]

High level detection object. .. attribute:: estimatorCollection

collection of estimators

type

FaceEstimatorsCollection

_emotions

lazy load emotions estimations

Type

Optional[Emotions]

_eyes

lazy load eye estimations

Type

Optional[EyesEstimation]

_mouthState

lazy load mouth state estimation

Type

Optional[MouthStates]

_basicAttributes

lazy load basic attribute estimation

Type

Optional[BasicAttributes]

_gaze

lazy load gaze direction estimation

Type

Optional[GazeEstimation]

_warpQuality

lazy load warp quality estimation

Type

Optional[Quality]

_headPose

lazy load head pose estimation

Type

Optional[HeadPose]

_ags

lazy load ags estimation

Type

Optional[float]

_transformedLandmarks68

lazy load transformed landmarks68

Type

Optional[Landmarks68]

ags

Get ags of the detection.

Returns

emotions

Return type

float

asDict()[source]

Convert to dict.

Returns

All estimated attributes will be added to dict

Return type

Dict[str, Union[dict, list, float]]

basicAttributes

Get all basic attributes of the detection.

Returns

basic attributes (age, gender, ethnicity)

Return type

BasicAttributes

descriptor

Get a face descriptor from warp

Returns

mouth state

Return type

FaceDescriptor

emotions

Get emotions of the detection.

Returns

emotions

Return type

Emotions

eyes

Get eyes estimation of the detection.

Returns

eyes estimation

Return type

EyesEstimation

gaze

Get gaze direction.

Returns

gaze direction

Return type

GazeEstimation

headPose

Get a head pose of the detection. Estimation bases on 68 landmarks

Returns

head pose

Return type

HeadPose

mouthState

Get a mouth state of the detection

Returns

mouth state

Return type

MouthStates

warp

Get warp from detection.

Returns

warp

Return type

Warp

warpQuality

Get quality of warped image which corresponding the detection :returns: quality

Return type

Quality

class lunavl.sdk.luna_faces.VLFaceDetector(detectorType=<DetectorType.FACE_DET_DEFAULT: 'Default'>, faceEngine=None)[source]

High level face detector. Return VLFaceDetection instead simple FaceDetection.

estimatorCollection

face estimator collections for new detections.

Type

FaceEstimatorsCollection

_faceDetector

face detector

Type

FaceDetector

faceEngine

face engine for detector and estimators, default FACE_ENGINE.

Type

VLFaceEngine

detect(images, limit=5)[source]

Batch detect faces on images.

Parameters
  • images – input images list. Format must be R8G8B8

  • limit – max number of detections per input image

Returns

return list of lists detection, order of detection lists is corresponding to order input images

Return type

List[List[VLFaceDetection]]

detectOne(image, detectArea=None)[source]

Detect just one best detection on the image.

Parameters
  • image – image. Format must be R8G8B8 (todo check)

  • detectArea – rectangle area which contains face to detect. If not set will be set image.rect

Returns

face detection if face is found otherwise None

Return type

Union[None, VLFaceDetection]

estimatorsCollection = <lunavl.sdk.estimator_collections.FaceEstimatorsCollection object>

estimators collection of class for usual creating detectors

faceEngine = <lunavl.sdk.faceengine.engine.VLFaceEngine object>

a global instance of FaceEngine for usual creating detectors

class lunavl.sdk.luna_faces.VLWarpedImage(body, filename='', vlImage=None)[source]

High level sample object.

_emotions

lazy load emotions estimations

Type

Optional[Emotions]

_mouthState

lazy load mouth state estimation

Type

Optional[MouthStates]

_basicAttributes

lazy load basic attribute estimation

Type

Optional[BasicAttributes]

_warpQuality

lazy load warp quality estimation

Type

Optional[Quality]

asDict()[source]

Convert to dict.

Returns

All estimated attributes will be added to dict

Return type

Dict[str, Union[dict, list, float]]

basicAttributes

Get all basic attributes of the detection.

Returns

basic attributes (age, gender, ethnicity)

Return type

BasicAttributes

descriptor

Get a face descriptor from warp

Returns

mouth state

Return type

FaceDescriptor

emotions

Get emotions of the detection.

Returns

emotions

Return type

Emotions

estimatorsCollection = <lunavl.sdk.estimator_collections.FaceEstimatorsCollection object>

estimators collection of class for usual creating detectors

mouthState

Get a mouth state of the detection

Returns

mouth state

Return type

MouthStates

warp

Support VLFaceDetection interface.

Returns

self

Return type

Warp

warpQuality

Get quality of warped image which corresponding the detection :returns: quality

Return type

Quality