Image Classification
Transformers
Safetensors
PyTorch
convnextv2
chest-xray
convnext
medical
medical-imaging
pneumonia
Eval Results (legacy)
Instructions to use kiselyovd/chest-xray-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kiselyovd/chest-xray-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="kiselyovd/chest-xray-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("kiselyovd/chest-xray-classifier") model = AutoModelForImageClassification.from_pretrained("kiselyovd/chest-xray-classifier") - Notebooks
- Google Colab
- Kaggle
Upload artifacts
Browse files- .gitattributes +3 -0
- README.md +73 -32
- config.json +51 -0
- hf_export/config.json +51 -0
- hf_export/model.safetensors +3 -0
- hf_export/preprocessor_config.json +22 -0
- model.safetensors +3 -0
- preprocessor_config.json +22 -0
- samples/bacterial_pneumonia.png +3 -0
- samples/normal.png +3 -0
- samples/viral_pneumonia.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/bacterial_pneumonia.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
samples/normal.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/viral_pneumonia.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,59 +1,100 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
-
- image-classification
|
| 5 |
- chest-xray
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- medical-imaging
|
| 7 |
- pneumonia
|
| 8 |
-
- pytorch
|
| 9 |
-
-
|
| 10 |
-
- dinov2
|
| 11 |
-
library_name: pytorch
|
| 12 |
datasets:
|
| 13 |
-
-
|
| 14 |
-
pipeline_tag: image-classification
|
| 15 |
-
---
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
Three-class chest X-ray classifier distinguishing **normal**, **bacterial pneumonia**, and **viral pneumonia** on pediatric frontal radiographs. Main model: ConvNeXt-V2-Tiny fine-tuned on the Kaggle Chest X-Ray Images (Pneumonia) dataset (5,856 images) with a bacterial/viral split derived from filename metadata.
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## Metrics
|
| 26 |
|
| 27 |
| Metric | Value |
|
| 28 |
|---|---|
|
| 29 |
-
|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
|
|
| 33 |
-
|
|
| 34 |
-
|
|
| 35 |
-
| Baseline macro F1 | 84.2% |
|
| 36 |
-
| Baseline macro AUROC (OvR) | 94.2% |
|
| 37 |
-
| Test set size | 624.0 |
|
| 38 |
-
| Classes | bacterial_pneumonia, normal, viral_pneumonia |
|
| 39 |
|
| 40 |
## Usage
|
| 41 |
|
|
|
|
| 42 |
```python
|
| 43 |
-
from
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
```
|
| 52 |
|
| 53 |
-
## Intended use
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
https://github.com/kiselyovd/
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
library_name: transformers
|
| 4 |
+
|
| 5 |
+
pipeline_tag: image-classification
|
| 6 |
+
|
| 7 |
+
base_model: facebook/convnextv2-tiny-22k-224
|
| 8 |
tags:
|
|
|
|
| 9 |
- chest-xray
|
| 10 |
+
- convnext
|
| 11 |
+
- convnextv2
|
| 12 |
+
- image-classification
|
| 13 |
+
- medical
|
| 14 |
- medical-imaging
|
| 15 |
- pneumonia
|
| 16 |
+
- pytorch
|
| 17 |
+
- transformers
|
|
|
|
|
|
|
| 18 |
datasets:
|
| 19 |
+
- keremberke/chest-xray-classification
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
metrics:
|
| 22 |
+
- accuracy
|
| 23 |
+
- f1
|
| 24 |
|
| 25 |
+
widget:
|
| 26 |
+
- src: https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/bacterial_pneumonia.png
|
| 27 |
+
title: bacterial_pneumonia
|
| 28 |
+
- src: https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/normal.png
|
| 29 |
+
title: normal
|
| 30 |
+
- src: https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/samples/viral_pneumonia.png
|
| 31 |
+
title: viral_pneumonia
|
| 32 |
|
|
|
|
| 33 |
|
| 34 |
+
model-index:
|
| 35 |
+
- name: kiselyovd/chest-xray-classifier
|
| 36 |
+
results:
|
| 37 |
+
- task:
|
| 38 |
+
type: image-classification
|
| 39 |
+
dataset:
|
| 40 |
+
type: keremberke/chest-xray-classification
|
| 41 |
+
name: Chest X-Ray Images (Pneumonia)
|
| 42 |
+
metrics:
|
| 43 |
+
- type: auroc_macro_ovr
|
| 44 |
+
value: 0.9752638346619307
|
| 45 |
+
- type: accuracy
|
| 46 |
+
value: 0.9134615384615384
|
| 47 |
+
- type: macro_f1
|
| 48 |
+
value: 0.9029730638714358
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
# chest-xray-classifier
|
| 53 |
+
|
| 54 |
+
Production-grade 3-class chest X-ray classifier: normal vs bacterial pneumonia vs viral pneumonia.
|
| 55 |
|
| 56 |
## Metrics
|
| 57 |
|
| 58 |
| Metric | Value |
|
| 59 |
|---|---|
|
| 60 |
+
| classification_report | {'bacterial_pneumonia': {'precision': 0.8913857677902621, 'recall': 0.9834710743801653, 'f1-score': 0.9351669941060904, 'support': 242.0}, 'normal': {'precision': 0.995260663507109, 'recall': 0.8974358974358975, 'f1-score': 0.9438202247191011, 'support': 234.0}, 'viral_pneumonia': {'precision': 0.8356164383561644, 'recall': 0.8243243243243243, 'f1-score': 0.8299319727891157, 'support': 148.0}, 'accuracy': 0.9134615384615384, 'macro avg': {'precision': 0.9074209565511785, 'recall': 0.9017437653801291, 'f1-score': 0.9029730638714358, 'support': 624.0}, 'weighted avg': {'precision': 0.9171115127285565, 'recall': 0.9134615384615384, 'f1-score': 0.913452367196687, 'support': 624.0}} |
|
| 61 |
+
| confusion_matrix | [[238, 1, 3], [3, 210, 21], [26, 0, 122]] |
|
| 62 |
+
| classes | ['bacterial_pneumonia', 'normal', 'viral_pneumonia'] |
|
| 63 |
+
| auroc_macro_ovr | 0.9752638346619307 |
|
| 64 |
+
| accuracy | 0.9134615384615384 |
|
| 65 |
+
| macro_f1 | 0.9029730638714358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
## Usage
|
| 68 |
|
| 69 |
+
|
| 70 |
```python
|
| 71 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 72 |
+
import torch
|
| 73 |
+
from PIL import Image
|
| 74 |
|
| 75 |
+
processor = AutoImageProcessor.from_pretrained("kiselyovd/chest-xray-classifier")
|
| 76 |
+
model = AutoModelForImageClassification.from_pretrained("kiselyovd/chest-xray-classifier")
|
| 77 |
|
| 78 |
+
image = Image.open("your_image.png")
|
| 79 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 80 |
+
with torch.no_grad():
|
| 81 |
+
logits = model(**inputs).logits
|
| 82 |
+
predicted_class = logits.argmax(-1).item()
|
| 83 |
+
print(model.config.id2label[predicted_class])
|
| 84 |
```
|
| 85 |
|
|
|
|
| 86 |
|
| 87 |
+
## Training Data
|
| 88 |
+
|
| 89 |
+
Trained on [Chest X-Ray Images (Pneumonia)](https://huggingface.co/datasets/keremberke/chest-xray-classification).
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
## Source Code
|
| 93 |
+
|
| 94 |
+
[GitHub Repository](https://github.com/kiselyovd/chest-xray-classifier)
|
| 95 |
+
|
| 96 |
+
## Intended Use
|
| 97 |
|
| 98 |
+
This model is provided for research and educational purposes. The authors make no warranties about its suitability for any particular application. Users are responsible for evaluating the model's fitness for their use case, including fairness, safety, and compliance with applicable regulations.
|
| 99 |
|
| 100 |
+
> **Note:** This model card was generated from the [ml-project-template](https://github.com/kiselyovd/ml-project-template) scaffold.
|
config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ConvNextV2ForImageClassification"
|
| 4 |
+
],
|
| 5 |
+
"depths": [
|
| 6 |
+
3,
|
| 7 |
+
3,
|
| 8 |
+
9,
|
| 9 |
+
3
|
| 10 |
+
],
|
| 11 |
+
"drop_path_rate": 0.0,
|
| 12 |
+
"dtype": "float32",
|
| 13 |
+
"hidden_act": "gelu",
|
| 14 |
+
"hidden_sizes": [
|
| 15 |
+
96,
|
| 16 |
+
192,
|
| 17 |
+
384,
|
| 18 |
+
768
|
| 19 |
+
],
|
| 20 |
+
"id2label": {
|
| 21 |
+
"0": "LABEL_0",
|
| 22 |
+
"1": "LABEL_1",
|
| 23 |
+
"2": "LABEL_2"
|
| 24 |
+
},
|
| 25 |
+
"image_size": 224,
|
| 26 |
+
"initializer_range": 0.02,
|
| 27 |
+
"label2id": {
|
| 28 |
+
"LABEL_0": 0,
|
| 29 |
+
"LABEL_1": 1,
|
| 30 |
+
"LABEL_2": 2
|
| 31 |
+
},
|
| 32 |
+
"layer_norm_eps": 1e-12,
|
| 33 |
+
"model_type": "convnextv2",
|
| 34 |
+
"num_channels": 3,
|
| 35 |
+
"num_stages": 4,
|
| 36 |
+
"out_features": [
|
| 37 |
+
"stage4"
|
| 38 |
+
],
|
| 39 |
+
"out_indices": [
|
| 40 |
+
4
|
| 41 |
+
],
|
| 42 |
+
"patch_size": 4,
|
| 43 |
+
"stage_names": [
|
| 44 |
+
"stem",
|
| 45 |
+
"stage1",
|
| 46 |
+
"stage2",
|
| 47 |
+
"stage3",
|
| 48 |
+
"stage4"
|
| 49 |
+
],
|
| 50 |
+
"transformers_version": "5.5.4"
|
| 51 |
+
}
|
hf_export/config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ConvNextV2ForImageClassification"
|
| 4 |
+
],
|
| 5 |
+
"depths": [
|
| 6 |
+
3,
|
| 7 |
+
3,
|
| 8 |
+
9,
|
| 9 |
+
3
|
| 10 |
+
],
|
| 11 |
+
"drop_path_rate": 0.0,
|
| 12 |
+
"dtype": "float32",
|
| 13 |
+
"hidden_act": "gelu",
|
| 14 |
+
"hidden_sizes": [
|
| 15 |
+
96,
|
| 16 |
+
192,
|
| 17 |
+
384,
|
| 18 |
+
768
|
| 19 |
+
],
|
| 20 |
+
"id2label": {
|
| 21 |
+
"0": "LABEL_0",
|
| 22 |
+
"1": "LABEL_1",
|
| 23 |
+
"2": "LABEL_2"
|
| 24 |
+
},
|
| 25 |
+
"image_size": 224,
|
| 26 |
+
"initializer_range": 0.02,
|
| 27 |
+
"label2id": {
|
| 28 |
+
"LABEL_0": 0,
|
| 29 |
+
"LABEL_1": 1,
|
| 30 |
+
"LABEL_2": 2
|
| 31 |
+
},
|
| 32 |
+
"layer_norm_eps": 1e-12,
|
| 33 |
+
"model_type": "convnextv2",
|
| 34 |
+
"num_channels": 3,
|
| 35 |
+
"num_stages": 4,
|
| 36 |
+
"out_features": [
|
| 37 |
+
"stage4"
|
| 38 |
+
],
|
| 39 |
+
"out_indices": [
|
| 40 |
+
4
|
| 41 |
+
],
|
| 42 |
+
"patch_size": 4,
|
| 43 |
+
"stage_names": [
|
| 44 |
+
"stem",
|
| 45 |
+
"stage1",
|
| 46 |
+
"stage2",
|
| 47 |
+
"stage3",
|
| 48 |
+
"stage4"
|
| 49 |
+
],
|
| 50 |
+
"transformers_version": "5.5.4"
|
| 51 |
+
}
|
hf_export/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3c0b8fba6caa340cfbabf06119c6a9988b018c277a72d9565e0f62acda2a7d0
|
| 3 |
+
size 111498892
|
hf_export/preprocessor_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"crop_pct": 0.875,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.485,
|
| 8 |
+
0.456,
|
| 9 |
+
0.406
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "ConvNextImageProcessor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.229,
|
| 14 |
+
0.224,
|
| 15 |
+
0.225
|
| 16 |
+
],
|
| 17 |
+
"resample": 3,
|
| 18 |
+
"rescale_factor": 0.00392156862745098,
|
| 19 |
+
"size": {
|
| 20 |
+
"shortest_edge": 224
|
| 21 |
+
}
|
| 22 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3c0b8fba6caa340cfbabf06119c6a9988b018c277a72d9565e0f62acda2a7d0
|
| 3 |
+
size 111498892
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"crop_pct": 0.875,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.485,
|
| 8 |
+
0.456,
|
| 9 |
+
0.406
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "ConvNextImageProcessor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.229,
|
| 14 |
+
0.224,
|
| 15 |
+
0.225
|
| 16 |
+
],
|
| 17 |
+
"resample": 3,
|
| 18 |
+
"rescale_factor": 0.00392156862745098,
|
| 19 |
+
"size": {
|
| 20 |
+
"shortest_edge": 224
|
| 21 |
+
}
|
| 22 |
+
}
|
samples/bacterial_pneumonia.png
ADDED
|
Git LFS Details
|
samples/normal.png
ADDED
|
Git LFS Details
|
samples/viral_pneumonia.png
ADDED
|
Git LFS Details
|