Purino/resnet50-chest-pneumonia-256x256
resnet50-chest-pneumonia-256x256
Fine-tuned `microsoft/resnet-50` for binary chest X-ray pneumonia classification on the Kaggle dataset Chest pneumonia 256x256.
Research / educational use only. Not a medical device and not validated for clinical use.
Results (held-out test split, n=624)
Per class
Confusion matrix
Data
Classes: normal, pneumonia. Images are 256x256 grayscale X-rays, converted to 3-channel RGB, resized to 224x224 and normalized with the base checkpoint's statistics (mean (0.485, 0.456, 0.406), std (0.229, 0.224, 0.225)).
Augmentation (train only): random resized crop (scale 0.85-1.0), rotation +/-8 degrees, brightness/contrast jitter 0.15, random erasing (p=0.2), horizontal flip p=0.0. Class imbalance is handled with a weighted random sampler.
Training
Two phases with AdamW and mixed precision:
- Head only - 3 epochs, LR 0.001, backbone frozen.
- Full network - 7 epochs, backbone LR 1e-05, head LR 0.0001, cosine annealing.
Batch size 32, weight decay 0.0001, label smoothing 0.05, seed 42. The checkpoint with the best validation macro-F1 is the one published here.
Usage
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
proc = AutoImageProcessor.from_pretrained("Purino/resnet50-chest-pneumonia-256x256")
model = AutoModelForImageClassification.from_pretrained("Purino/resnet50-chest-pneumonia-256x256").eval()
img = Image.open("xray.png").convert("RGB")
with torch.no_grad():
logits = model(**proc(img, return_tensors="pt")).logits
print(model.config.id2label[int(logits.argmax(-1))])Limitations
- Trained on a single curated, preprocessed dataset; performance on raw X-rays from other scanners, hospitals or populations is untested.
- The dataset carries no patient identifiers, so patient-level separation between splits cannot be guaranteed and the reported metrics may be optimistic.
- Binary labels only - the model does not distinguish bacterial from viral pneumonia, and has never seen other pathologies.
- No calibration analysis; the softmax score should not be read as a probability of disease.
