Automated Detection of Equine Facial Action Units

5
Automated Detection of Equine Facial Action Units Zhenghong Li 1,2 Sofia Broom´ e 1 Pia Haubro Andersen 4 Hedvig Kjellstr¨ om 1,3 1 KTH Royal Institute of Technology, Sweden sbroome,[email protected] 2 Stony Brook University, USA [email protected] 3 Silo AI, Sweden 4 Swedish University of Agricultural Sciences, Sweden [email protected] Abstract— The recently developed Equine Facial Coding System (EquiFACS) provides a precise and exhaustive, but laborious, manual labelling method of facial action units of the horse. To automate parts of this process, we propose a Deep Learning-based method to detect EquiFACS units automatically from images. We use a cascade framework; we firstly train several object detectors to detect the predefined Region-of- Interest (ROI), and secondly apply binary classifiers for each action unit in related regions. We experiment with both regular CNNs and a more tailored model transferred from human facial action unit recognition. Promising initial results are presented for nine action units in the eye and lower face regions. Code for the project is publicly available. I. I NTRODUCTION The horse is a highly social species, and facial commu- nication is of utmost importance for the function of the herd. In accordance, the horse has a remarkable repertoire of facial expressions which may be described by 17 degrees of freedom, so called actions units [20]. This repertoire is smaller than for humans which have 27 action units [5], but larger than for example the chimpanzee repertoire of 13 action units [3]. While the detailed analysis of the facial expressions of people to assess their emotions is mature [4], almost nothing is known about the association between facial activity and emotional states of animals. This is primarily due to the lack of self-report of emotions and other inner states in animals. Nevertheless, facial expressions are expected to convey important information of animal welfare [9], but methodologies for investigations are lacking. In the past few years, great progress has been made in the field of Computer Vision. With the adoption of Deep Learning models, such as Convolutional Neural Networks (CNN), in Computer Vision, in some tasks such as image classification, the accuracies of computer models are even competitive with human capabilities. Related works for hu- man facial action unit detection have also made progress in these years. Therefore, in this work, we investigate the possibility of automatically recognizing horse facial action units. We currently focus on how to do this from still images. Even if the facial configurations of horses and humans are very different, a remarkably high number of action units are conserved across species [21]. We therefore transfer methods for human action unit detection to horses. There are two main contributions of our project: We propose a cascade framework for the recognition of horse facial action units. We apply standard models for general image classifica- tion as well as for human facial action unit recognition to horses within our framework and compare their performance across multiple experimental settings. II. RELATED WORK Facial expressions can be described as combinations of different facial action units. A facial action unit is based on the visible movement of a facial muscle lying under the skin [18]. In 1978, Ekman and Friesen proposed the Facial Action Coding System (FACS) [5]. Through electrically stimulating individual muscles and learning to control them voluntarily, each action unit was associated with one or more facial muscles [2]. The recording of facial actions is entirely atheoretical; any inference of their meaning takes places during the later analysis. In 2002, Ekman et al. [6] proposed the final version of human FACS which since has been widely used for research in human emotion recognition. Inspired by the progress of human FACS, Wathan et al. [20] created EquiFACS. As for FACS, EquiFACS consists of action units (AUs) and action descriptors (ADs). In addition, the movements of the ears of horses are specifically named as ear action descriptors (EADs). Until recently, EquiFACS has not been used for research in animal emo- tions, due to the very time consuming manual labelling. An initial study of facial expressions of pain in horses [14] showed that pain indeed is associated with increased frequencies of certain facial AUs. These AUs were anatom- ically located in the ear region, around the eyes, nostrils and muzzle. A major limitation of that study was the small sample size, which was attributed to the extremely resource demanding, but necessary, hand labelling of the videos. A prerequisite for more research in animal emotions using AUs is therefore development of methods that allow automated AU detection. Pain recognition in animals via pre-defined facial features has previously been explored for sheep [12], [13] and for horses and donkeys [8]. Compared to our method, these works rely on more coarse-grained underlying facial expres- sion representations, albeit using precise landmark extraction to extract regions of interest. The simpler structure increases robustness but limits the range and precision of expressions that can be represented. A third approach is to learn the underlying representation of pain expressions in horses from arXiv:2102.08983v2 [cs.CV] 4 May 2021

