- Medical Imaging
- VGG19
- Transfer Learning
Diagnosing Pneumonia Using Deep Learning
A VGG19-based classifier that distinguishes pneumonia from COVID-19 on chest X-rays.

Pneumonia remains a significant global health challenge, claiming approximately one million lives each year. It disproportionately affects children under five and adults over 65. In 2016, pneumonia accounted for roughly one in every six childhood deaths worldwide. The condition involves inflammation of the lungs that impairs breathing and can become fatal if not treated promptly. Common symptoms include fever, cough with mucus, chest pain, and shortness of breath. Most cases are fully curable within four weeks when diagnosed early.
There are four main types of pneumonia: walking, bacterial, viral, and chemical. Early and accurate detection is critical, as misdiagnosis contributes to around 100,000 fatalities annually. Misdiagnosis often stems from limited access to experienced specialists, rushed examinations, or overlap with symptoms of other respiratory conditions.
Recent advances in computer vision, particularly through deep neural networks and convolutional neural networks (CNNs), offer promising tools for improving diagnostic accuracy. These models have achieved over 90% accuracy in various object detection tasks, supported by large labeled datasets such as ImageNet (approximately 40 million human-labeled images) and increased computational power from GPUs.
Convolutional neural networks typically operate in stages: early layers detect basic features such as edges, colors, and curves, while deeper layers identify textures, shapes, and complex patterns. The final layers perform classification by assigning labels based on learned representations.
A common approach for medical imaging tasks involves transfer learning. Pre-trained models such as VGG16 or ResNet50, originally trained on large general image datasets, can be adapted for chest X-ray classification. VGG16 is frequently selected due to its strong performance on image recognition benchmarks.
In this setup, the model is customized by removing the original top classification layers (to accommodate a binary pneumonia vs. normal classification) and adding new layers suited to the task. The base layers are frozen to preserve pre-trained weights. A flatten layer is added, followed by a final dense layer with softmax activation for the two-class output. The model is compiled using the Adam optimizer and categorical cross-entropy loss.
Data augmentation is applied to the training set using ImageDataGenerator to increase variety without compromising class representation. Typical parameters include rescaling (1/255), shear range (0.2), zoom range (0.2), and horizontal flip. Both training and validation datasets are processed with a batch size of 32 and image size of 224x224 pixels. The model is then trained using a fit generator.
Reported performance metrics for this model include:
- Accuracy: 90% (correct diagnoses overall)
- Loss: 0.2
- Recall: 90% (critical in medical contexts to minimize false negatives)
- AUC: 0.89
Recall is prioritized as the primary metric in medical diagnostics, as false negatives carry higher risk than false positives.
Future enhancements could include multi-class classification to differentiate pneumonia from other lung infections (such as COVID-19 or tuberculosis) and localization of infection regions within the lungs. Such models have potential to support radiologists and healthcare professionals when integrated into diagnostic workflows, subject to rigorous clinical validation.
References
- What Causes Pneumonia in the Elderly? (2017, October 28). Retrieved from aging.com
- Misdiagnosis of Pneumonia: Passen & Powell: Chicago Injury Trial Lawyers. (2018, May 08). Retrieved from passenpowell.com