Automated goat breed identification using CNN-based transfer learning with VGG16 and mobilenetv2
Abstract
Effective management of livestock genetic resources and the implementation of breeding programmes require accurate identification of indigenous breeds. However, under field conditions, goat breed identification is often challenging due to phenotypic similarities among breeds and reliance on subjective visual assessment. Therefore, the present study aimed to develop an automated image-based deep learning framework using transfer learning for the classification of two morphologically related indigenous goat breeds, Barbari and Jamunapari, employing convolutional neural network (CNN) architectures. A curated dataset consisting of 640 images collected from 160 goats (80 animals per breed) was developed, where four images per animal were captured: two frontal and two left-lateral views. The dataset was partitioned at the animal level into training, validation and testing subsets using a 70:10:20 split (training:validation:testing) to ensure independent evaluation. Two transfer learning architectures, VGG16 and MobileNetV2, pretrained on ImageNet, were fine-tuned for binary breed classification. Model performance was evaluated using confusion matrix–derived metrics including accuracy, precision, recall, F1-score and AUC–ROC, along with computational efficiency parameters such as inference time and memory usage. On the independent test set, MobileNetV2 achieved the highest classification accuracy (94.53%), with precision of 93.85%, recall of 95.31% and F1-score of 94.57%, whereas VGG16 achieved an accuracy of 93.75%, with precision of 95.16%, recall of 92.19% and F1-score of 93.65%. ROC analysis indicated strong discriminative capability for both models, with AUC–ROC values of 0.94 for MobileNetV2 and 0.95 for VGG16. Overall, the results demonstrate that deep learning–based image classification can effectively distinguish closely related goat breeds and provide a scalable tool for automated breed identification.
Full Text
Tables and figures are in the full-text PDF.
Introduction
Goat production plays an important role in sustaining the livelihoods and nutritional security of small and marginal farmers, particularly in developing countries where livestock systems are predominantly smallholder-based. Goats provide meat, milk and income and often serve as a financial buffer in resource-limited rural production systems (Jegoda et al., 2022) [11] . Globally, the goat population exceeds one billion animals distributed across several hundred recognized breeds adapted to diverse agro-ecological conditions. India possesses one of the largest goat populations globally, accounting for approximately 27% of the global goat population, with nearly 148.88 million goats representing 43 registered breeds (Department of Animal Husbandry and Dairying, 2019; ICAR-National Bureau of Animal Genetic Resources, 2025) [5,9] . However, a substantial proportion of these animals are categorized as non-descript due to extensive interbreeding and weak phenotypic differentiation, which complicates accurate breed identification under field conditions (Yaro et al., 2017) [2] . Accurate breed identification is essential for genetic improvement programmes, conservation of indigenous genetic resources and maintenance of breed purity. Traditionally, breed identification relies on morphological traits, yet observer subjectivity and phenotypic overlap often reduce the reliability of such assessments (Brito et al., 2020) [4] . Recent advances in computer vision and artificial intelligence have created new opportunities for automated livestock phenotyping. Deep learning approaches, particularly convolutional neural networks (CNNs), have demonstrated strong capability in extracting complex visual features from images and performing automated classification tasks (Bergman et al., 2024) [3] . CNN-based systems reduce dependence on manual evaluation and enable standardized, reproducible phenotypic analysis from large digital image datasets. These technologies are increasingly applied in livestock research for animal identification, breed classification and monitoring, thereby improving management, traceability and documentation of genetic resources (Bachmann et al., 2022) [2] . Among widely used CNN architectures, VGG16 and MobileNetV2 represent two models with contrasting computational characteristics (Habibullah et al., 2023; İnce et al., 2025) [8,10] . VGG16 is a deep convolutional network with sequential convolutional layers that enable hierarchical extraction of fine-grained visual features, allowing detection of subtle morphological variations. In contrast, MobileNetV2 is a lightweight architecture that utilizes depthwise separable convolutions to reduce computational cost and parameter size while maintaining competitive classification performance, making it suitable for real-time and mobile-based applications (S et al., 2024) [15] .
Deep learning-based breed identification has been successfully explored in several livestock species including sheep, cattle and camels, where CNN models trained on image datasets have achieved high classification accuracies. These studies demonstrate the potential of automated systems to recognize animals using morphological cues such as facial structure, body conformation and coat pattern distribution (Li et al., 2024) [13] . However, research on automated breed identification in goats remains limited, particularly for indigenous Indian breeds that often exhibit considerable phenotypic similarity. In this study, two morphologically related indigenous goat breeds, Barbari and Jamunapari, were selected for automated classification. Barbari goats are typically characterized by smaller body size, straight facial profile, erect ears and variable spotted coat patterns (Singh et al., 2015) [18] , whereas Jamunapari goats exhibit larger body size, a convex facial profile, long pendulous ears and a predominantly white coat with tan markings on the head and neck (Rout et al., 2000) [14] . Despite these distinguishing traits, variations in posture, illumination and image capture conditions can make visual identification difficult under practical farm conditions. Therefore, this study aims to develop an automated image-based framework using transfer learning with pretrained VGG16 and MobileNetV2 architectures to classify Barbari and Jamunapari goats. A summary of major machine learning and deep-learning applications for animal breed and identity recognition is provided in Table 1 to contextualize the current study within existing literature. [1] Sheep (4 breeds) VGG16 VGG16: 95.8%
Weber et al. (2020) [20] Cattle (Pantaneira) DenseNet-201, ResNet50 DenseNet-201: 99.85% ResNet50: 99.78% Shah et al. (2020) [16] 103 dog breeds custom model Accuracy: 95.5% Shah and Sheppard (2020) [17] 12,500 cats + 12,500 dogs InceptionV3 Accuracy: 100% Dutta (2021) [6] Sheep custom model Accuracy: 87.1%
Materials and Methods
Study area and selection of animals
The present study was conducted using two indigenous goat breeds, Barbari and Jamunapari, maintained at the Goat Research and Training Centre, Department of Veterinary Physiology, College of Veterinary Science and Animal Husbandry (CVSc & AH), DUVASU, Mathura, Uttar Pradesh, India. A total of 160 adult goats were selected for the study, comprising 80 Barbari and 80 Jamunapari animals. Animals included in the dataset were between 2 and 5 years of age and represented typical phenotypic characteristics of their respective breeds. Animals were selected to ensure that only purebred individuals with clearly identifiable morphological traits were included, minimizing ambiguity during model training.
Image dataset acquisition
A standardized image acquisition protocol was followed to build a curated image dataset for goat breed classification. Digital images were captured using a smartphone camera (12 MP, Sony IMX682 sensor, f/1.8) at 1440 × 1440 pixels under natural daylight conditions within the farm premises. For each animal, four images were captured to represent important morphological perspectives: (i) two frontal images capturing facial profile, horn orientation and ear structure; (ii) two leftlateral images capturing body conformation, head profile and coat pattern. A total of 640 images were collected from 160 goats, with four images captured per animal, as summarized in Table 2. During image acquisition, the camera was positioned at approximately a distance of 1.5-2.0 m from the animal to ensure clear capture of body structure and facial characteristics. Images with motion blur, occlusion, poor illumination or partial visibility of the animal were excluded during manual inspection to maintain dataset quality.
Dataset partitioning
To ensure unbiased model evaluation, the dataset was partitioned at the animal level, so that images from the same individual did not appear in more than one subset. The dataset was divided into training, validation and testing subsets using a 70:10:20 ratio. Since each animal contributed four images, the final dataset distribution is presented in Table 3. The training dataset was used for model learning, the validation dataset was used for hyperparameter tuning and monitoring model convergence, and the independent testing dataset was reserved exclusively for final performance evaluation.
Image preprocessing and data augmentation
All images were resized to match the input dimension requirements of the CNN architectures used in the study. Prior to training, pixel values were normalized using architecturespecific preprocessing functions to ensure compatibility with pretrained ImageNet weights. To improve model generalization and reduce overfitting, data augmentation was applied during training using real-time image transformations. The augmentation pipeline included: Random rotation (± 20°), horizontal translation (≤ 25% of image width), vertical translation (≤ 25% of image height), zoom variations (≤ 25%), horizontal flipping and brightness adjustment (0.8-1.2 range). These transformations simulate natural variations in orientation, illumination and animal posture that commonly occur during field photography. Validation and testing images were not augmented, ensuring that model evaluation was performed on unaltered images.
Deep learning models and transfer learning framework
Two convolutional neural network architectures, VGG16 (Jiang et al., 2021) [12] and MobileNetV2 (Gulzar, 2023) [7] , were used for automated goat breed classification. Both architectures were initialized with pretrained ImageNet weights, allowing the models to leverage previously learned hierarchical visual features. The original classification layers of the pretrained networks were removed and replaced with a custom classification head consisting of: Global Average Pooling layer, fully connected dense layer (512 units), Batch normalization, LeakyReLU activation, Dropout layer (0.5) and final dense layer with softmax activation for two classes (Barbari and Jamunapari). Initially, the convolutional base of each architecture was frozen to perform feature extraction.
Subsequently, selected deeper layers were unfrozen for finetuning, enabling the models to adapt high-level features to the goat breed classification task. All models were implemented using TensorFlow with Keras in a Python environment.
Model training
Model training was performed using Stochastic Gradient Descent (SGD) optimization with momentum. The key hyperparameters used for training the CNN models are summarized in Table 4.
Model evaluation
Model performance was evaluated on the independent test dataset using standard classification metrics derived from the confusion matrix. The evaluation metrics and their corresponding formulations are presented in Table 5. These metrics provide a comprehensive evaluation of classification performance by assessing both correct predictions and misclassification patterns between the two goat breeds. Additionally, confusion matrices were generated to visualize class-wise prediction performance for Barbari and Jamunapari goats.
Classification performance on the independent test dataset
The performance of the trained models was evaluated using the independent test dataset comprising 32 animals ( 16Barbari and 16 Jamunapari), corresponding to 128 images. Classification outcomes were assessed using confusion matrices and standard evaluation metrics including accuracy, precision, recall and F1-score. The confusion matrices for both models are presented in Figure 2. The results indicate that the majority of test images were correctly classified for both goat breeds, with only a small number of misclassifications observed. For the VGG16 model, 59 Barbari images were correctly classified while 5 were misclassified as Jamunapari. Similarly, 61 Jamunapari images were correctly classified, with 3 images incorrectly predicted as Barbari. For the MobileNetV2 model, 61 Barbari images were correctly identified while 3 were misclassified, whereas 60 Jamunapari images were correctly classified and 4 were misclassified as Barbari. Based on these predictions, VGG16 achieved an overall classification accuracy of 93.75%, while MobileNetV2 achieved an accuracy of 94.53% on the independent test dataset. The corresponding precision, recall and F1-score values derived from the confusion matrices indicated strong classification performance for both models. showing slightly higher discriminative performance compared to MobileNetV2.
Comparative performance of CNN architectures
Although both CNN architectures produced highly accurate predictions, differences were observed in computational characteristics. MobileNetV2 required fewer parameters and provided faster inference, making it suitable for deployment in computationally constrained environments. In contrast, VGG16 achieved marginally higher classification accuracy due to its deeper architecture and greater representational capacity. Thus, the results demonstrate that both architectures are effective for automated goat breed identification from images. MobileNetV2 achieved the highest classification accuracy, while VGG16 demonstrated strong predictive performance due to its deeper architecture.
Discussion
The [20] . Likewise, a VGG16-based model achieved an accuracy of 95.8% for automated sheep breed identification using image datasets (Abu Jwade et al., 2019) [1] . Furthermore, transfer learning models applied for classification of phenotypically similar cattle breeds reported accuracies ranging from 80% to 86% across MobileNet and EfficientNet architectures (Warhade et al., 2024) [19] . These studies collectively highlight the strong capability of deep learning models for accurate livestock breed identification and demonstrate the increasing applicability of CNN-based approaches in animal biometric recognition.
In the present study, MobileNetV2 achieved slightly higher classification accuracy (94.53%) compared with VGG16 (93.75%), as observed from the confusion matrix-derived evaluation metrics. The high classification performance indicates that the visual characteristics present in the dataset were sufficient for reliable breed discrimination. Although VGG16 produced slightly lower accuracy than MobileNetV2, it maintained strong predictive performance with high precision and F1-score values. VGG16 is a deep convolutional architecture composed of multiple sequential convolutional layers that progressively learn hierarchical visual features from images. This structure allows the model to capture fine morphological patterns such as facial contour, ear structure and coat pattern distribution, which are important distinguishing traits between Barbari and Jamunapari goats.
MobileNetV2 also demonstrated strong classification performance while maintaining lower computational complexity. The architecture employs depthwise separable convolutions and inverted residual blocks, enabling efficient feature extraction with significantly fewer parameters. This design allows MobileNetV2 to achieve high accuracy while requiring lower computational resources and faster inference compared with deeper networks. The ability of both CNN models to correctly classify the majority of test images highlights their effectiveness for automated goat breed identification. Despite the partial phenotypic similarity between Barbari and Jamunapari goats, the models successfully learned discriminative morphological features from the training dataset, enabling reliable classification of the two breeds using image-based inputs.
Conclusion
This study demonstrates the effectiveness of deep learningbased image classification for automated identification of indigenous goat breeds. A curated dataset of 640 images collected from 160 goats representing Barbari and Jamunapari breeds was used to evaluate two transfer learning architectures, VGG16 and MobileNetV2. Both models successfully distinguished between the two morphologically similar goat breeds using image-based features. While VGG16 showed strong predictive performance, MobileNetV2 required lower inference time and memory usage, indicating greater computational efficiency. These findings suggest that lightweight CNN architectures can provide reliable breed identification while remaining suitable for deployment in resource-constrained environments. The proposed framework offers a practical approach for automated livestock breed recognition and can support breed documentation, genetic improvement programmes and conservation of indigenous goat genetic resources through scalable computer visionbased phenotyping systems. However, the dataset was obtained from a single farm environment, which may limit generalization across diverse conditions. Future studies should include larger multi-location datasets and additional breeds to improve model robustness and broader applicability.
study. The authors extend their sincere gratitude to the Hon'ble Vice Chancellor and the PG Dean for their continual guidance and institutional support throughout the execution of this work.
Acknowledgement
AcknowledgmentThis research was supported by Uttar Pradesh Pandit Deen Dayal Upadhyaya Pashu Chikitsa Vigyan Vishwavidyalaya Evam Go-Anusandhan Sansthan, Mathura, which provided the necessary infrastructure and facilities for conducting the
References
- Abu Jwade S, Guzzomi A, Mian A. On-farm automatic sheep breed classification using deep learning. Comput Electron Agric. 2019;167:105055.
- Bachmann N, Tripathi S, Brunner M, Jodlbauer H. The contribution of data-driven technologies in achieving the Sustainable Development Goals. Sustainability. 2022;14:2497.
- Bergman N, Yitzhaky Y, Halachmi I. Biometric identification of dairy cows via real-time facial recognition. Animal. 2024;18:101079.
- Brito LF, Oliveira HR, McConn BR, Schinckel AP, Arrazola A, Marchant-Forde JN, et al. Large-scale phenotyping of livestock welfare in commercial production systems: A new frontier in animal breeding. Front Genet. 2020;11:793.
- Department of Animal Husbandry and Dairying. 20th livestock census 2019: All India report. New Delhi: Government of India; 2019.
- Dutta P. A deep learning approach for animal breed classification: Sheep. Int J Res Appl Sci Eng Technol. 2021;9:73-76.
- Gulzar Y. Fruit image classification model based on MobileNetV2 with deep transfer learning technique. Sustainability. 2023;15:1906.
- Habibullah, Ullah MO, Kamal M, Sohag MSH, Rahman MS. Improved convolutional neural network and transfer learning with VGG16 approach for image classification. In: Proceedings of the 2023 International Conference on Innovation and Intelligence for Informatics, Computing, and Technologies (3ICT). IEEE; 2023. p. 389-396.
- ICAR-National Bureau of Animal Genetic Resources. Breed registration catalogue. 2025. https://nbagr.res.in/brc
- İnce AH, Günhan C, Soydaş F. Animal images classification with MobileNetV2. In: Proceedings of the 9th International Symposium on Innovative Approaches in Smart Technologies (ISAS). IEEE; 2025. p. 1-5.
- Jegoda MN, Jadav SJ, Patel JH. Socio-economic profile and constraints faced by goat keepers. Gujarat J Ext Educ. 2022;34:79-85.
- Jiang ZP, Liu YY, Shao ZE, Huang KW. An improved VGG16 model for pneumonia image classification. Appl Sci. 2021;11:11185.
- Li TK, Chan KL, Tjahjadi T. Variable temporal length training for action recognition CNNs. Sensors. 2024;24:3403.
- Rout PK, Saxena VK, Khan BU, Roy R, Mandal A, Singh SK, et al. Characterisation of Jamunapari goats in their home tract. Anim Genet Resour Inf. 2000;27:43-52.
- S AD, Begum A, Kalilulah SI, Naveena NR, K R, D H. Deep learning advances in brain tumor classification: Leveraging VGG16 and MobileNetV2 for accurate MRI diagnostics. In: Proceedings of the 2024 International Conference on Power, Energy, Control and Transmission Systems (ICPECTS). IEEE; 2024. p. 1-6.
- Shah BK, Kumar A, Kumar A. Dog breed classifier for facial recognition using convolutional neural networks. In: Proceedings of the 3rd International Conference on Intelligent Sustainable Systems (ICISS). IEEE; 2020. p. 508-513.
- Shah SS, Sheppard JW. Evaluating explanations of convolutional neural network image classifications. In: Proceedings of the International Joint Conference on Neural Networks (IJCNN). IEEE; 2020. p. 1-8.
- Singh PP, Tomar SS, Thakur MS, Kumar A. Polymorphism and association of growth hormone gene with growth traits in Sirohi and Barbari breeds of goat. Vet World. 2015;8:382-387.
- Warhade R, Devi I, Singh N, Arya S, Dudi K, Lathwal SS, et al. Attention module incorporated transfer learning empowered deep learning-based models for classification of phenotypically similar tropical cattle breeds (Bos indicus). Trop Anim Health Prod. 2024;56:192.
- Weber FDL, Weber VAM, Menezes GV, Oliveira Junior AS, Alves DA, Oliveira MVM, et al. Recognition of Pantaneira cattle breed using computer vision and convolutional neural networks. Comput Electron Agric. 2020;175:105548.
- Yaro M, Munyard KA, Stear MJ, Groth DM. Molecular identification of livestock breeds: A tool for modern conservation biology. Biol Rev. 2017;92:993-1010.
How this paper connects to the literature. Drag to explore, click any node to open that paper.