Transcript of Automated Detection of Equine Facial Action Units

Page 1: Automated Detection of Equine Facial Action Units

Automated Detection of Equine Facial Action Units

Zhenghong Li1,2 Sofia Broome1 Pia Haubro Andersen4 Hedvig Kjellstrom1,3

1 KTH Royal Institute of Technology, Sweden sbroome,[email protected] Stony Brook University, USA [email protected] 3 Silo AI, Sweden4 Swedish University of Agricultural Sciences, Sweden [email protected]

Abstract— The recently developed Equine Facial CodingSystem (EquiFACS) provides a precise and exhaustive, butlaborious, manual labelling method of facial action units of thehorse. To automate parts of this process, we propose a DeepLearning-based method to detect EquiFACS units automaticallyfrom images. We use a cascade framework; we firstly trainseveral object detectors to detect the predefined Region-of-Interest (ROI), and secondly apply binary classifiers for eachaction unit in related regions. We experiment with both regularCNNs and a more tailored model transferred from human facialaction unit recognition. Promising initial results are presentedfor nine action units in the eye and lower face regions. Codefor the project is publicly available.

I. INTRODUCTION

The horse is a highly social species, and facial commu-nication is of utmost importance for the function of theherd. In accordance, the horse has a remarkable repertoireof facial expressions which may be described by 17 degreesof freedom, so called actions units [20]. This repertoire issmaller than for humans which have 27 action units [5],but larger than for example the chimpanzee repertoire of 13action units [3].

While the detailed analysis of the facial expressions ofpeople to assess their emotions is mature [4], almost nothingis known about the association between facial activity andemotional states of animals. This is primarily due to thelack of self-report of emotions and other inner states inanimals. Nevertheless, facial expressions are expected toconvey important information of animal welfare [9], butmethodologies for investigations are lacking.

In the past few years, great progress has been made inthe field of Computer Vision. With the adoption of DeepLearning models, such as Convolutional Neural Networks(CNN), in Computer Vision, in some tasks such as imageclassification, the accuracies of computer models are evencompetitive with human capabilities. Related works for hu-man facial action unit detection have also made progress inthese years.

Therefore, in this work, we investigate the possibilityof automatically recognizing horse facial action units. Wecurrently focus on how to do this from still images. Evenif the facial configurations of horses and humans are verydifferent, a remarkably high number of action units areconserved across species [21]. We therefore transfer methodsfor human action unit detection to horses.

There are two main contributions of our project:

• We propose a cascade framework for the recognition ofhorse facial action units.

• We apply standard models for general image classifica-tion as well as for human facial action unit recognitionto horses within our framework and compare theirperformance across multiple experimental settings.

II. RELATED WORK

Facial expressions can be described as combinations ofdifferent facial action units. A facial action unit is basedon the visible movement of a facial muscle lying under theskin [18]. In 1978, Ekman and Friesen proposed the FacialAction Coding System (FACS) [5]. Through electricallystimulating individual muscles and learning to control themvoluntarily, each action unit was associated with one ormore facial muscles [2]. The recording of facial actions isentirely atheoretical; any inference of their meaning takesplaces during the later analysis. In 2002, Ekman et al. [6]proposed the final version of human FACS which since hasbeen widely used for research in human emotion recognition.

Inspired by the progress of human FACS, Wathan etal. [20] created EquiFACS. As for FACS, EquiFACS consistsof action units (AUs) and action descriptors (ADs). Inaddition, the movements of the ears of horses are specificallynamed as ear action descriptors (EADs). Until recently,EquiFACS has not been used for research in animal emo-tions, due to the very time consuming manual labelling.An initial study of facial expressions of pain in horses[14] showed that pain indeed is associated with increasedfrequencies of certain facial AUs. These AUs were anatom-ically located in the ear region, around the eyes, nostrilsand muzzle. A major limitation of that study was the smallsample size, which was attributed to the extremely resourcedemanding, but necessary, hand labelling of the videos. Aprerequisite for more research in animal emotions using AUsis therefore development of methods that allow automatedAU detection.

