Face Data Classes

Overview

Face data in degirum-face is represented by two related classes:

  • FaceAttributes - Contains face identity data (embeddings, attributes, images)

  • FaceRecognitionResult - Includes all FaceAttributes properties plus detection metadata (bounding box, scores, landmarks)

FaceAttributes

Contains face identity data without detection-specific information. Used primarily for enrollment workflows.

Properties

Property
Type
Description

attributes

dict or str or None

Person metadata. Can be any Python dictionary containing person information (first name, last name, address, etc.) or a simple string for the person's name. Examples in this documentation use simple strings for clarity.

db_id

str or None

Database ID if stored

embeddings

list

Face embedding vector(s) (512-D each). May contain multiple embeddings when returned by find_faces_in_file() / find_faces_in_clip()

images

list

Cropped face images (numpy arrays) corresponding to embeddings. May contain multiple images when returned by find_faces_in_file() / find_faces_in_clip()

When It's Used

find_faces_in_file() and find_faces_in_clip() return Dict[int, FaceAttributes] - a mapping of track IDs to face data. Each FaceAttributes object contains:

  • Multiple embeddings - One for each frame where the face was detected (or sampled based on reid_expiration_frames)

  • Multiple images - Corresponding cropped face images for each embedding

  • This accumulated data across frames provides robust face representations for enrollment

Also used as input to FaceTracker.enroll() for batch enrollment.

Usage Example

FaceRecognitionResult

Subclasses FaceAttributes to add detection-specific metadata. Used for real-time recognition results.

Properties

Inherits all FaceAttributes properties (attributes, db_id, embeddings, images) plus:

Property
Type
Description

bbox

list

Bounding box [x1, y1, x2, y2]

detection_score

float

Face detection confidence 0.0-1.0

similarity_score

float or None

Match confidence 0.0-1.0 (None if unknown)

landmarks

array

Facial keypoints (eyes, nose, mouth)

frame_id

int or None

Frame number (when applicable)

Important notes:

  • The embeddings and images lists contain a single item when returned by enroll_image(), enroll_batch(), predict(), or predict_batch(). Access using result.embeddings[0] and result.images[0]. This is different from find_faces_in_file() / find_faces_in_clip() which return multiple embeddings/images per track.

  • When using FaceTracker, track_id is in InferenceResults.results, not as a property. Access via result.results[i].get("track_id")

When It's Used

  • Returned by enroll_image() and enroll_batch()

  • Contained in InferenceResults.faces from predict() and predict_batch()

Usage Examples

Check if face was detected:

Access detection properties:

Access embeddings and cropped images:

FaceTracker - Access tracking data:

Return Types by Method

FaceRecognizer

Method
Return Type

enroll_image()

Optional[FaceRecognitionResult]

enroll_batch()

List[FaceRecognitionResult]

predict()

InferenceResults (.faces property yields FaceRecognitionResult objects)

predict_batch()

Iterator of InferenceResults

FaceTracker

Method
Return Type

predict_batch()

Iterator of InferenceResults (.faces property yields FaceRecognitionResult objects)

find_faces_in_file()

Dict[int, FaceAttributes]

find_faces_in_clip()

Dict[int, FaceAttributes]

Last updated

Was this helpful?