AlexNet Fine-Tuned on HERLEV Dataset
This repository contains a fine-tuned AlexNet model trained on the HERLEV cervical cytology dataset for multi-class classification of Pap smear images.
The model was uploaded using the PyTorchModelHubMixin, enabling native Hugging Face loading via from_pretrained.
Model Details
- Architecture: AlexNet
- Framework: PyTorch
- Input size: 224 × 224 RGB
- Number of classes: 7
- Task: Cervical cell image classification
Classes
| Label | Cell Type |
|---|---|
| 0 | Superficial Squamous |
| 1 | Intermediate Squamous |
| 2 | Columnar |
| 3 | Mild Dysplasia |
| 4 | Moderate Dysplasia |
| 5 | Severe Dysplasia |
| 6 | Carcinoma in situ |
How to Use
Installation
pip install torch torchvision huggingface_hub pillow
Load the Model
import torch
from huggingface_hub import PyTorchModelHubMixin
from torchvision import transforms
from PIL import Image
from model import AlexNetHERLEV
model = AlexNetHERLEV.from_pretrained(
"hp1318/alexnet-finetuned-herlev"
)
model.eval()
Image Preprocessing
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
])
Run Inference
image = Image.open("cell_image.jpg").convert("RGB")
image = transform(image).unsqueeze(0)
with torch.no_grad():
outputs = model(image)
prediction = torch.argmax(outputs, dim=1)
print("Predicted class:", prediction.item())
Output
The model outputs logits for all cervical cell classes.
The predicted label corresponds to the class with the highest logit score.
Notes
- Input images must be RGB format.
- Images are resized to 224 × 224 before inference.
- Normalization follows ImageNet statistics.
- This model is intended for research and educational use only.
Citation
If you use this model in academic work, please cite the corresponding paper or repository.
- Downloads last month
- 21