Pain recognition in animals via pre-defined facial featureshas previously been explored for sheep [12], [13] and forhorses and donkeys [8]. Compared to our method, theseworks rely on more coarse-grained underlying facial expres-sion representations, albeit using precise landmark extractionto extract regions of interest. The simpler structure increasesrobustness but limits the range and precision of expressionsthat can be represented. A third approach is to learn theunderlying representation of pain expressions in horses from

arX

iv:2

102.

0898

3v2

[cs

.CV

] 4

May

202

1

Page 2: Automated Detection of Equine Facial Action Units

raw data in an end-to-end manner [1], without imposing anydesigned coding system. In [1], the authors used a recurrentneural network structure that exploited both temporal andspatial information from video of horses, and found that tem-poral information (video) is important for pain assessment.A future research direction is to study the interplay betweendata-driven learned emotion expression representations andEquiFACS.

Ever since Krizhevsky et al. proposed AlexNet [10], deepCNNs have been replacing the traditional methods in imageclassification fields with their outstanding performance. AfterAlexNet, deeper models such as VGG [19] and ResNet [7]have been proposed and applied as feature extractors invarious fields. In our work, we chose CNNs as the classifiersof AUs.

CNNs are also widely used for object detection. In thiswork, an object detector network is employed to detect pre-defined regions of interest (ROI). Object detectors can bedivided into two categories: one-stage methods and two-stage methods. One-stage methods such as YOLOv3 [15] andSSD [11] generate anchor proposals and perform detectionin one stage and can be trained in an end-to-end manner.Two-stage methods such as Faster-RCNN [16] first generateanchor box proposals via a region proposal network and thenuse ROI-Pooling to crop the related features out for the finalprediction.

Previous works in human facial AU recognition from stillimages usually employ regional learning. Zhao et al. [22] in-serted a region layer into a classical CNN to learn the featuresof AUs on sparse facial regions, and trained the model viamulti-label learning. Shao et al. [18] further cascaded regionlayers with different sizes of patches together and employedan attention mechanism for AU detection.

III. DATA

In total, the dataset used for this study contains 20180labeled video clips across 31 AUs or ADs, with durationsranging from 0.05 seconds to 2 minutes. The data is recordedacross eight horse subjects. We randomly sample one framefrom each labeled clip to use as input for our classifier.

The class distribution is quite uneven. There are, e.g., 5280labeled samples for EAD104 (ear rotator), but only one forAD160 (lower lip relax). For our experiments, we selectedthe 11 categories listed in Table I. Each contains more than200 labeled crops, which we consider to be the minimalsufficient number of samples for the training, validation andtest sets. However, we quickly found that the ear actiondescriptors were not suited to detect using still images, sincethey are defined by movement. For this reason, we chose toexclude EAD101 and EAD104 from our experiments.

We perform subject-exclusive eight-fold validation acrossthe different horses, using six for training, one for validationand one for testing in each fold.

As for the sampled images, the original sizes are 1910×1080 or 1272× 720. For the face, eye and lower face crops,we first zero-pad the detected regions, to then resize them.Face crops are resized to 512×512, as they are then fed into

TABLE ISELECTED ACTION UNITS (ACTION DESCRIPTORS).

Code AU (AD) Labeled video clipsAD1 Eye white increase 394AD19 Tougue show 443AD38 Nostril dilator 696AU101 Inner brow raiser 1918AU145 Blink 3856AU25 Lips part 478AU47 Half blink 1816AU5 Upper lid raiser 208

AUH13 Nostril lift 353EAD101 Ears forward 4778EAD104 Ear rotator 5240

YOLOv3-tiny whose default input size is 416 × 416. Eyeand lower face crops are resized to 64× 64 for the modifiedDRML and modified AlexNet classifiers, which can run onsmaller input sizes.

IV. METHODOLOGY1

Considering the class imbalance, the dataset is not suitedfor multi-label classification. Initial tests were carried outin this fashion, but the model would get stuck in a localminimum where it predicted the dominant AUs to be trueand the others to be false. Therefore, we use multiple binaryclassifiers for the nine classes. For each binary classifierset-up, we randomly sample negative samples to make thenumber of positive and negative samples equal. This wasdone for both the training, validation and test split of thedata.

