Abstract
Objective
Manual classification of rat fecal consistency is widely used in gastrointestinal and pharmacological research, but it is highly inefficient and exposes researchers to allergens due to frequent defecation and continuous handling. Automated image-based analysis addresses a gap in high-throughput experimental workflows by reducing human error and improving scalability. Therefore, this study aimed to develop an artificial intelligence (AI) model using the YOLOv5-L6 object-detection framework to automate the classification of fecal consistency into four categories: normal, soft, muddy, and watery. Moreover, the efficiency and reproducibility of the proposed framework are compared with manual methods.
Results
A dataset of 95 images containing 1,667 labeled fecal samples was prepared with augmentation techniques to enhance robustness. The trained model achieved a mean average precision (mAP) of 86.2%, with class-specific average precision ranging from 75.5% to 95.4%. Compared with manual classification, which required an average of 45 ± 11.3 min, the AI-based approach completed initial classification in 53 s. Moreover, by including manual correction of misclassifications, the total time was approximately 8 min, representing an 82% reduction in processing time. These findings demonstrate that AI-based object detection can substantially improve workflow efficiency in preclinical research.
Keywords: Artificial intelligence, Diarrhea, Fecal stools, Object detection, Rats
Introduction
Fecal characteristics are widely used as indicators of gastrointestinal function in animal studies, particularly in research on dietary interventions and gut motility. Accurate assessment of stool properties is essential for evaluating physiological responses; however, conventional approaches have relied heavily on manual observation. Conventional fecal evaluation is often performed based on visual inspection of stool appearance [1, 2]. These approaches are widely used; however, they depend on the observer’s judgment, which can lead to variability and impose a considerable workload. Moreover, frequent handling of fecal samples during manual classification can expose researchers to potential allergens. In particular, occupational studies have shown that the incidence of allergy increases with greater weekly exposure to laboratory animals and animal-related tasks [3].
Motivation
Automated image-based analysis offers a promising solution to these challenges by reducing human error and improving scalability. Recent advances in computer vision, particularly convolutional neural networks (CNN), have demonstrated strong performance in medical image segmentation, lesion detection, and object localization [4, 5]. In colorectal polyp detection, the YOLOv4 model achieved 90.96% and 82.93% accuracy on the CVC-ClinicDB and ETIS-Larib datasets, respectively, and demonstrated processing speeds sufficient for immediate decision-making during examinations [6]. These successes highlight the potential of using modern computer vision techniques in preclinical studies. Moreover, deep learning has already been adopted in various preclinical applications, including high‑precision, automated analysis of rodent behavior and activity using markerless pose estimation techniques [7].
Research gap
Despite these advances, automated approaches for fecal consistency assessment in rodents remain largely unexplored. Current methods still rely on manual observation, which limits reproducibility and scalability. Although CNN-based detection and segmentation have been widely applied in clinical imaging, their adaptation to rat fecal analysis has not been reported, leaving a critical gap in high-throughput experimental workflows.
Objective
This study aims to develop an AI-based approach using the YOLO object-detection framework [8] to classify rat fecal consistency into four categories: normal, soft, muddy, and watery. We evaluated model performance using mean average precision (mAP) and compared classification efficiency with manual methods to assess its feasibility for preclinical research.
Main text
The overall workflow of the proposed method is shown in Fig. 1. It consists of five main steps: image acquisition, annotation, dataset preparation, model training, and inference/evaluation.
Fig. 1.

