Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ResNet-18 Peripheral Blood Cell Classifier
|
| 2 |
+
|
| 3 |
+
## Model Description
|
| 4 |
+
|
| 5 |
+
This is a ResNet-18 model fine-tuned for peripheral blood cell (PBC) classification using fastai. The model can classify blood cell images into 8 different cell types with 98.07% validation accuracy.
|
| 6 |
+
|
| 7 |
+
## Model Details
|
| 8 |
+
|
| 9 |
+
- **Model Type**: ResNet-18 with transfer learning
|
| 10 |
+
- **Framework**: fastai (version <2.8.0)
|
| 11 |
+
- **Task**: Image Classification
|
| 12 |
+
- **Dataset**: Peripheral Blood Cell (PBC) dataset
|
| 13 |
+
- **Classes**: 8 cell types
|
| 14 |
+
- **Validation Accuracy**: 98.07%
|
| 15 |
+
|
| 16 |
+
## Cell Types
|
| 17 |
+
|
| 18 |
+
The model can classify the following blood cell types:
|
| 19 |
+
1. **Basophil** - A type of white blood cell involved in inflammatory reactions
|
| 20 |
+
2. **Eosinophil** - White blood cells that fight parasites and allergic reactions
|
| 21 |
+
3. **Erythroblast** - Immature red blood cells
|
| 22 |
+
4. **IG (Immature Granulocyte)** - Immature white blood cells
|
| 23 |
+
5. **Lymphocyte** - White blood cells that fight infections
|
| 24 |
+
6. **Monocyte** - Large white blood cells that become macrophages
|
| 25 |
+
7. **Neutrophil** - Most common white blood cells that fight bacterial infections
|
| 26 |
+
8. **Platelet** - Cell fragments that help blood clotting
|
| 27 |
+
|
| 28 |
+
## Training Details
|
| 29 |
+
|
| 30 |
+
- **Training Images**: 13,674
|
| 31 |
+
- **Validation Images**: 3,418
|
| 32 |
+
- **Architecture**: Pretrained ResNet-18 backbone with custom head
|
| 33 |
+
- **Training Strategy**:
|
| 34 |
+
- 4 epochs with frozen backbone
|
| 35 |
+
- 6 epochs with fine-tuning
|
| 36 |
+
- **Input Size**: 224x224 pixels
|
| 37 |
+
- **Preprocessing**: Standard ImageNet normalization
|
| 38 |
+
|
| 39 |
+
## Performance
|
| 40 |
+
|
| 41 |
+
- **Validation Accuracy**: 98.07%
|
| 42 |
+
- **All cell types**: >95% precision and recall
|
| 43 |
+
- **Best performers**: Eosinophil and Platelet (100% precision)
|
| 44 |
+
|
| 45 |
+
## Usage
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from fastai.vision.all import *
|
| 49 |
+
|
| 50 |
+
# Load the model
|
| 51 |
+
learn = load_learner('cell_classifier.pkl')
|
| 52 |
+
|
| 53 |
+
# Predict on an image
|
| 54 |
+
pred, pred_idx, probs = learn.predict('path/to/blood_cell_image.jpg')
|
| 55 |
+
print(f"Predicted: {pred}")
|
| 56 |
+
print(f"Confidence: {probs[pred_idx]:.2%}")
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Requirements
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
fastai>=2.7.0,<2.8.0
|
| 63 |
+
numpy<2.0
|
| 64 |
+
pillow>=10.0.0
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Model Files
|
| 68 |
+
|
| 69 |
+
- `cell_classifier.pkl` - Complete fastai learner with model and preprocessing
|
| 70 |
+
- `cell_classifier_weights.pth` - PyTorch weights only
|
| 71 |
+
- `confusion_matrix.png` - Validation confusion matrix
|
| 72 |
+
- `classification_report.csv` - Detailed classification metrics
|
| 73 |
+
- `training_summary.json` - Training configuration and results
|
| 74 |
+
|
| 75 |
+
## Citation
|
| 76 |
+
|
| 77 |
+
If you use this model, please cite:
|
| 78 |
+
|
| 79 |
+
```bibtex
|
| 80 |
+
@misc{pbc-cell-classifier-2024,
|
| 81 |
+
title={ResNet-18 Peripheral Blood Cell Classifier},
|
| 82 |
+
author={Your Name},
|
| 83 |
+
year={2024},
|
| 84 |
+
howpublished={Hugging Face Hub},
|
| 85 |
+
url={https://huggingface.co/your-username/pbc-cell-classifier}
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## License
|
| 90 |
+
|
| 91 |
+
This model is released under the MIT License.
|
| 92 |
+
|
| 93 |
+
## Created For
|
| 94 |
+
|
| 95 |
+
HuggingFace Agents-MCP-Hackathon Track 1 - MCP Tool/Server
|