Deep Learning Classification of Urine Crystal Images using Convolutional Neural Networks

Main Article Content

Ronnarong Kaewprasert

Abstract

Background: Urinalysis is a fundamental component of routine clinical laboratory screening. Despite the widespread adoption of automated analyzers, manual microscopic classification of urinary sediment remains the gold standard. However, this manual process is time-consuming and susceptible to inter-observer variability among laboratory personnel.             This research addresses these limitations by developing an automated classification system for urine crystals leveraging Deep Learning techniques.


Objectives: The primary objective of this study is to develop a high-precision automated classification system for urine crystals using a custom Convolutional Neural Network (CNN). The secondary objective is to deploy the model as a real-time web application to minimize diagnostic errors and enhance the operational efficiency of laboratory technologists.


Method: The study utilized a dataset of 4,539 images categorized into 13 distinct types of urine crystals: Acyclovir, Bilirubin, Calcium Carbonate, Leucine, Calcium Phosphate,             Uric Acid, Triple Phosphate, Calcium Oxalate, Ammonium Biurate, Hippuric Acid, Tyrosine, Cystine, and Cholesterol. The dataset was partitioned into training and testing sets. Development was conducted using Python within the Google Colab environment, employing a Sequential CNN architecture with three convolutional layers. Furthermore, a web application was developed using the FastAPI framework to facilitate real-time image prediction.


Results: The experimental results demonstrate that the model achieved an overall accuracy of 92% on the test dataset. Exceptional performance was observed in several classes; notably, Acyclovir, Hippuric Acid, and Leucine achieved perfect F1-scores of 1.00. Other high-performing classes included Ammonium Biurate (F1-score: 0.98) and Cystine (F1-score: 0.92). Training monitored over 10 epochs showed consistent improvement, with both training and validation accuracy exceeding 90%, while the validation loss decreased in tandem with the training loss, indicating a well-generalized model without overfitting.


Conclusion: This research successfully demonstrates the effectiveness of a custom CNN model for high-precision automated urine crystal classification. Deployment via a FastAPI-based interface provides a practical and efficient tool for clinical laboratories. The system effectively reduces workload, saves time, and minimizes subjectivity in diagnosis, serving as a rapid screening tool to enhance the overall standards of urinalysis.

Article Details

How to Cite
Kaewprasert, R. (2026). Deep Learning Classification of Urine Crystal Images using Convolutional Neural Networks. Journal of Health Sciences Sukhothai hospital, 1(1), 32–49. retrieved from https://he05.tci-thaijo.org/index.php/jhsh-skth/article/view/7684
Section
Research Article

References

European Confederation of Laboratory Medicine. European urinalysis guidelines. Scand J Clin Lab Invest Suppl. 2000;60(231):1-96.

Becker KS, Marani S, Batra S, Chaker A. Urinalysis: guide for prescribers. Hosp Med Clin. 2016;5(4):554-571.

Li X, Shang J, Li Y, Xu J, Sun J, Zhang S. Deep learning based clinical urine sediment analysis: a pilot study. Biomed Signal Process Control. 2019;52:281-291.

Zhou Z, Xu J, Jiao X, Jin L, Zhao J, Tang Y. Automated identification of urine crystals based on shape features and SVM. J Med Syst. 2017;41(1):12.

Liang Y, Kong G, Pu J, He B, Jin L, Xu J, et al. Urine sediment particle detection using stacked denoising autoencoder and ResNet. IEEE Access. 2018;6:40148-40159.

Zhang M, Li L, Jiao X, Jin L, Zhao J, Tang Y. A multi-scale feature fusion CNN for urine sediment particle classification. Comput Biol Med. 2021;130:104214.

Salehinejad H, Colak E, Dowdell T, Barfett J, Valaee S. Generalization of deep neural networks for medical imaging with overlapping classes. In: Proc IEEE Eng Med Biol Soc (EMBC); 2019.

Smith J, Thomas K, Miller L. Texture and shape-based feature extraction for urinary crystal detection. Pattern Recognit Lett. 2018;105:112-121.

Zhang Y, Zhang L, Qin L, Qin Z, Guo Y, Liu H, et al. Small dataset challenges in automated microscopic diagnosis. J Med Syst. 2020;44(8):143.

Li Y, Zhang L, Qin L, Qin Z, Guo Y, Liu H, et al. Automated throughput enhancement in clinical laboratories via machine learning. J Clin Pathol. 2020;73(5):260-268.

Chen H, Jiao X, Jin L, Zhao J, Tang Y. Limitations of handcrafted features in urine sediment morphology. Biomed Signal Process Control. 2020;58:101845.

Garcia R, Lopez M. High-precision classification of uric acid crystals using Inception-V3. IEEE Trans Med Imaging. 2022;41(8):2105-2118.

Kumar P, Rawat SS, Jain S. Application of ResNet architectures in renal sediment analysis. Comput Biol Med. 2021;135:104612.

Tan L, Wang J, Song Z, Ye C, Feng L, Zhang Y. Ensemble learning for the detection of rare pathological crystals. Artif Intell Med. 2022;124:102231.

Zhao X, Li L, Jiao X, Jin L, Zhao J, Tang Y. Attention-based neural networks for discriminating benign and pathological urine particles. Med Image Anal. 2023;85:102741.

Roboflow. Urine Crystals Dataset [Internet]. San Francisco (CA): Roboflow Universe; 2024 [cited 2026 Mar 10]. Available from: https://universe.roboflow.com

Long J, Wang J, Song Z, Ye C, Feng L, Zhang Y. Optimization of image preprocessing in automated microscopic analysis. J Clin Lab Anal. 2023;37(4):e24810.

Wong TT, Yeh PY. Reliable accuracy estimates of deep learning models in medical imaging with small datasets. Inf Sci. 2020;508:13-36.

Ramos P, Silva A. Deploying deep learning models for real-time pathology using FastAPI and Docker. SoftwareX. 2024;25:101612.

Liang Y, Kong G, Pu J, He B, Jin L, Xu J, et al. Automated identification of urinary particles using deep convolutional neural networks. Comput Biol Med. 2022;142:105198.

Wang L, Zhang L, Qin L, Qin Z, Guo Y, Liu H, et al. Performance of ResNet architectures in automated urinalysis. IEEE Access. 2021;9:112340-112352.

Aris M. Challenges in cross-platform generalization of automated urinalysis systems. J Med Syst. 2026;50(2):45-58.

Brown L. Robustness of AI models in contaminated clinical urine samples. Clin Chem Lab Med. 2026;64(1):112-120.

Choi S, Park J, Kim H, Lee J, Jung S, Moon T. Generalization gaps in deep learning models for urinary sediment analysis. Digit Med Rev. 2025;11(3):201-215.