Workflow for building the AI model for rat fecal classification. The process includes image acquisition, annotation, dataset preparation, model training, and inference/evaluation
Materials and methods
Animals
The fecal images used for AI model development were obtained from an animal experiment focused on gastroenterological research conducted at Otsuka Pharmaceutical Factory, Inc. All procedures were approved by the Committee for the Care and Use of Laboratory Animals (Approval No. OPFCAE-2022164) and were conducted in accordance with the Guidelines for Animal Experiments established by the company.
Sixty-three six-week-old male Wistar rats (Crlj: WI; The Jackson Laboratory Japan, Inc., Kanagawa, Japan) were used in the study. The animals were housed under controlled environmental conditions: temperature of 23 ± 3 °C, humidity of 55 ± 15%, and a 12:12-h light-dark cycle (lights on from 07:00 to 19:00). The acclimatization period consisted of 10 days of group housing in polycarbonate cages (three rats per cage), followed by three days of individual housing in stainless steel metabolic cages. During this period, rats had ad libitum access to a purified solid diet (AIN-93G; Oriental Yeast Co., Osaka, Japan) and potable water.
Rats were stratified by body weight and randomly assigned to seven groups (n = 9 per group). Sample sizes were determined based on a previous study evaluating rodent stools [9]. Seven test diets were prepared based on reference studies that demonstrated the induction of diarrhea using liquid dietary regimens [1, 10]. Each group received its respective test diet and had free access to water for seven consecutive days. Diets were replenished daily.
A humane endpoint was defined as the appearance of severe distress, such as marked weakness or refusal to eat. No animals met these criteria during the study.
Fecal image acquisition
Stool samples were collected daily on a white absorbent polymer sheet (WP-500; Watanabe Isolator Systems, Inc., Tokyo, Japan) placed beneath each stainless steel metabolic cage with a wire-mesh floor. Images were captured from approximately 40 cm above the sheet using a digital camera (Canon PowerShot G7 X Mark II; Canon Inc., Tokyo, Japan) without flash under standard animal laboratory lighting conditions (approximately 300 lx) to maintain natural color appearance.
Dataset preparation
The dataset, comprising 95 images that served as the foundation for developing the AI model, was curated to cover a diverse spectrum of stool consistencies. Any images with obscured fecal samples were excluded, particularly by individuals without knowledge of the experimental group assignments. A total of 1,667 individual stools within these images were tagged with labels corresponding to their visual consistency (normal: class 0; soft: class 1; muddy: class 2; watery: class 3) using the VoTT2.2.0 tagging software (Microsoft Corporation, Redmond, WA, USA) (Fig. 2). Of these 95 images, 77 were subsequently allocated for training, containing 1,344 stools (representing 81% of the total), whereas the remaining 18 images were designated for validation, comprising 323 stools (constituting 19% of the total). Three distinct training datasets were constructed: (1) Original Dataset comprising the unaltered images, (2) Rotated Dataset incorporating the rotated images, and (3) Copy-Paste Dataset (Table 1). Rotated Dataset was prepared by applying rotational transformations of 0, 90, 180, and 270 degrees to the original images, thereby generating new training samples. Copy-Paste Dataset was generated following the method reported in [11], which involved applying random scale jittering (0.8–1.25×), horizontal flipping, and pasting objects onto other images. The 18 validation images were used in their original form as a single validation dataset. The annotated data were initially exported in the Pascal VOC format and converted into the YOLO format to facilitate their use with the selected object-detection framework.
Fig. 2.
Example images and annotations for fecal classification. a Original images; b Annotated images with class labels; c Representative stool samples (class 0: normal, class 1: soft, class 2: muddy, class 3: watery)
Table 1.
Dataset composition
| Dataset | Number of images |
Number of stool samples | Stool count ratio by class (%) | |||
|---|---|---|---|---|---|---|
| Class 0 | Class 1 | Class 2 | Class 3 | |||
| Original Dataset | 77 | 1,344 | 21.7 | 13.8 | 42.8 | 21.7 |
| Rotated Dataset | 308 | 5,376 | 21.7 | 13.8 | 42.8 | 21.7 |
| Copy-Paste Dataset | 5,852 | 154,843 | 21.7 | 13.9 | 43.0 | 21.3 |
| Validation Dataset | 18 | 323 | 20.1 | 14.6 | 45.5 | 19.8 |
Model training
Model training was conducted using Amazon EC2 G4 instances. The YOLOv5-L6 architecture [12] was retrained on three datasets: Original, Rotated, and Copy-Paste. Each model was trained separately using a batch size of 8, an input image size of 2240 × 2240 pixels, a learning rate of 0.01, and 300 epochs. Detection criteria were set at an intersection over union (IoU) threshold ≥ 0.5 and a confidence score threshold ≥ 0.5.
Evaluation metrics
We use standard definitions for IoU, precision, recall, average precision (AP) and mAP. For a predicted box B and ground-truth box G,
![]() |
Let TP, FP, and FN denote true positives, false positives, and false negatives, respectively. Then,
![]() |
![]() |
AP is the area under the precision–recall curve:
![]() |
The mAP was then calculated by determining the arithmetic mean of the AP values obtained for all classes.
![]() |
where K is the number of classes.
Efficiency comparison of human- and AI-based classification
To compare the efficiency of human and AI-based classification, a total of 871 stool samples collected from 30 rats over 24 h were evaluated. These samples were not included in either the training or validation datasets. Manual classification was conducted by three experienced professionals who visually examined the physical stool samples and recorded the number of samples in each category. The average time required for classification across the three individuals was calculated. For AI-based classification, the Rotated Model algorithm was applied to digital images of the same 871 stool samples. The total processing time was measured from the initiation of the algorithm to the completion of classification and output generation.
The time required for image acquisition and data transfer to a personal computer was excluded from both methods. This exclusion was based on the rationale that these procedures are routinely performed to preserve raw data even during manual classification. Consequently, they represent a typical preprocessing step that does not affect the comparative efficiency of the two approaches.
Results
Performance evaluation of AI models
The trained AI models detected and classified fecal samples successfully within the input images, with each instance delineated by bounding boxes (Fig. 3). Table 2 summarizes the AP for each fecal consistency class, where the mAP represents the overall detection performance. Among the models, the Rotated Model achieved the highest mAP of 86.2%, demonstrating superior accuracy and robustness across most classes. Notably, this model showed marked improvement in detecting class 1 (soft stools), which had previously posed classification challenges.
Fig. 3.

