This project applies Deep Learning and Computer Vision techniques to detect pneumonia from chest X-ray images.
It uses the Chest X-Ray Pneumonia Dataset from Kaggle (Kermany et al., Cell, 2018) and a DenseNet-121 architecture fine-tuned by transfer learning for binary classification (Normal vs Pneumonia).
This challenge was developed as a personal initiative, building on the knowledge gained during my Deep Learning coursework at ÉTS Montréal.
- Total: 5 216 training and 624 test images
- Two classes:
NORMALandPNEUMONIA - Basic grayscale normalization and resizing to 224×224
- Optional histogram equalization and denoising
- Backbone: DenseNet-121 pretrained on ImageNet
- Final layer: Replaced with a 2-class linear layer
- Loss: Weighted Cross-Entropy (to mitigate imbalance)
- Optimizer: AdamW (lr = 3e-4, weight_decay = 1e-4)
- Scheduler: Cosine Annealing
- Training device: Mac m1 & Ubuntu with RTX 3060 (automatic GPU detection)
- Accuracy: ≈ 93 %
- Weighted F1-score: 0.93
- NORMAL: Precision 0.98 | Recall 0.85 | F1 0.91
- PNEUMONIA: Precision 0.91 | Recall 0.99 | F1 0.95
The model achieves 93 % accuracy and a weighted F1-score of 0.93, showing a strong and balanced performance across both classes. Notably, the model maintains high precision for normal cases (reducing false alarms) while achieving near-perfect recall for pneumonia, ensuring critical cases are rarely missed.
Both classes reach Average Precision > 0.95, showing strong separability.
The pneumonia curve stays near the top-right, while the normal class drops slightly in precision at high recall.
- Applying stronger data augmentation to the NORMAL class
- Trying Focal Loss or class reweighting
- Fine-tuning deeper layers of the DenseNet backbone
# Install dependencies
pip install torch torchvision torchaudio opencv-python scikit-learn matplotlib tqdm
# Launch the notebook
jupyter notebook main.ipynbRobert Antaluca
ÉTS Montréal / Université de Technologie de Compiègne
Website: antaluca.com
Pneumonia Image Classification Using DenseNet Architecture
Classification of Paediatric Pneumonia Using Modified DenseNet-121 Deep-Learning Model
MIT License: feel free to modify and build upon this project for research or learning purposes.



