Deep Learning and Explainable Artificial Intelligence for Infrared-Thermography-Based CMT-Status Classification in Dairy Cows: A Comparative Evaluation in Egyptian Farms
Abstract
Simple Summary Mastitis reduces milk output and quality while harming animal comfort. It is one of the most expensive diseases in dairy farming. If caught early and without invasive treatments, farmers can respond more quickly. To find out if modern deep-learning models can directly detect mastitis from infrared thermal images of the udder, we looked at two types of models: traditional convolutional neural networks and the latest Vision Transformers. Using the same set of thermal images as in our previous research, we trained seven end-to-end models and tested them with an animal-level cross-validation method designed to prevent data leakage between cows. The convolutional models, especially DenseNet-121, performed significantly better than the Vision Transformers on this relatively small dataset. We also explored the connection between model predictions and somatic cell count, using an explainability method to show where each model focused. Our results suggest that advanced convolutional networks are currently the most reliable option for thermal mastitis screening. However, vision transformers likely need much larger datasets to compete.