kiselyovd's picture
docs: add hero banner
85ed64b verified
|
Raw
History Blame Contribute Delete
5.72 kB
metadata
license: mit
library_name: transformers
pipeline_tag: image-classification
base_model: facebook/convnextv2-tiny-22k-224
tags:
  - chest-xray
  - convnext
  - convnextv2
  - image-classification
  - medical
  - medical-imaging
  - pneumonia
  - pytorch
  - transformers
datasets:
  - keremberke/chest-xray-classification
metrics:
  - accuracy
  - f1
widget:
  - src: >-
      https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/bacterial_pneumonia.png
    example_title: bacterial_pneumonia
  - src: >-
      https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/normal.png
    example_title: normal
  - src: >-
      https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/viral_pneumonia.png
    example_title: viral_pneumonia
model-index:
  - name: kiselyovd/chest-xray-classifier
    results:
      - task:
          type: image-classification
        dataset:
          type: keremberke/chest-xray-classification
          name: Chest X-Ray Images (Pneumonia)
        metrics:
          - type: auroc_macro_ovr
            value: 0.9752638346619307
          - type: accuracy
            value: 0.9134615384615384
          - type: macro_f1
            value: 0.9029730638714358

chest-xray-classifier

chest-xray-classifier - 3-class pneumonia classification

A 3-class chest X-ray classifier that distinguishes bacterial pneumonia, normal, and viral pneumonia on pediatric frontal chest radiographs. The main model is a ConvNeXt-V2-Tiny fine-tuned with the transformers library; a DINOv2 ViT-S linear probe serves as the baseline.

Medical disclaimer: this model is provided for research and educational purposes only. It is not a medical device and must not be used for clinical diagnosis or treatment decisions.

Metrics

Evaluated on the held-out test split (624 radiographs: 242 bacterial / 234 normal / 148 viral). All values are reported as percentages.

Model Accuracy Macro F1 Macro AUROC (OvR)
ConvNeXt-V2-Tiny (main) 91.3% 90.3% 97.5%
DINOv2 ViT-S linear probe (baseline) 85.6% 84.2% 94.2%

Per-class results (main model)

Class Precision Recall F1 Support
bacterial_pneumonia 89.1% 98.3% 93.5% 242
normal 99.5% 89.7% 94.4% 234
viral_pneumonia 83.6% 82.4% 83.0% 148
Macro avg 90.7% 90.2% 90.3% 624
Weighted avg 91.7% 91.3% 91.3% 624

Visualizations

All charts below are generated by scripts/make_plots.py, which runs this exact model over the full test split. The computed accuracy / macro-F1 / macro-AUROC are cross-checked against the committed evaluation report before any chart is rendered.

Confusion matrix

Confusion matrix

Counts and row-normalized rates on the 624-image test split. Bacterial pneumonia and normal are recognized strongly; the main source of error is viral pneumonia being predicted as bacterial pneumonia, which is the clinically hardest distinction in this dataset.

ROC curves (one-vs-rest)

ROC curves

One-vs-rest ROC curves with per-class AUROC. The normal class separates near-perfectly, while viral pneumonia is the most challenging, consistent with the confusion matrix.

Sample predictions

Sample predictions

Representative correctly-classified test radiographs (two per class) with predicted class and softmax confidence.

Usage

import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForImageClassification

processor = AutoImageProcessor.from_pretrained("kiselyovd/chest-xray-classifier")
model = AutoModelForImageClassification.from_pretrained("kiselyovd/chest-xray-classifier")
model.eval()

image = Image.open("your_radiograph.png").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
    logits = model(**inputs).logits

probs = torch.softmax(logits, dim=-1)[0]
pred_id = int(probs.argmax())
print(model.config.id2label[pred_id], float(probs[pred_id]))

Class index order (model id2label): 0 -> bacterial_pneumonia, 1 -> normal, 2 -> viral_pneumonia.

Training data

Trained on the Chest X-Ray Images (Pneumonia) dataset of pediatric frontal chest radiographs. The original two-class layout (NORMAL / PNEUMONIA) is split into three classes by separating the PNEUMONIA images into bacterial and viral cases, producing the bacterial_pneumonia / normal / viral_pneumonia target space.

Intended use and limitations

Research and educational use only. This model is not a medical device, has not been clinically validated, and must not be used for diagnosis or any clinical decision-making. It was trained on a single pediatric dataset and may not generalize to adult radiographs, other imaging equipment, or different acquisition protocols. Users are responsible for evaluating fitness for their use case, including fairness, safety, and compliance with applicable regulations.

Source code

GitHub Repository

License

MIT.