Update README.md
Browse files
README.md
CHANGED
|
@@ -6,7 +6,125 @@ tags:
|
|
| 6 |
- pytorch_model_hub_mixin
|
| 7 |
---
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- pytorch_model_hub_mixin
|
| 7 |
---
|
| 8 |
|
| 9 |
+
---
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
pipeline_tag: image-classification
|
| 12 |
+
tags:
|
| 13 |
+
- medical-imaging
|
| 14 |
+
- cervical-cancer
|
| 15 |
+
- pap-smear
|
| 16 |
+
- pytorch
|
| 17 |
+
- alexnet
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# AlexNet Fine-Tuned on HERLEV Dataset
|
| 21 |
+
|
| 22 |
+
This repository contains a fine-tuned **AlexNet** model trained on the **HERLEV cervical cytology dataset** for multi-class classification of Pap smear images.
|
| 23 |
+
|
| 24 |
+
The model was uploaded using the **PyTorchModelHubMixin**, enabling native Hugging Face loading via `from_pretrained`.
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## Model Details
|
| 29 |
+
|
| 30 |
+
- **Architecture:** AlexNet
|
| 31 |
+
- **Framework:** PyTorch
|
| 32 |
+
- **Input size:** 224 × 224 RGB
|
| 33 |
+
- **Number of classes:** 7
|
| 34 |
+
- **Task:** Cervical cell image classification
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## Classes
|
| 39 |
+
|
| 40 |
+
| Label | Cell Type |
|
| 41 |
+
|------|-----------|
|
| 42 |
+
| 0 | Superficial Squamous |
|
| 43 |
+
| 1 | Intermediate Squamous |
|
| 44 |
+
| 2 | Columnar |
|
| 45 |
+
| 3 | Mild Dysplasia |
|
| 46 |
+
| 4 | Moderate Dysplasia |
|
| 47 |
+
| 5 | Severe Dysplasia |
|
| 48 |
+
| 6 | Carcinoma in situ |
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## How to Use
|
| 53 |
+
|
| 54 |
+
### Installation
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
pip install torch torchvision huggingface_hub pillow
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## Load the Model
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
import torch
|
| 67 |
+
from huggingface_hub import PyTorchModelHubMixin
|
| 68 |
+
from torchvision import transforms
|
| 69 |
+
from PIL import Image
|
| 70 |
+
|
| 71 |
+
from model import AlexNetHERLEV
|
| 72 |
+
|
| 73 |
+
model = AlexNetHERLEV.from_pretrained(
|
| 74 |
+
"hp1318/alexnet-finetuned-herlev"
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
model.eval()
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## Image Preprocessing
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
transform = transforms.Compose([
|
| 86 |
+
transforms.Resize((224, 224)),
|
| 87 |
+
transforms.ToTensor(),
|
| 88 |
+
transforms.Normalize(
|
| 89 |
+
mean=[0.485, 0.456, 0.406],
|
| 90 |
+
std=[0.229, 0.224, 0.225]
|
| 91 |
+
)
|
| 92 |
+
])
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
## Run Inference
|
| 98 |
+
|
| 99 |
+
```python
|
| 100 |
+
image = Image.open("cell_image.jpg").convert("RGB")
|
| 101 |
+
image = transform(image).unsqueeze(0)
|
| 102 |
+
|
| 103 |
+
with torch.no_grad():
|
| 104 |
+
outputs = model(image)
|
| 105 |
+
prediction = torch.argmax(outputs, dim=1)
|
| 106 |
+
|
| 107 |
+
print("Predicted class:", prediction.item())
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## Output
|
| 113 |
+
|
| 114 |
+
The model outputs logits for all cervical cell classes.
|
| 115 |
+
The predicted label corresponds to the class with the highest logit score.
|
| 116 |
+
|
| 117 |
+
---
|
| 118 |
+
|
| 119 |
+
## Notes
|
| 120 |
+
|
| 121 |
+
- Input images must be RGB format.
|
| 122 |
+
- Images are resized to 224 × 224 before inference.
|
| 123 |
+
- Normalization follows ImageNet statistics.
|
| 124 |
+
- This model is intended for research and educational use only.
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
## Citation
|
| 129 |
+
|
| 130 |
+
If you use this model in academic work, please cite the corresponding paper or repository.
|