S_T_Mamba: A Novel Jinnan Calf Diarrhea Behavior Recognition Model Based on Sequence Tree Mamba
Simple Summary
Abstract
1. Introduction
- (1)
- In this paper, we propose a novel S_T_Mamba model designed to recognize Jinnan calf diarrhea behavior efficiently. This model can establish temporal dependencies by leveraging a sequence processing strategy. Additionally, it can construct spatial long-range feature relationships in images through the tree state space module.
- (2)
- This paper initially introduces a sequence processing strategy, which builds temporal dependencies underlying the video. This strategy explores the temporal features of the diarrhea behavior of Jinnan calves. Subsequently, it can significantly improve the performance of calf diarrhea behavior recognition.
- (3)
- This paper proposes an innovative tree state space module (TreeSSM). It can effectively capture long-range dependencies in the spatial domain of the image. Furthermore, TreeSSM enables the model to accurately characterize the subtle pattern differences underlying similar behaviors. Consequently, it will further enhance the discriminative ability of S_T_Mamba.
- (4)
- This paper first establishes a median-scale dataset for Jinnan calf diarrhea behavior. This dataset consists of five classes of behavior, and each of them contains approximately 700 videos. Specifically, the duration of each video ranges from 5 to 10 s. This novel Jinnan calf diarrhea dataset is collected from a natural environment, which will provide a solid foundation for research in the field of calf diarrhea.
2. Related Work
3. Materials and Methods
3.1. Dataset
3.2. S_T_Mamba
3.2.1. Sequence Processing Strategy
3.2.2. Stem Block
3.2.3. TreeMamba
3.2.4. TreeSSM
Algorithm 1 TreeSSM process. |
Input: Input features x, parameters , Output: Transformed features y 1: // Feature projection and discretization 2: 3: 4: 5: // Minimum spanning tree construction 6: 7: 8: 9: // Tree traversal ordering 10: 11: // Tree-structured feature refinement 12: 13: // Output computation 14: 15: return y |
3.3. The Loss Function
3.4. Model Configuration
4. Experiments and Analysis
4.1. Experimental Setup
4.2. Evaluation of the Effectiveness of Different Models
4.3. Evaluation of the Effectiveness of Sequence Processing Strategy
4.4. Evaluation of the Effectiveness of Different Sequence Frame Lengths
4.5. Evaluation of the Effectiveness of Different Sampling Strategies
4.6. Evaluation of the Effectiveness of TreeSSM
5. Discussion
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Wang, H.; Ren, X.; Zhang, Y.; Gao, H.; Che, L.; Wang, X. Application of Gene Chip Technology in Jinnan Bull Breeding. Acta Vet. Zootech. Sin. 2021, 52, 2803. [Google Scholar]
- da Silva Santos, A.; de Medeiros, V.W.C.; Gonçalves, G.E. Monitoring and classification of cattle behavior: A survey. Smart Agric. Technol. 2023, 3, 100091. [Google Scholar] [CrossRef]
- Dissanayake, O.; McPherson, S.; Allyndree, J.; Kennedy, E.; Cunningham, P.; Riaboff, L. Personalized Weighted AdaBoost for Animal Behavior Recognition from Sensor Data. In Proceedings of the 31st Irish Conference on Artificial Intelligence and Cognitive Science (AICS 2023), Letterkenny, Ireland, 7–8 December 2023; pp. 1–8. [Google Scholar]
- Zhang, Y.; Zhang, Y.; Gao, M.; Dai, B.; Kou, S.; Wang, X.; Fu, X.; Shen, W. Digital twin perception and modeling method for feeding behavior of dairy cows. Comput. Electron. Agric. 2023, 214, 108181. [Google Scholar] [CrossRef]
- Zhang, Y.; Zhang, Y.; Jiang, H.; Du, H.; Xue, A.; Shen, W. New method for modeling digital twin behavior perception of cows: Cow daily behavior recognition based on multimodal data. Comput. Electron. Agric. 2024, 226, 109426. [Google Scholar] [CrossRef]
- Dorea, J.R.; Bresolin, T.; Ferreira, R.E.P.; Pereira, L.G.R. 383 Harnessing the Power of Computer Vision System to Improve Management Decisions in Livestock Operations. J. Anim. Sci. 2020, 98, 138–139. [Google Scholar] [CrossRef]
- Chen, C.; Zhu, W.; Norton, T. Behaviour recognition of pigs and cattle: Journey from computer vision to deep learning. Comput. Electron. Agric. 2021, 187, 106255. [Google Scholar] [CrossRef]
- Rohan, A.; Rafaq, M.S.; Hasan, M.J.; Asghar, F.; Bashir, A.K.; Dottorini, T. Application of deep learning for livestock behaviour recognition: A systematic literature review. Comput. Electron. Agric. 2024, 224, 109115. [Google Scholar] [CrossRef]
- Wang, L.; Arablouei, R.; Alvarenga, F.A.P.; Bishop-Hurley, G.J. Classifying animal behavior from accelerometry data via recurrent neural networks. Comput. Electron. Agric. 2023, 206, 107647. [Google Scholar] [CrossRef]
- Qiao, Y.; Guo, Y.; Yu, K.; He, D. C3D-ConvLSTM based cow behaviour classification using video data for precision livestock farming. Comput. Electron. Agric. 2022, 193, 106650. [Google Scholar] [CrossRef]
- Han, Y.; Wu, J.; Zhang, H.; Cai, M.; Sun, Y.; Li, B.; Feng, X.; Hao, J.; Wang, H. Beef cattle abnormal behaviour recognition based on dual-branch frequency channel temporal excitation and aggregation. Biosyst. Eng. 2024, 241, 28–42. [Google Scholar] [CrossRef]
- Arablouei, R.; Bishop-Hurley, G.J.; Bagnall, N.; Ingham, A. Cattle behavior recognition from accelerometer data: Leveraging in-situ cross-device model learning. Comput. Electron. Agric. 2024, 227, 109546. [Google Scholar] [CrossRef]
- Martin-Cirera, A.; Nowak, M.; Norton, T.; Auer, U.; Oczak, M. Comparison of Transformers with LSTM for classification of the behavioural time budget in horses based on video data. Biosyst. Eng. 2024, 242, 154–168. [Google Scholar] [CrossRef]
- Peng, Y.; Chen, Y.; Yang, Y.; Liu, M.; Hu, R.; Zou, H.; Xiao, J.; Jiang, Y.; Wang, Z.; Xu, L. A multimodal classification method: Cow behavior pattern classification with improved EdgeNeXt using an inertial measurement unit. Comput. Electron. Agric. 2024, 226, 109453. [Google Scholar] [CrossRef]
- Geng, H.; Hou, Z.; Liang, J.; Li, X.; Zhou, X.; Xu, A. Motion focus global–local network: Combining attention mechanism with micro action features for cow behavior recognition. Comput. Electron. Agric. 2024, 226, 109399. [Google Scholar] [CrossRef]
- van Leerdam, M.; Hut, P.R.; Liseune, A.; Slavco, E.; Hulsen, J.; Hostens, M. A predictive model for hypocalcaemia in dairy cows utilizing behavioural sensor data combined with deep learning. Comput. Electron. Agric. 2024, 220, 108877. [Google Scholar] [CrossRef]
- Zheng, Z.; Qin, L. PrunedYOLO-Tracker: An efficient multi-cows basic behavior recognition and tracking technique. Comput. Electron. Agric. 2023, 213, 108172. [Google Scholar] [CrossRef]
- Zheng, K.; Yang, R.; Li, R.; Guo, P.; Yang, L.; Qin, H. A spatiotemporal attention network-based analysis of golden pompano school feeding behavior in an aquaculture vessel. Comput. Electron. Agric. 2023, 205, 107610. [Google Scholar] [CrossRef]
- Leliveld, L.M.C.; Brandolese, C.; Grotto, M.; Marinucci, A.; Fossati, N.; Lovarelli, D.; Riva, E.; Provolo, G. Real-time automatic integrated monitoring of barn environment and dairy cattle behaviour: Technical implementation and evaluation on three commercial farms. Comput. Electron. Agric. 2024, 216, 108499. [Google Scholar] [CrossRef]
- Gu, A.; Dao, T. Mamba: Linear-Time Sequence Modeling with Selective State Spaces. arXiv 2024, arXiv:2312.00752. [Google Scholar]
- Liu, Z.; Mao, H.; Wu, C.-Y.; Feichtenhofer, C.; Darrell, T.; Xie, S. A ConvNet for the 2020s. In Proceedings of the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR 2022), New Orleans, LA, USA, 18–24 June 2022; pp. 11966–11976. [Google Scholar]
- Dosovitskiy, A.; Beyer, L.; Kolesnikov, A.; Weissenborn, D.; Zhai, X.; Unterthiner, T.; Dehghani, M.; Minderer, M.; Heigold, G.; Gelly, S.; et al. An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. arXiv 2020, arXiv:2010.11929. [Google Scholar]
- Wang, W.; Xie, E.; Li, X.; Fan, D.-P.; Song, K.; Liang, D.; Lu, T.; Luo, P.; Shao, L. Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions. In Proceedings of the 2021 IEEE/CVF International Conference on Computer Vision (ICCV 2021), Montreal, QC, Canada, 11–17 October 2021; pp. 548–558. [Google Scholar]
- Zhu, L.; Liao, B.; Zhang, Q.; Wang, X.; Liu, W.; Wang, X. Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model. arXiv 2024, arXiv:2401.09417. [Google Scholar] [CrossRef]
- Guttmann, W.; Robinson-O’Brien, N. Relation-Algebraic Verification of Borůvka’s Minimum Spanning Tree Algorithm. In Proceedings of the 19th International Conference on Relational and Algebraic Methods in Computer Science (RAMiCS 2021), Marseille, France, 2–5 November 2021; Springer: Berlin/Heidelberg, Germany, 2021; pp. 225–240. [Google Scholar]
- Li, K.; Li, X.; Wang, Y.; He, Y.; Wang, Y.; Wang, L.; Qiao, Y. VideoMamba: State Space Model for Efficient Video Understanding. arXiv 2024, arXiv:2403.06977. [Google Scholar] [CrossRef]
Behavior Category | Behavioral Description | Label |
---|---|---|
Eating | Suckled at the teat | Eating |
Standing | Leg upright to support body | Standing |
Walking | Alternated bending of limbs, trunk horizontal, head raised | Walking |
Lying | Abdominal contact with ground | Lying |
Diarrhea | Diluted excreta discharged from their tails | Diarrhea |
Behavior Category | Total Number of Videos | Number of Distinct Calves |
---|---|---|
Diarrhea | 700 | 9 |
Eating | 722 | 10 |
Standing | 727 | 9 |
Walking | 730 | 9 |
Lying | 727 | 8 |
Total | 3606 | 45 |
Hyperparameter/Component | Value/Description |
---|---|
Input size | |
Sequence length | 20 |
Batch size | 32 |
Optimizer | Adam (, ) |
Initial learning rate | 0.001 |
Learning rate scheduler | StepLR(0.1) |
Training epochs | 250 |
Weight decay | 0.05 |
Stem block | |
TreeMamba layers | 4 |
TreeSSM state dimension | 16 |
MLP expansion ratio | 4 |
DropPath | 0.1 |
Model | Accuracy (%) | Loss | Precision (%) | Recall (%) | F1-Score (%) | Params (M) | FLOPs (G) | Latency (ms) |
---|---|---|---|---|---|---|---|---|
S_ConvNeXt | 99.15 | 1.810 | 99.12 | 99.06 | 99.09 | 28.59 | 4.47 | 4.85 ± 0.13 |
S_ViT | 97.83 | 1.897 | 97.91 | 97.85 | 97.88 | 5.72 | 1.26 | 5.47 ± 0.84 |
S_PVT | 99.19 | 1.830 | 99.18 | 99.14 | 99.16 | 13.23 | 1.94 | 5.78 ± 0.42 |
S_Bi_Mamba | 99.08 | 1.816 | 99.03 | 99.00 | 99.01 | 7.15 | 1.08 | 16.75 ± 0.96 |
S_Mamba | 99.53 | 1.767 | 99.51 | 99.47 | 99.49 | 37.13 | 2.92 | 11.59 ± 0.53 |
S_T_Mamba | 99.78 | 1.658 | 99.68 | 99.66 | 99.67 | 29.96 | 4.78 | 60.63 ± 8.34 |
Model | Accuracy (%) | ||||
---|---|---|---|---|---|
Diarrhea | Walking | Standing | Lying | Eating | |
S_ConvNeXt | 100 | 96.88 | 99.09 | 99.55 | 99.78 |
S_ViT | 100 | 93.70 | 96.22 | 99.60 | 99.73 |
S_PVT | 100 | 97.31 | 98.90 | 99.55 | 99.95 |
S_Bi_Mamba | 100 | 96.82 | 98.66 | 99.51 | 100 |
S_Mamba | 100 | 99.23 | 99.62 | 99.73 | 99.78 |
S_T_Mamba | 100 | 98.90 | 99.43 | 99.96 | 100 |
Model | Accuracy (%) |
---|---|
ConvNeXt | 63.47 |
S_ConvNeXt | 99.15 |
ViT | 77.45 |
S_ViT | 97.83 |
PVT | 78.29 |
S_PVT | 99.19 |
Bi_Mamba | 66.81 |
S_Bi_Mamba | 99.08 |
T_Mamba | 87.27 |
S_T_Mamba | 99.78 |
Model | 5 | 10 | 15 | 20 |
---|---|---|---|---|
S_ConvNeXt | 84.45 | 91.47 | 96.97 | 99.15 |
S_ViT | 87.99 | 93.20 | 95.88 | 97.83 |
S_PVT | 92.66 | 96.79 | 98.45 | 99.19 |
S_Bi_Mamba | 89.24 | 96.16 | 97.92 | 99.08 |
S_T_Mamba | 96.83 | 99.31 | 99.75 | 99.78 |
Model | Uniform | Random |
---|---|---|
S_ConvNeXt | 98.69 | 99.15 |
S_ViT | 97.62 | 97.83 |
S_PVT | 98.91 | 99.19 |
S_Bi_Mamba | 98.44 | 99.08 |
S_T_Mamba | 99.74 | 99.78 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Hao, W.; Xue, Y.; Shu, H.; Lv, B.; Li, H.; Han, M.; Liu, Y.; Li, F. S_T_Mamba: A Novel Jinnan Calf Diarrhea Behavior Recognition Model Based on Sequence Tree Mamba. Animals 2025, 15, 2646. https://doi.org/10.3390/ani15182646
Hao W, Xue Y, Shu H, Lv B, Li H, Han M, Liu Y, Li F. S_T_Mamba: A Novel Jinnan Calf Diarrhea Behavior Recognition Model Based on Sequence Tree Mamba. Animals. 2025; 15(18):2646. https://doi.org/10.3390/ani15182646
Chicago/Turabian StyleHao, Wangli, Yakui Xue, Hao Shu, Bingxue Lv, Hanwei Li, Meng Han, Yanhong Liu, and Fuzhong Li. 2025. "S_T_Mamba: A Novel Jinnan Calf Diarrhea Behavior Recognition Model Based on Sequence Tree Mamba" Animals 15, no. 18: 2646. https://doi.org/10.3390/ani15182646
APA StyleHao, W., Xue, Y., Shu, H., Lv, B., Li, H., Han, M., Liu, Y., & Li, F. (2025). S_T_Mamba: A Novel Jinnan Calf Diarrhea Behavior Recognition Model Based on Sequence Tree Mamba. Animals, 15(18), 2646. https://doi.org/10.3390/ani15182646