Further, binary classification for facial AUs is a highlyfine-grained image classification task. As such, directly ap-plying networks for common image classification tasks willfail to reach acceptable results. Noticing that the horse face isusually only a fraction of the raw frame (Fig. 1), and inspiredby the framework for sheep pain estimation by Lu et al. [12],we propose our Deep Learning cascade framework (Fig. 2)for horse facial AU recognition. For each input image, wefirst detect the horse face and cut it out. Then, depending onthe facial location of the action unit class, we extract eitherthe eye region or the lower face region (including nostrilsand mouth) from the detected face region. This is becausethe eye regions and the lower face regions naturally take upeven smaller fractions of the raw frames, and the detectornetwork is not able to detect these regions directly. Finally,two CNN-based models for image classification are used asbinary classifiers for the respective classes belonging to theseregions. Note that the classifiers are trained separately foreach class.

A. ROI Detector

YOLOv3 [15] is a widely used object detector, with highperformance with respect to both average precision and com-putation speed. For our task, we chose one of its light-weightimplementations, YOLOv3-tiny for the ROI detection, since

1Code for all methods presented in this section is publiclyavailable in the repository https://github.com/ZhenghLi/Automated-Detection-of-Equine-Facial-Action-Units.

Page 3: Automated Detection of Equine Facial Action Units

Fig. 1. A raw example of AD1 eye white increase in our dataset

Fig. 2. Our cascade framework for EquiFACS recognition. Note that eachpart is trained separately

it could be readily applied to our dataset with an acceptableperformance. Knowing that existing object detectors do notperform well on objects that are small relative to the frame,we chose to cascade the detectors together to detect smallregions. Specifically, we first trained a face detector, and thentrained an eye region and a lower face detector, respectively,on the detected face crops.

B. Classifier

DRML [22] is a classical model for human facial AUdetection. We first experimented with directly training iton raw frames as well as on detected face regions. Then,we applied it to detected eye or lower face regions, whilereplacing the region layer with a simple 3 × 3 convolutionlayer. In addition, we also applied the AlexNet [10] as aclassifier on all three levels of detail. When using DRML andAlexNet for crops of the eye or lower face regions (resizingthe input to a resolution of 64 × 64), we modified the firstconvolutional layer in each model to use 5×5 convolutionalkernels (instead of 11× 11 as in the original models).

V. EXPERIMENTAL RESULTS

A. Model Exploration on AU101

First, we explore which frameworks are suitable for horsefacial AU recognition. We evaluate these on AU101 (innerbrow raiser), because the key features of AU101 (the angularshape of the inner brows) are relatively easy to recognize inimages and the class has more labeled samples than otherrelatively ”easy” classes. Using eight-fold validation, weevaluate the performance of the DRML model and AlexNet

TABLE IIBINARY CLASSIFICATION RESULTS FOR AU101, PRECEDED BY REGION

DETECTION OF DIFFERENT PRECISION: WHOLE FRAME, HEAD REGION,OR MOST PRECISELY, EYE REGION. MEAN AND STANDARD DEVIATION

RESULTING FROM EIGHT-FOLD CROSS-VALIDATION.

Region DRML AlexNetAccuracy F1-score Accuracy F1-score

Frame 54.0±7.1 46.9±10.9 52.8±5.8 46.0±11.6Face 53.7±6.0 47.6±12.9 53.6±4.3 51.0±13.5Eye 58.1±4.8 60.7±6.9 57.0±6.5 58.0±10.7

TABLE IIIBINARY CLASSIFICATION FOR EIGHT OTHER AUS. EYE REGION

DETECTION IS USED FOR AD1, AU145, AU47, AND AU5, WHILE

LOWER FACE REGION DETECTION IS USED FOR AU25, AD19, AD38,AND AUH13.

AU DRML AlexNetAccuracy F1-score Accuracy F1-score

