# Automatic gait classification for equine lameness detection using transfer learning

Mahaut Gérard, Guillaume Dubois, Sandrine Hanne-Poujade, Neila Mezghani, Henry Chateau

<figure><img src="image_1.png" /></figure>

## To cite this version:

Mahaut Gérard, Guillaume Dubois, Sandrine Hanne-Poujade, Neila Mezghani, Henry Chateau. Automatic gait classification for equine lameness detection using transfer learning. Multidisciplinary Biomechanics Journal, 2025, 49th congress of the Société de Biomécanique, 10.46298/mbj.14521. hal-04738003v2

HAL Id: hal-04738003

https://hal.science/hal-04738003v2

Submitted on 31 Jan 2025

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_2.png" /></figure>
<figure><img src="image_3.png" /></figure>

# Automatic gait classification for equine lameness detection using transfer learning

Mahaut Gérard<sup>a, b, c*</sup>, Guillaume Dubois<sup>b</sup>, Sandrine Hanne-Poujade<sup>b</sup>, Neila Mezghani<sup>c</sup>, Henry Chateau<sup>a</sup>

<sup>a</sup> Ecole nationale vétérinaire d'Alfort, CIRALE, 94700 Maisons-Alfort, France

<sup>b</sup> LIM Group, 24300 Nontron, France

<sup>c</sup> Université TELUQ, Montréal, Québec, Canada

* Corresponding author: mahaut.gerard@vet-alfort.fr

Received date: 07/04/2024

Accepted date: 28/06/2024

Publication date: 31/01/2025

**Keywords:** horse, gait, lameness, transfer learning, deep learning

© 2025 The Authors
Licence CC-BY 4.0
Published by Société de Biomécanique

## 1. Introduction

Equine locomotion is usually evaluated visually by veterinarians, but this method is subjective (Keegan et al. 2019). Recently, inertial measurement unit (IMU) systems have been used for quantitative evaluation, mainly computing symmetry indices at trot. However, other gaits, such as walk and gallop, are known to impact locomotion variables, and some disorders are mainly visible at a specific gait (Robilliard et al. 2007). Gait classification can be performed by rule-based methods such as the limb stance sequence. However, it is not robust enough for horses with specific locomotion or types of lameness. Therefore, some works use machine learning models for gait classification (Bragança et al. 2020). More precisely, the Long Short-Term Memory (LSTM) network is widely used for gait classification in humans (Prasanth et al. 2021). To our knowledge, no study has been able to work with horse raw IMU data without any manual pre-selection of signal parts. The study aims for automatic multi-gait classification (walk, trot, gallop, other) from raw data of diverse veterinary lameness assessment settings.

## 2. Methods

### 2.1 Data collection

Data from 326 horses seen during standard veterinarian locomotor assessment at the CIRALE clinic between 2021 and 2022 were used. Data were collected at different gaits (walk, trot, gallop), grounds (soft, hard), and figures (eight, straight line, circle). Each horse

was equipped with 7 IMUs (3-axis accelerometer and 3-axis gyroscope) on the head, withers, pelvis and 4 metacarpal-tarsal bones. IMUs were synchronized and sampled at 200 Hz.

### 2.2 Data processing

Gaits of 12 horses across 120 conditions were labelled as walk, trot, gallop, and 'other' for non-constant gait signal parts. It was performed manually using the gyroscopes' dorso-ventral axis of the four limbs and synchronized videos, resulting in 556732 timestamps. IMU signal was down-sampled to 100 Hz. Input sequences were of length 256, every 10 timesteps, ensuring continuity within each sequence. The feature set was selected based on preliminary experiments. Data were split into 60% training and 40% testing for each horse group. Each feature was independently standardized from training set mean and standard deviation. When mentioned with (aug), the data were augmented using time-warping (sigma=0.2, knots=3) and scaling (alpha=0.01) every two sequences.

### 2.3 Gait classification

The models were implemented in python 3.11.5 using the keras library (2.14.0). Classification models tested include a convolutional neural network (CNN) and a LSTM. For each input sequence, the models output a gait class for every timestep. To address the small labelled dataset size compared to the unlabelled dataset, we also implemented a transfer learning approach. It combines an encoder (trained as part of an auto-encoder
to reconstruct signals on the unlabelled dataset) and the CNN or LSTM, as shown on Figure 1. For each input sequence, the encoder-based models output one gait class.

<figure><img src="image_4.png" /><figcaption>**Figure 1.** Auto-encoder network and its role in the transfer learning approach.</figcaption></figure>

