CoolFace
Modelpublic

Purino/resnet50-chest-pneumonia-256x256

sourceHugging Faceapache-2.0updated 10d agoView on Hugging Face
0likes51downloads
Model Card

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)

MetricValue
Accuracy0.8013
Precision (macro)0.8361
Recall (macro)0.747
F1 (macro)0.7626
ROC-AUC0.923
Cross-entropy loss0.4611

Per class

ClassPrecisionRecallF1Support
normal0.89860.52990.6667234
pneumonia0.77370.96410.8584390

Confusion matrix

True \ Prednormalpneumonia
normal124110
pneumonia14376

[image]

Data

SplitImages
Train4211
Validation3452
Test624

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:

  1. 1.Head only - 3 epochs, LR 0.001, backbone frozen.
  2. 2.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

python
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.