AD1 65.2±6.0 64.0±10.4 64.1±6.2 60.8±8.2AU145 57.5±4.2 57.8±5.1 59.9±2.4 57.2±7.9AU47 49.6±3.7 50.7±9.1 49.4±2.3 47.9±8.3AU5 60.5±8.1 57.6±8.9 57.9±8.8 56.9±12.6

AU25 59.8±6.7 57.8±9.6 63.6±8.2 57.9±12.6AD19 64.6±5.0 59.6±8.9 61.8±5.0 58.0±8.1AD38 58.5±4.1 57.3±6.4 60.9±7.1 57.7±10.1

AUH13 58.6±2.7 53.2±6.4 60.0±4.3 56.1±9.1

on raw frames, detected face regions, and detected eyeregions, in turn. Results are shown in Table II.

For both DRML and AlexNet, we observe that there is nolarge difference between classification on the raw frames andon face crops. The results are merely random. We furtheremployed Grad-CAM [17] to visualize what the criticalportions of the images were for these classifiers (Fig. 3).According to the visualization results, both classifiers failedto focus on the relevant regions, i.e., the inner brows, bothfor the raw frames and face crops.

Our hope was that if we forced the classifiers to focus onlyon the eye regions, they could learn something meaningfulfor the recognition of AU101. The last two columns in Fig.3 show that although the classifiers sometimes still lookeverywhere in the eye regions, they become able to payattention to the exact inner brows in some cases. Based onthese results, we believe that for the task at hand, it is criticalto give pre-defined ROIs as input to the classifiers.

B. Model Validation on Eight Other AUs

Based on the experiments on AU101, we carried outexperiments on eight other AUs on the eye and lower faceregions The results are shown in Table III.

In these experiments, generally, the difference is not largebetween the performance of DRML and AlexNet, but theDRML typically showed a more stable performance acrossthe different subject folds than AlexNet. For most AUs, theresults lie close to the those on AU101, except for AU47(half blink). Moreover, AU47 is sometimes confused withAU145 (blink). We believe that this is because the differencebetween the presence or absence of AU47 is too small in stillimages. Our framework would need to be extended to takesequences of images as input to to detect it, as in e.g. [1].

Page 4: Automated Detection of Equine Facial Action Units

Fig. 3. Grad-CAM saliency maps of the models for binary classification of AU101

Fig. 4. Grad-CAM saliency maps of the different models for binary classification of the other eight AUs. Examples with precise focus are shown on theeven columns

Similarly, we note that theoretically, we cannot distinguishAU145 (blink) from AU143 (eye closure) in still imagesbecause the sole difference between these is the duration ofthe time the eyes remain closed. However, since the AU143class has too few samples in our dataset, we did not include itin our experiments. Therefore, the bias of our dataset causesthis ”good” result of AU145.

To further validate our models, we visualized their saliencymaps, shown in Fig. 4. Similar to AU101, the classifiers arein many cases able to pay attention to the correct regions,such as eyelid, nostril, corner of mouth, and tongue (the evencolumns in Fig. 4), if we crop the pre-defined related regionsout before training for classification.

VI. CONCLUSIONS

In this project, we proposed a framework for automateddetection of equine facial AUs and descriptors and showedthat our framework could help the classifiers to focus onmore relevant regions and to improve the classificationaccuracy.

There are many avenues to explore in the future. Firstly,because the dataset used in this article is quite small andunbalanced, deeper models such as VGG and ResNet cannotbe trained well, and multi-label learning is not suitable. Thesetechniques will be explored when we collect enough data.Secondly, we are aware that the attention of our model is notfully stable, and we would like to add an attention mecha-nism to the classification models to make our frameworkmore effective. Finally, our framework currently does notwork well for the EADs. This is probably due to the manypossible positions of the ears, which are extremely mobileand rarely still in horses. EADs are therefore probably bestdetermined from video. This is also the case for the blinkingAUs (AU47 and AU145). A future direction is therefore toextend the method to the temporal domain.

ACKNOWLEDGMENTS

The authors would like to thank Elin Hernlund, KatrinaAsk, and Maheen Rashid for valuable discussions. This workhas been funded by Vetenskapsradet and FORMAS.