The CNN architecture was: 3 convolutional layers with batch normalization, ReLU activation, maxpooling, and dropout. Followed by upsampling and a fully connected layer with sigmoid activation. Kernel size was set to 3 and padding to 'same'. It was trained with a 1e-3 learning rate. The LSTM architecture was: 2 LSTM layers with batch normalization, tanh activation, and dropout. Followed by a fully connected layer with batch normalization and ReLU activation. It was trained with a 1e-4 learning rate. Both neural networks were cross-trained with MAE loss for 100 epochs. The encoder had 4 convolutional layers, ReLU activation, and maxpooling, with batch normalization in the first layer. The autoencoder was trained on 10 epochs, a 1e-3 learning rate and MSE loss. Batch sizes were 1024 and optimizers were Adam.

As the sequence length is longer than the step between each sequence, each timestamp can have several classes. A majority voting classifier was used to finally classify each timestamp.

### 3. Results and discussion

Considering base models, the LSTM, known to be more suited to timeseries dataset, outperformed the CNN with 87% accuracy on test timesteps. With augmented data, the LSTM achieves a better accuracy: 90%. The cross-validation accuracy has a smaller standard deviation, and no gap was seen between training and testing

accuracies. The augmentation is promising towards better model generalisation. Overall, the best model was the encoder followed by the CNN achieving 93% on test timesteps. After the encoder, the signal of size (16, 4) is no more in the time-series shape as the features were extracted. Thus, the output of the encoder is more adapted to the input of a CNN than a LSTM.

<table><caption>**Table 1.** Comparison of model's accuracy, written in percentage.</caption><thead><tr><th rowspan="2">Model</th><th>Cross-training</th><th colspan="2">Testing accuracy</th></tr><tr><th>Accuracy±sd</th><th>Sequence</th><th>Timestep</th></tr></thead><tbody><tr><td>CNN</td><td>89±2</td><td>82</td><td>83</td></tr><tr><td>LSTM</td><td>90±3</td><td>87</td><td>87</td></tr><tr><td>LSTM (aug)</td><td>90±1</td><td>90</td><td>90</td></tr><tr><td>Encoder+CNN</td><td>93±2</td><td>91</td><td>93</td></tr><tr><td>Encoder+LSTM</td><td>91±4</td><td>90</td><td>91</td></tr></tbody></table>

To our knowledge, no related work classified gaits with a sample possibility outside all defined gait classes. The multi-gait classification developed by Bragança et al. (2020) presents an accuracy of 97%. Our best accuracy is of 93%, however we see on confusion matrices that most of the confusions are done related to the 'other' class. The challenge of this additional class is to gather very different samples (for instance, halt is the opposite of kicks when looking at signal amplitude) and gait transition, aiming for 10ms precision. The addition of the 'other' class enables the model to work with raw IMU data, without any manual preselection. Models with reject options may be a good alternative to the added 'other' class.

### 4. Conclusions

Our best model, the encoder followed by the CNN, classifies gaits (walk, trot, gallop, other) with 93% accuracy on test timesteps. Transfer learning efficiently leverages the lack of labelled data. The proposed approach is therefore promising for end-to-end automatic multi-gait classification in diverse kinds of veterinary locomotor assessment.

### Acknowledgements

The authors would like to thank the team of CIRALE.
**Conflict of Interest Statement**

No conflict of interest was reported by the authors.

**References**

Keegan, Kevin G. 2019. Reliability of equine visual lameness classification. *Veterinary Record* 184(2):60-62.

Prasanth, Hari, Miroslav Caban, Urs Keller, Grégoire Courtine, Auke Ijspeert, Heike Vallery, and Joachim von Zitzewitz. 2021. Wearable Sensor-Based Real-Time Gait Detection: A Systematic Review. *Sensors* 21(8).

Robilliard, Justine J., Thilo Pfau, and Alan M. Wilson. 2007. Gait characterisation and classification in horses. *Journal of Experimental Biology* 210(2):187-97.

Serra Bragança, F. M., S. Broomé, M. Rhodin, S. Björnsdóttir, V. Gunnarsson, J. P. Voskamp, E. Persson-Sjodin, W. Back, G. Lindgren, M. Novoa-Bravo, A. I. Gmel, C. Roepstorff, B. J. van der Zwaag, P. R. Van Weeren, and E. Hernlund. 2020. Improving gait classification in horses by using inertial measurement unit (IMU) generated data and machine learning. *Scientific Reports* 10(1):17785.