DEEP-GRAM: A Deep Learning Model for Gram Stain Species Prediction in Bloodstream Infections
CWSF · 2026 Disease & Illness Silver Medal
Overview
Bloodstream infections are life-threatening and frequently bacterial, requiring rapid initiation of species-specific antibiotic treatment. Gram staining provides initial bacterial characterization but cannot identify species. Definitive identification requires specialized testing that involves substantial resources, technical expertise, and can take two to three days. This delay can result in under-treatment or inappropriate broad-spectrum antibiotic use. To address this, I hypothesized that deep learning could automate Gram stain interpretation and extract species-specific morphological patterns imperceptible to the human eye. I generated an image dataset of Gram-stained blood cultures representing thirteen bacterial species. Then, I developed a multi-stage AI pipeline called DEEP-GRAM, comprising models for bacterial cell detection and isolation, Gram classification, morphology classification, species identification, and slide-level species prediction. The slide-level model achieved 92% accuracy for Gram type and morphology classification and 85% top-choice species accuracy. DEEP-GRAM demonstrates the potential for AI-assisted pathogen identification, reducing time to targeted treatment and improving patients outcomes.
Video
This video could not be played here. Watch it on the original project page.
Video
Transcript:
Every hour a bloodstream infection goes untreated, a patient’s chance of survival drops, making rapid bacterial species-specific antibiotic treatment critical. However, identifying the bacteria responsible can take days and requires resources many regions don’t have.
I’m Caroline Chan and to solve this problem, I created DEEP-GRAM, a deep learning model that identifies bacterial species directly from Gram stain images.
I hypothesized that artificial intelligence could detect species-specific patterns invisible to the human eye. To test this, I created an image dataset of simulated Gram-stained blood cultures and used it to develop a multi-stage AI pipeline that isolates individual bacteria, classifies their Gram type, morphology and species, and combines those classifications into a final species prediction for the whole slide.
DEEP-GRAM achieved an 85% accuracy in slide-level species classification, showing that AI-assisted pathogen identification is feasible and could improve patient outcomes, especially in low-resource settings, where every hour counts.
Why?
Introduction
Bacteria can enter the bloodstream and cause a bloodstream infection (BSI). If untreated, BSI can progress to sepsis, a dysregulated response to infection that can lead to organ failure and death. Sepsis is a leading infectious cause of death, affecting 75,000 Canadians annually, with a 30-day mortality rate of 25-30%.
When a patient is suspected of having a BSI, a blood culture is performed. If bacteria grow, a Gram stain provides preliminary information (available 1-2 hours after positive culture), including Gram type, morphology, and arrangement. However, definitive species identification typically requires specialized tools such as mass spectrometry or biochemical testing, taking 48-72 hours after positive culture.
Problem Statements
Problem 1: Accurate Gram stain interpretation requires extensive training and experience. In low-resource settings, access to expert microbiologists is limited.
Problem 2: During the 48-72 hour delay in species identification, physicians must make antibiotic decisions with incomplete information. This can lead to:
Under-treatment: Ineffective antibiotics allow the bloodstream infection to progress to sepsis and death.
Over-treatment: Broad-spectrum antibiotics improve coverage, but contribute to the growing crisis of antimicrobial resistance.
Proposed Solution
I propose to develop DEEP-GRAM, a deep learning image classification model trained on Gram stain microscopy images from blood cultures. It will perform:
Traditional Gram stain interpretation
Bacterial species prediction
Hypothesis:
Gram stain images contain subtle, species-level morphological information beyond the limits of human perception that deep neural networks can be trained to detect and use these features for species identification. This hypothesis has not previously been tested.
How?
Image Dataset Generation
1. Species Selection and Blood Culture Simulation: 13 bacterial species were selected to represent the most common causes of bloodstream infections (9 Gram positive, 4 Gram negative). Each species was subcultured, serially diluted, and inoculated into bacteria-free patient blood samples.
2. Gram Staining and Slide Preparation: Smears were prepared from each simulated blood culture, Gram stained, and coverslipped for digital scanning.
3. Digital Scanning: Slides were scanned at 400× magnification using a Huron Digital Pathology TissueScope LE120.
Multi-Stage Model Pipeline
1) Detection and Isolation Model
Goal: Identify and extract regions containing bacteria on slides while excluding background debris and blood cells. These crops were used for training downstream models.
Architecture: U-Net and 4-block CNN
Methods: Slide images were split into approximately 4,500 tiles. Using 50 annotated tiles per species, a U-Net detected and cropped bacterial regions. A 4-block CNN debris filter removed non-bacterial crops, yielding 659,448 crops.
2) Gram Type Model
Goal: Classify each bacteria as Gram positive (purple) or Gram negative (pink).
Architecture: Vision Transformer
Methods: Bacterial crops were used to train a vision transformer to classify Gram type.
3) Morphology Model
Goal: Classify each bacteria as bacilli, cocci clusters, or cocci chains.
Architecture: Vision Transformer
Methods: Bacterial crops were used to train vision transformer models for each gram type to classify morphology and arrangement.
4) Species Model
Goal: Classify each bacteria by its species.
Architecture: Transfer Learning
Methods: Bacteria crops were used to train transfer learning models for each morphology and gram subclass to classify the species.
Slide-Level Classification
In order to improve accuracy across an entire slide (over single-crop classification), Gram type, morphology, and species models were run on every crop from a slide, and all predictions were combined to generate a slide-level Gram type, morphology, and top 3 species prediction.
What?
Dataset and Evaluation
Bacterial crops were partitioned 80:20 into training and validation sets, with the validation set used to guide model development. Final pipeline performance was assessed on crops from a held-out set of test slides (one per species) never seen during training or validation.
Multi-Stage Model Pipeline
1) Detection and Isolation Model
The U-Net segmentation model, followed by a CNN-based debris filter, successfully isolated bacterial crops while excluding background debris and blood cells. Of all crops identified, 98% contained genuine bacteria, confirming reliable detection prior to downstream classification.
2) Gram Type Model
The Gram-type model classified 538,908 bacterial crops as either Gram-positive or Gram-negative, achieving 90.5% accuracy and an area under the receiver operating characteristic curve (AUC) of 0.967, indicating strong discriminative performance. AUC represents the probability that the model assigns a higher score to a randomly chosen positive sample than to a randomly chosen negative sample, where 1.0 indicates perfect discrimination and 0.5 indicates chance. Per-class sensitivity, the proportion of bacteria in each class correctly identified, was 90.7% for Gram-positives and 89.6% for Gram-negatives, reflecting balanced performance.
3) Morphology Model
Both morphology classifiers performed strongly. The Gram-negative morphology classifier, evaluated on 93,646 crops, achieved 86.2% accuracy and an AUC of 0.901, with high sensitivities for bacilli and cocci. The Gram-positive morphology classifier, applied to 445,262 crops, achieved 77.3% accuracy and an AUC of 0.913, with high sensitivities across all classes despite the greater morphological diversity within Gram-positive species.
4) Species Model
Four transfer learning architectures, EfficientNet-B4, DenseNet-201, ResNet-101, and ConvNeXt-Small, were evaluated on a subset of bacterial crops. Accuracy improved with architectural complexity: 69.9%, 80.3%, 86.4%, and 91.3%, respectively. ConvNeXt-Small was therefore selected for the final species classifier, correctly predicting 92% of species as the top-ranked match. The single misclassified species, S. mitis, was predicted as another member of the same genus (Streptococcus), likely reflecting their close morphological similarity. Notably, the two Enterococcus species, indistinguishable by eye, were differentiated with sensitivities of 77.3% for E. faecalis and 81.1% for E. faecium.
Slide-Level Classification
When individual crop predictions were aggregated across each slide, both Gram-type and morphology classification achieved 92.3% accuracy (12 of 13 slides). First-choice species prediction was correct for 84.6% of slides (11 of 13), rising to 100% when the top two predictions were considered. A one-sample binomial test against random selection among the 13 species (1/13) yielded p = 3.8 × 10⁻¹¹ for first-choice species accuracy, indicating that the observed performance is extremely unlikely to arise by chance.
Species Model Analysis
To confirm that the model was learning from true bacterial morphology rather than incidental image features, I applied Grad-CAM (Gradient-weighted Class Activation Mapping), a technique that highlights image regions most important to a prediction. The heatmaps showed that the species classifier focused on bacterial cells rather than background debris or staining artifacts, suggesting that classification decisions were driven by genuine morphological features.
So What?
Key Findings
DEEP-GRAM can perform standard Gram stain interpretation tasks (Gram type, morphology, arrangement) and species-level classification using a multi-stage neural network pipeline.
Gram stains contain species-level morphological information that DEEP-GRAM extracts from subtle patterns (e.g. differences in cell size, texture, staining intensity, and spatial organization) not visible to the human eye.
Population-level analysis across thousands of bacterial crops from a single slide improves classification accuracy, mirroring how expert microbiologists scan many microscopic fields before making an interpretation.
Species-level prediction from Gram stains alone is feasible with modern vision models, expanding the diagnostic potential of a century-old technique.
To my knowledge, this is the first project to test species level identification of bloodstream infections directly from Gram stain images. Prior machine learning classification of Gram stains from bloodstream infections has been limited to Gram type, morphology, arrangement, and genus. Species-level classification has not previously been published.
Clinical Significance
Integrating DEEP-GRAM into the traditional species identification pathway could decrease time from positive culture to directed antibiotic treatment for bloodstream infections by removing the need for additional subculture growth and equipment.
Earlier species prediction enables more targeted antibiotic selection, potentially improving patient outcomes and reducing overuse of broad-spectrum antibiotics.
DEEP-GRAM can assist microbiologists by automating early interpretive steps, reducing workload and freeing time for complex cases.
The system is particularly suited to low-resource settings, as it requires no new laboratory infrastructure.
What's Next?
Scan at higher magnification (800-1000×) to capture finer morphological details for distinguishing closely related species.
Improve robustness by training on more samples and adding new species.
Try other model architectures better suited to extracting subtle differences between species.
Validate across multiple labs and staining protocols to ensure generalization.
Test on real patient samples, including mixed infections and blood cultures, to reflect clinical variability.
Add support for other stain types, such as acid-fast and India ink, to broaden pathogen detection (e.g. mycobacteria, fungi).
Open-source the model and publicly release the image dataset to enable independent validation and accelerate further development.
Thanks
I sincerely thank my mentor, Dr. Susan Poutanen, as well as Golnoush Akhtari and the Mount Sinai Microbiology Research Lab for supporting my research and providing access to their equipment, bacteria, and offering technical expertise and guidance. Additionally, I thank Ioannis Prassas and Maximilian Domann for scanning my slides to create my dataset, and Phedias Diamandis for giving me guidance to improve my AI models.
I would also like to thank Barbara Worth and Colin Williams for providing guidance during the preparation of my project for the Canada Wide Science Fair.
Finally, I’d like to thank Dr. Burt, my biology teacher, and my family and friends for all their support in helping me to get to the Canada Wide Science Fair.
References
Bayot, M. L., Sharma, S., & Mirza, T. M. (2023, August 7). Acid Fast Bacteria. Nih.gov; StatPearls Publishing. https://www.ncbi.nlm.nih.gov/books/NBK537121/
BioRender. (2025). BioRender. Www.biorender.com; Biorender. https://www.biorender.com/
BYJUS. (2019). Major Difference Between Gram-Positive and Gram-Negative Bacteria. BYJUS. https://byjus.com/biology/difference-between-gram-positive-and-gram-negative-bacteria/
Canertas. (2025, December 18). Tiny Data, Big Impact: How Small Datasets Shape Big AI Models. Medium. https://medium.com/@can00ertas/tiny-data-big-impact-how-small-datasets-shape-big-ai-models-64131f79f275
Chisale, M., Salema, D., Sinyiza, F., Mkwaila, J., Kamudumuli, P., & Lee, H. (2020). A comparative evaluation of three methods for the rapid diagnosis of cryptococcal meningitis (CM) among HIV-infected patients in Northern Malawi. Malawi Medical Journal, 32(1), 3–7. https://doi.org/10.4314/mmj.v32i1.2
Clinical Lab Products. (2001, May 4). Cost conscious automated microbiology testing. Clinical Lab Products. https://clpmag.com/miscellaneous/cost-conscious-automated-microbiology-testing/
Dhiman, N., Hall, L., Wohlfiel, S. L., Buckwalter, S. P., & Wengenack, N. L. (2011). Performance and Cost Analysis of Matrix-Assisted Laser Desorption Ionization-Time of Flight Mass Spectrometry for Routine Identification of Yeast. Journal of Clinical Microbiology, 49(4), 1614–1616. https://doi.org/10.1128/jcm.02381-10
Excedr. (2025, October 22). How Much Does a MALDI-TOF Mass Spectrometer Cost? Excedr.com; Excedr. https://www.excedr.com/blog/how-much-does-a-maldi-tof-mass-spectrometer-cost
GeeksforGeeks. (2024, October 9). Vision Transformer (ViT) Architecture. GeeksforGeeks. https://www.geeksforgeeks.org/deep-learning/vision-transformer-vit-architecture/
Holmes, C. L., Albin, O. R., Mobley, H. L. T., & Bachman, M. A. (2024). Bloodstream infections: mechanisms of pathogenesis and opportunities for intervention. Nature Reviews Microbiology, 23. https://doi.org/10.1038/s41579-024-01105-2
Huron Technologies. (2026, March 22). TissueScopeTM LE120 Slide Scanner . Huron Technologies. https://www.hurontechnologies.com/solutions/tissuescope-le120/
Işıl, Ç., Koydemir, H. C., Eryilmaz, M., de Haan, K., Pillar, N., Mentesoglu, K., Unal, A. F., Rivenson, Y., Chandrasekaran, S., Garner, O. B., & Ozcan, A. (2025). Virtual Gram staining of label-free bacteria using dark-field microscopy and deep learning. Science Advances, 11(2). https://doi.org/10.1126/sciadv.ads2757
Jumaah, N., Joshi, S., & Doblin, S. (2014). Prevalence of Bacterial Contamination when using a Diversion Pouch during Blood Collection: A Single... Malaysian Journal of Medical Sciences, 21(3), 47–53. https://www.researchgate.net/publication/266028804_Prevalence_of_Bacterial_Contamination_when_using_a_Diversion_Pouch_during_Blood_Collection_A_Single_Center_Study_in_Malaysia
Kim, H. E., Maros, M. E., Siegel, F., & Ganslandt, T. (2022). Rapid Convolutional Neural Networks for Gram-Stained Image Classification at Inference Time on Mobile Devices: Empirical Study from Transfer Learning to Optimization. Biomedicines, 10(11), 2808. https://doi.org/10.3390/biomedicines10112808
Kim, H., Ganslandt, T., Miethke, T., Neumaier, M., & Kittel, M. (2020). Deep Learning Frameworks for Rapid Gram Stain Image Data Interpretation: Protocol for a Retrospective Data Analysis. JMIR Research Protocols, 9(7), e16843. https://doi.org/10.2196/16843
MacVane, S. H., & Dwivedi, H. P. (2024). Evaluating the impact of rapid antimicrobial susceptibility testing for bloodstream infections: a review of actionability, antibiotic use and patient outcome metrics. Journal of Antimicrobial Chemotherapy, 79(Supplement_1), i13–i25. https://doi.org/10.1093/jac/dkae282
Marshall, N. (2021, November 2). Beyond the Matrix: Mass Spec as a Clinical Microbiology Tool. ASM.org. https://asm.org/Articles/2021/November/Beyond-the-Matrix-Mass-Spec-as-a-Clinical-Microbio
McMahon, J., Tomita, N., Tatishev, E. S., Workman, A. A., Costales, C. R., Banaei, N., Martin, I. W., & Hassanpour, S. (2025). A novel framework for the automated characterization of Gram-stained blood culture slides using a large-scale vision transformer. Journal of Clinical Microbiology, 63(3), e0151424. https://doi.org/10.1128/jcm.01514-24
Microscope Central. (2015). Clinical Microscopes. Microscope Central. https://microscopecentral.com/collections/clinical
Rohde, M. (2011). Microscopy. Methods in Microbiology, 38, 61–100. https://doi.org/10.1016/b978-0-12-387730-7.00004-8
Ronneberger, O. (2015). U-Net: Convolutional Networks for Biomedical Image Segmentation. Uni-Freiburg.de. https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/
Sanderson, M., Chikhani, M., Blyth, E., Wood, S., Moppett, I. K., McKeever, T., & Simmonds, M. J. (2018). Predicting 30-day mortality in patients with sepsis: An exploratory analysis of process of care and patient characteristics. Journal of the Intensive Care Society, 19(4), 299–304. https://doi.org/10.1177/1751143718758975
Schuttevaer, R., Brink, A., Alsma, J., van Dijk, W., Melles, D. C., de Steenwinkel, J. E. M., Lingsma, H. F., Verbon, A., & Schuit, S. C. E. (2020). Non-adherence to antimicrobial guidelines in patients with bloodstream infection visiting the emergency department. European Journal of Internal Medicine, 78, 69–75. https://doi.org/10.1016/j.ejim.2020.04.013
Smith, K. P., Kang, A. D., & Kirby, J. E. (2017). Automated Interpretation of Blood Culture Gram Stains by Use of a Deep Convolutional Neural Network. Journal of Clinical Microbiology, 56(3). https://doi.org/10.1128/jcm.01521-17
SPOT Imaging Solutions, a division of Diagnostic Instruments, Inc. (2021, March 4). Digital SLR (DSLR) Camera to Microscope Adapters. SPOT Imaging Solutions. https://www.spotimaging.com/microscope-camera-adapters/dslr-microscope-adapters/
The Ottawa Hospital Foundation. (2023). All About Sepsis. The Ottawa Hospital Foundation. https://ohfoundation.ca/health-profiles/all-about-sepsis/
V, S., Prasad, K., Mukhopadhyay, C., & Banerjee, B. (2025). Vision transformer based bacteria classification model for Gram-stained direct smear images. Multimedia Tools and Applications, 84(19), 20289–20309. https://doi.org/10.1007/s11042-025-20742-0
Wang, X., Shi, Y., Guo, S., Qu, X., Xie, F., Duan, Z., Hu, Y., Fu, H., Shi, X., Quan, T., Wang, K., & Xie, L. (2024). A Clinical Bacterial Dataset for Deep Learning in Microbiological Rapid On-Site Evaluation. Scientific Data, 11(1). https://doi.org/10.1038/s41597-024-03370-5
Wikipedia Contributors. (2019a, March 11). Cryptococcus neoformans. Wikipedia; Wikimedia Foundation. https://en.wikipedia.org/wiki/Cryptococcus_neoformans
Wikipedia Contributors. (2019b, April 26). Gram stain. Wikipedia; Wikimedia Foundation. https://en.wikipedia.org/wiki/Gram_stain
Wikipedia Contributors. (2019c, September 7). Mycobacterium. Wikipedia; Wikimedia Foundation. https://en.wikipedia.org/wiki/Mycobacterium
Yi. (2024). An annotated dataset of gram stains from positive blood cultures. Figshare. https://doi.org/10.6084/u002Fm9.figshare.26004610.v2
Images (29)
Awards (2)
- Silver Medal
- Selected for CWSF 2026
Competition history
- CWSF 2026
Related projects
CWSF · 2026
Computer Vision For Bacterial Gram Stain Classification
CWSF · 2026
Pre-Symptomatic Sepsis Detection Using a Wearable Biosensing System and Deep Learning Framework
ISEF · 2022
A Novel Approach of Deep Learning on Detection and Classification of Leukemic Cells and BCR-ABL1 Gene
ISEF · 2020
Improving Hazard Characterization in Bacterial Pathogens: Predicting Efficiency of Antibiotics Using Machine Learning
ISEF · 2024
Utilizing Deep Learning to Facilitate Diagnosis of Look-Alike Leukemia Subtypes
JSHS · 2024
New York-Long Island Utilizing Deep Learning to Facilitate Diagnosis of Look-Alike Leukemia Subtypes
ISEF · 2021
HemaVision: A Deep Learning and Computer Vision-Based Mobile Screening System for Rapid, Inexpensive, and Automated Diagnosis of Hematological Diseases
ISEF · 2016
Can MRI Be Used as a Novel Technique to Diagnose Human Bacterial Blood Infections?
Closest projects by meaning, across every fair and year in the corpus.