Models.emotions_hse package

Submodules

Models.emotions_hse.EmotionsClassifier module

class Models.emotions_hse.EmotionsClassifier.EmotionsClassifier(model_path: Path, use_cuda: bool = False)[source]

Bases: object

Perform classification of emotions on face images.

Load the emotions classifier.

Parameters:
  • model_path (Path) – Path to the .h5 model file.

  • use_cuda (bool, optional) – If True, execute the model on a CUDA device. Defaults to False.

predict(images: List[ndarray] | ndarray) List[Instance][source]

Predict the emotion of a face image.

Parameters:

images (Union[List[np.ndarray], np.ndarray]) – A single image or a list of images of faces, BGR uint8 of shape (H, W, 3).

Returns:

List of Instances with an “emotion” field storing

a Emotion enum and a “confidence” field storing the classification confidence.

Return type:

List[Instance]

Module contents