Page 5: Automated Detection of Equine Facial Action Units

REFERENCES

[1] S. Broome, K. B. Gleerup, P. H. Andersen, and H. Kjellstrom.Dynamics are important for the recognition of equine pain in video. InIEEE Conference on Computer Vision and Pattern Recognition, 2019.

[2] J. F. Cohn, Z. Ambadar, and P. Ekman. Observer-based measurementof facial expression with the Facial Action Coding System. The Hand-book of Emotion Elicitation and Assessment, 1(3):203–221, 2007.

[3] R. Diogo, B. A. Wood, M. A. Aziz, and A. Burrows. On the origin,homologies and evolution of primate facial muscles, with a particularfocus on hominoids and a suggested unifying nomenclature for thefacial muscles of the Mammalia. J. Anatomy, 215, 2009.

[4] P. Ekman. Facial expression and emotion. American Psychologist,48(4):384–392, 1993.

[5] P. Ekman and W. V. Friesen. Facial Action Coding System. ConsultingPsychologists Press, 1978.

[6] P. Ekman, W. V. Friesen, and J. C. Hager. Facial action coding system[E-book]. Research Nexus, 2002.

[7] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for imagerecognition. In IEEE Conference on Computer Vision and PatternRecognition, 2016.

[8] H. I. Hummel, F. Pessanha, A. A. Salah, T. van Loon, and R. C.Veltkamp. Automatic pain detection on horse and donkey faces. InIEEE International Conf. Automatic Face and Gesture Recognition,2020.

[9] K. A. Descovich, J. Wathan, M. C. Leach, H. M. Buchanan-Smith,P. Flecknell., et al. Facial expression: An under-utilized tool for theassessment of welfare in mammals. ALTEX, 34, 2017.

[10] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classificationwith deep convolutional neural networks. In Neural InformationProcessing Syst., 2012.

[11] W. Liu, D. Anguelov, D. Erhan, C. Szegedy, S. Reed, C.-Y. Fu,and A. C. Berg. SSD: Single shot multibox detector. In EuropeanConf. Computer Vision, 2016.

[12] Y. Lu, M. Mahmoud, and P. Robinson. Estimating sheep pain levelusing facial action unit detection. In IEEE Int. Conf. Automatic Faceand Gesture Rec., 2017.

[13] F. Pessanha, K. McLennan, and M. Mahmoud. Towards automaticmonitoring of disease progression in sheep: A hierarchical model forsheep facial expressions analysis from video. In 2020 15th IEEEInternational Conference on Automatic Face and Gesture Recognition(FG 2020), pages 387–393, 2020.

[14] M. Rashid, K. B. Gleerup, A. Silventoinen, and P. H. Andersen. Equinefacial action coding system for determination of pain-related facialresponses in videos of horses. PLOS ONE, accepted, 2020.

[15] J. Redmon and A. Farhadi. YOLOv3: An Incremental Improvement.arXiv preprint arXiv:1804.02767, 2018.

[16] S. Ren, K. He, R. Girshick, and J. Sun. Faster r-cnn: Towards real-timeobject detection with region proposal networks. In Neural InformationProc. Syst. 2015.

[17] R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, andD. Batra. Grad-cam: Visual explanations from deep networks viagradient-based localization. International Journal of Computer Vision,128(2), 2019.

[18] Z. Shao, Z. Liu, J. Cai, Y. Wu, and L. Ma. Facial action unit detectionusing attention and relation learning. IEEE Transactions on AffectiveComputing, 2019.

[19] K. Simonyan and A. Zisserman. Very deep convolutional networksfor large-scale image recognition. In International Conf. LearningRepresentations, 2015.

[20] J. Wathan, A. M. Burrows, B. M. Waller, and K. McComb. EquiFACS:the equine facial action coding system. PLOS ONE, 10(8), 2015.

[21] A. C. Williams. Facial expression of pain: An evolutionary account.Behav. Brain Sciences, 25, 2002.

[22] K. Zhao, W.-S. Chu, and H. Zhang. Deep region and multi-labellearning for facial action unit detection. In IEEE Conf. ComputerVision and Pattern Rec., 2016.