Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
4 |
```py
|
5 |
Accuracy: 0.9891
|
6 |
F1 Score: 0.9893
|
@@ -23,3 +27,73 @@ weighted avg 0.9891 0.9891 0.9891 17092
|
|
23 |
```
|
24 |
|
25 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
# **WBC-Type-Classifier**
|
5 |
+
|
6 |
+
> **WBC-Type-Classifier** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify different types of white blood cells (WBCs) using the **SiglipForImageClassification** architecture.
|
7 |
+
|
8 |
```py
|
9 |
Accuracy: 0.9891
|
10 |
F1 Score: 0.9893
|
|
|
27 |
```
|
28 |
|
29 |

|
30 |
+
|
31 |
+
The model categorizes images into eight classes:
|
32 |
+
- **Class 0:** "Basophil"
|
33 |
+
- **Class 1:** "Eosinophil"
|
34 |
+
- **Class 2:** "Erythroblast"
|
35 |
+
- **Class 3:** "IG"
|
36 |
+
- **Class 4:** "Lymphocyte"
|
37 |
+
- **Class 5:** "Monocyte"
|
38 |
+
- **Class 6:** "Neutrophil"
|
39 |
+
- **Class 7:** "Platelet"
|
40 |
+
|
41 |
+
# **Run with Transformers🤗**
|
42 |
+
|
43 |
+
```python
|
44 |
+
!pip install -q transformers torch pillow gradio
|
45 |
+
```
|
46 |
+
|
47 |
+
```python
|
48 |
+
import gradio as gr
|
49 |
+
from transformers import AutoImageProcessor
|
50 |
+
from transformers import SiglipForImageClassification
|
51 |
+
from transformers.image_utils import load_image
|
52 |
+
from PIL import Image
|
53 |
+
import torch
|
54 |
+
|
55 |
+
# Load model and processor
|
56 |
+
model_name = "prithivMLmods/WBC-Type-Classifier"
|
57 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
58 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
59 |
+
|
60 |
+
def wbc_classification(image):
|
61 |
+
"""Predicts WBC type for a given blood cell image."""
|
62 |
+
image = Image.fromarray(image).convert("RGB")
|
63 |
+
inputs = processor(images=image, return_tensors="pt")
|
64 |
+
|
65 |
+
with torch.no_grad():
|
66 |
+
outputs = model(**inputs)
|
67 |
+
logits = outputs.logits
|
68 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
69 |
+
|
70 |
+
labels = {
|
71 |
+
"0": "Basophil", "1": "Eosinophil", "2": "Erythroblast", "3": "IG",
|
72 |
+
"4": "Lymphocyte", "5": "Monocyte", "6": "Neutrophil", "7": "Platelet"
|
73 |
+
}
|
74 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
75 |
+
|
76 |
+
return predictions
|
77 |
+
|
78 |
+
# Create Gradio interface
|
79 |
+
iface = gr.Interface(
|
80 |
+
fn=wbc_classification,
|
81 |
+
inputs=gr.Image(type="numpy"),
|
82 |
+
outputs=gr.Label(label="Prediction Scores"),
|
83 |
+
title="WBC Type Classification",
|
84 |
+
description="Upload a blood cell image to classify its WBC type."
|
85 |
+
)
|
86 |
+
|
87 |
+
# Launch the app
|
88 |
+
if __name__ == "__main__":
|
89 |
+
iface.launch()
|
90 |
+
```
|
91 |
+
|
92 |
+
# **Intended Use:**
|
93 |
+
|
94 |
+
The **WBC-Type-Classifier** model is designed to classify different types of white blood cells from blood smear images. Potential use cases include:
|
95 |
+
|
96 |
+
- **Medical Diagnostics:** Assisting pathologists in identifying different WBC types for diagnosis.
|
97 |
+
- **Hematology Research:** Supporting studies related to blood cell morphology and disease detection.
|
98 |
+
- **Automated Blood Analysis:** Enhancing automated diagnostic tools for rapid blood cell classification.
|
99 |
+
- **Educational Purposes:** Providing insights and training data for medical students and researchers.
|