Pneumonia Detection on chest X-ray images Using Ensemble of Deep Convolutional Neural Networks
Paper β’ 2312.07965 β’ Published
Official repository containing the pre-trained weights, modular source code, comparative benchmarks, and cross-validation evaluations for the BioHCL-SSSM model on the Guangzhou Pediatric Chest X-Ray Cohort (Kermany et al., Cell 2018; 5,856 images).
This central repository provides:
checkpoints/):best_student_cv.pt: Peak student model (Fold 2: 99.81% Val Acc, 0.9987 Val F1, 14.01M params, 8.56 GFLOPs).cross_validation/model_fold_1.pt to 10.pt: Full 10-fold cross-validation ensemble models.ablations/: Model weights for key architectural variants (best_student_bioprior.pt, best_student_single_cnn.pt, best_student_no_positional.pt, baseline_resnet50.pt).src/):BioHCLSSSM, LinearBioSSSMBlock, DualChainExtractor, HierarchicalConvBlock, and QuadraticPositionalEncoder.BioPINNLoss), and evaluation pipelines.results/):figures/): ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Input Chest X-Ray (3 x 224 x 224) β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββ
β DUAL-CHAIN FEATURE EXTRACTOR β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ€
βΌ βΌ β
[Hierarchical Conv Block] [DenseNet-121 Semantic Backbone] β
Multi-kernel (3x3, 5x5, 7x7) Dense connectivity (1024 -> 256) β
β β β
βββββββββββββββ¬ββββββββββββββ β
βΌ β
βββββββββββββββββββββββββββββ β
β Cross-Gated Fusion + β β
β Quadratic Positional Enc β β
βββββββββββββββ¬ββββββββββββββ β
βΌ β
βββββββββββββββββββββββββββββ β
β Selective State Space β βββ Linear O(N) Recurrence β
β (SSSM) Sequence Engine β βββ Continuous-to-Discrete β
β (3 Blocks, d_state=64) β βββ Zero-Order Hold (ZOH) β
βββββββββββββββ¬ββββββββββββββ β
βΌ β
βββββββββββββββββββββββββββββ β
β Additive Identity Skip β β
β Connection Highway β β
βββββββββββββββ¬ββββββββββββββ β
βΌ β
βββββββββββββββββββββββββββββ β
β Global Pooling & Head β βββΊ [NORMAL vs PNEUMONIA] β
βββββββββββββββββββββββββββββ
results/5_10_fold_cross_validation_metrics.csv)
Evaluated across the entire cohort (5,232 images pooled):
checkpoints/best_student_cv.pt).results/1_sota_benchmarks_master.csv)
Tested on the official 624-image Kermany held-out test split (234 Normal, 390 Pneumonia):
| Model | Architecture Family | Params (M) | FLOPs (G) | Accuracy (%) | Precision (%) | Recall (%) | Specificity (%) | F1-Score (%) | ROC-AUC (%) | Source |
|---|---|---|---|---|---|---|---|---|---|---|
| ResNet-50 | Classic CNN | 25.56 | 4.12 | 92.63 | 90.00 | 99.23 | 81.62 | 94.39 | 98.31 | Diagnostics 2026 |
| DenseNet-121 | Classic CNN | 7.98 | 2.88 | 92.62 | 91.18 | 99.23 | 81.60 | 95.04 | 98.78 | Appl. Sci. 2020 |
| Xception | Classic CNN | 22.91 | 8.38 | 95.03 | 94.26 | 98.00 | 89.96 | 96.08 | 98.10 | AJSE 2022 |
| ViT-Base (ViT-B/16) | Vision Transformer | 86.57 | 17.56 | 92.47 | 89.80 | 99.00 | 81.20 | 94.18 | 97.10 | arXiv:2312.07965 |
| DeiT-Small | Vision Transformer | 22.05 | 4.60 | 93.75 | 92.40 | 97.95 | 86.75 | 95.10 | 97.80 | ICML 2021 |
| Swin-T | Hierarchical ViT | 27.52 | 2.98 | 95.99 | 95.74 | 97.95 | 92.74 | 96.83 | 99.18 | Diagnostics 2026 |
| BioHCL-SSSM (Proposed Best) | State-Space Hybrid | 14.01 | 8.56 | 96.47 | 96.25 | 98.21 | 93.59 | 97.22 | 99.37 | Ours (Empirical Test Set) |
import torch
from PIL import Image
from huggingface_hub import hf_hub_download
from src.models.biohcl_sssm import BioHCLSSSM
from src.dataset import get_transforms
# 1. Download and load the pre-trained model
ckpt_path = hf_hub_download(
repo_id="unknownBrain/BioHCL-SSSM-Pediatric-Pneumonia",
filename="checkpoints/best_student_cv.pt"
)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = BioHCLSSSM(num_classes=2, embed_dim=512, chain_mode="dual", num_sssm_blocks=3)
state_dict = torch.load(ckpt_path, map_location=device)
if "model_state_dict" in state_dict:
state_dict = state_dict["model_state_dict"]
model.load_state_dict(state_dict)
model.to(device).eval()
# 2. Predict on a chest X-ray image
_, eval_transform = get_transforms(img_size=224)
image = Image.open("path_to_xray.jpeg").convert("RGB")
tensor = eval_transform(image=np.array(image))["image"].unsqueeze(0).to(device)
with torch.no_grad():
logits, _ = model(tensor)
probs = torch.softmax(logits, dim=1)[0]
classes = ["NORMAL", "PNEUMONIA"]
pred = classes[torch.argmax(probs).item()]
print(f"Prediction: {pred} (Confidence: {probs.max().item():.4f})")
This project is licensed under the MIT License. Dataset credit: Guangzhou Women and Childrenβs Medical Center (Kermany et al., Cell 2018).