Detection results for rat fecal samples using YOLOv5-L6. Bounding boxes indicate detected stools with class labels (class 0–3). Detection thresholds: IoU ≥ 0.5, confidence ≥ 0.5
Table 2.
Performance metrics of the AI models
| Metric | Class | Original model | Rotated model | Copy-paste model |
|---|---|---|---|---|
| Precision (%) | Class 0 | 87.6 | 91.7 | 89.8 |
| Class 1 | 60.6 | 71.7 | 69.0 | |
| Class 2 | 85.0 | 84.5 | 86.1 | |
| Class 3 | 83.9 | 83.6 | 92.0 | |
| Recall (%) | Class 0 | 92.3 | 93.8 | 83.1 |
| Class 1 | 70.2 | 80.9 | 70.2 | |
| Class 2 | 84.7 | 83.0 | 83.7 | |
| Class 3 | 82.8 | 79.9 | 72.2 | |
| AP (%) | Class 0 | 92.7 | 95.4 | 88.8 |
| Class 1 | 65.0 | 75.5 | 69.4 | |
| Class 2 | 86.5 | 87.2 | 85.4 | |
| Class 3 | 86.5 | 86.8 | 84.1 | |
| mAP (%) | 82.7 | 86.2 | 81.9 |
Comparison of classification time
Manual classification of 871 stool samples, excreted by 30 rats over 24 h, required 29, 49, and 56 min by three experienced professionals, with an average duration of 45 ± 11.3 min. In contrast, the AI-based classification using the trained models was completed in just 53 s for initial inference. Including manual correction of misclassifications, the total time was approximately 8 min, representing an 82% reduction in processing time compared with manual classification.
Discussion
This study demonstrates that YOLOv5‑L6 can classify rat fecal consistency into four categories with high accuracy (mAP 86.2%) and reduce classification time by 82% compared with manual assessment. These findings highlight the potential of AI-based object detection to improve efficiency and reproducibility in preclinical workflows while reducing researcher workload.
Beyond operational gains, automation may help limit allergen exposure by reducing direct handling of fecal samples, an important occupational concern in laboratory animal work. Our results indicate that augmentation strategies should be dataset-specific. Rotation has improved generalization whereas copy–paste has offered limited benefit under uniform backgrounds. This underscores the need for context-aware augmentation rather than generic application.
All images were collected under uniform conditions at a single facility. Thus, further validation across datasets obtained under varied imaging settings is warranted to assess the robustness and broader applicability of the model. In addition, all annotations were performed by a single annotator, suggesting that future work should incorporate multiple annotators and inter‑rater agreement analysis to enhance the statistical soundness of the dataset.
Object detection was selected for speed and simplicity; however, segmentation could provide pixel-level detail for severity grading. Future work should explore hybrid detection–segmentation approaches, expand datasets to address class imbalance, and incorporate cross-species validation. Real-time video analysis and advanced preprocessing may further enhance robustness and applicability.
Limitations
This study has several limitations:
Partial automation: The current system is not fully automated. Misclassifications by the AI still require manual correction by human experts.
Dataset size and class imbalance: The modest dataset (95 images; 1,667 instances) and the smaller number of class 1 samples may limit generalizability and contribute to lower AP for that class.
All annotations were performed by a single annotator, and inter‑rater reliability was not evaluated. Future studies should include multiple annotators to improve the statistical soundness of the conclusions.
Restricted morphological diversity: The variability in stool morphology, especially within class 1, may have affected the model’s learning capacity and classification accuracy.
Uniform imaging conditions: All images were collected under uniform imaging conditions—including the same polymer sheet, consistent lighting, and fixed camera settings—at a single facility. This aspect may limit the generalizability of the model across different imaging environments.
Single-species dataset: The dataset was limited to rat feces, and the generalizability of the model to other animal species remains to be validated.
Statistical reporting scope: The model was trained using a fixed random seed, which ensured consistency but did not allow assessment of variability across multiple runs. Future studies should include inter-rater reliability for labeling and calibration analysis across classes to strengthen reproducibility.
Acknowledgements
The authors thank Yukari Miki for providing the images used in this study, Airi Honjo for her invaluable support in creating the dataset, and Tomohiro Kagawa for his assistance with the proofreading and editing of this manuscript. Additionally, the authors thank Editage (http://www.editage.com) for English language editing.
Author contributions
E.M. and I.Y. designed the study. S.N. developed the AI models. E.M and I.Y. interpreted the results. E.M. wrote the first draft of the manuscript. All authors have reviewed and approved the final version of the manuscript.
Funding
This work was supported by Otsuka Pharmaceutical Factory, Inc. No specific grant number is associated with this funding. The funder had no role in the study design, data collection and analysis, decision to publish, or preparation of the manuscript.
Data availability
The models generated and analyzed in the current study are not publicly available due to proprietary restrictions but are available from the corresponding author on reasonable request.
Declarations
Ethics approval and consent to participate
All animal procedures were approved by the Committee for the Care and Use of Laboratory Animals (Approval No. OPFCAE-2022164) and conducted in accordance with the Guidelines for Animal Experiments of Otsuka Pharmaceutical Factory, Inc.
Consent for publication
Not applicable.
Competing interests
This work was supported by Otsuka Pharmaceutical Factory, Inc., through employment and research funding provided to the authors. None of the authors has any commercial or financial involvement in connection with this study that represents or appears to represent any conflicts of interest.
Footnotes
Publisher’s Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
References
- 1.Hino K, Miyatake S, Yamada F, Endo N, Akiyama R, Ebisu G. Undigested low-methoxy pectin prevents diarrhea and induces colonic contraction during liquid-diet feeding in rats. Nutrition. 2020;78:110804. 10.1016/j.nut.2020.110804. [DOI] [PubMed] [Google Scholar]
- 2.Jia S, Chai L, Zhang J, Zhang M, Li L, Qi Y, et al. Wei Chang An pill regulates gastrointestinal motility in a bidirectional manner. Pharm Biol. 2021;59:1450–61. 10.1080/13880209.2021.1991383. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Elliott L, Heederik D, Marshall S, Peden D, Loomis D. Incidence of allergy and allergy symptoms among workers exposed to laboratory animals. Occup Environ Med. 2005;62:766–71. 10.1136/oem.2004.018739. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Wu X, Sahoo D, Hoi SCH. Recent advances in deep learning for object detection. Neurocomputing. 2020;396:39–64. 10.1016/j.neucom.2020.01.085. [Google Scholar]
- 5.Kourounis G, Elmahmudi A, Thomson B, Hunter J, Ugail H, Wilson C. Computer image analysis with artificial intelligence: a practical introduction to convolutional neural networks for medical professionals. Postgrad Med J. 2023;99:1287–94. 10.1093/postmj/qgad095. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Carrinho P, Falcao G. Highly accurate and fast YOLOv4-based polyp detection. Expert Syst Appl. 2023;232:120834. 10.1016/j.eswa.2023.120834. [Google Scholar]
- 7.Sturman O, von Ziegler L, Schläppi C, Akyol F, Privitera M, Slominski D, et al. Deep learning–based behavioral analysis reaches human accuracy and is capable of outperforming commercial solutions. Neuropsychopharmacology. 2020;45:1942–52. 10.1038/s41386-020-0776-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Redmon J, Divvala S, Girshick R, Farhadi A. You Only Look Once: Unified, real-time object detection. In: 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). 2016. pp. 779 – 88. 10.1109/CVPR.2016.91
- 9.Paturi G, Butts CA, Joyce NI, Rippon PE, Morrison SC, Hedderley DI, et al. Pectin influences the absorption and metabolism of polyphenols from blackcurrant and green tea in rats. Foods. 2021;10:813. 10.3390/foods10040813. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Kagawa T, Endo N, Ebisu G, Yamaoka I. Fecal imaging demonstrates that low-methoxyl pectin supplementation normalizes gastro-intestinal transit in mice given a liquid diet. Physiol Rep. 2018;6:e13662. 10.14814/phy2.13662. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Ghiasi G, Cui Y, Srinivas A, Qian R, Lin T-Y, Cubuk ED et al. Simple copy-paste is a strong data augmentation method for instance segmentation. In: 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). 2021. pp. 2917-27. 10.1109/CVPR46437.2021.00294
- 12.Jocher G. YOLOv5. GitHub repository. https://github.com/ultralytics/yolov5. Accessed 15 Oct 2024.
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
The models generated and analyzed in the current study are not publicly available due to proprietary restrictions but are available from the corresponding author on reasonable request.






