Downloads · 30 days
0
kamal-018/PBC_VIT
PBC_VIT is a machine learning model from kamal-018. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains PyTorch model weights (teachermodel.pth and studentmodel.pth) for 8-type Peripheral Blood Cell classification. The models leverage Vision Transformer (ViT) architectures and Knowledge Distilla…
Downloads · 30 days
0
Access
Public
Updated Aug 9, 2026
Repo size
290 MB
Likes
0
Public
Click a slice to open those files.
.pth290 MB · 100%
From the Hugging Face model README
This repository contains PyTorch model weights (teacher_model.pth and student_model.pth) for 8-type Peripheral Blood Cell classification. The models leverage Vision Transformer (ViT) architectures and Knowledge Distillation (KD) for efficient cellular analysis.
basophil, eosinophil, erythroblast, ig, lymphocyte, monocyte, neutrophil, platelet).vit_tiny_patch16_224 (5M parameters, ~22MB).| Model | Architecture | Parameters | Test Accuracy | Precision | Recall | F1-Score | MCC |
|---|---|---|---|---|---|---|---|
Teacher (teacher_model.pth) | Custom ViT Base | ~67M | 95.44% | 0.9568 | 0.9544 | 0.9548 | 0.9470 |
Student (student_model.pth) | ViT Tiny (vit_tiny_patch16_224) | ~5M | 97.02% | 0.9712 | 0.9702 | 0.9703 | 0.9653 |
label2id = {
"basophil": 0,
"eosinophil": 1,
"erythroblast": 2,
"ig": 3,
"lymphocyte": 4,
"monocyte": 5,
"neutrophil": 6,
"platelet": 7,
}
id2label = {v: k for k, v in label2id.items()}
timm / PyTorchstudent_model.pth)import timm
import torch
from torchvision import transforms
# 1. Initialize Student Architecture
model = timm.create_model("vit_tiny_patch16_224", pretrained=False, num_classes=8)
# 2. Load Weight Checkpoint
state_dict = torch.load("student_model.pth", map_location="cpu")
model.load_state_dict(state_dict)
model.eval()
# 3. 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]
),
]
)
from PIL import Image
image = Image.open("blood_cell_image.jpg").convert("RGB")
input_tensor = transform(image).unsqueeze(0)
with torch.no_grad():
logits = model(input_tensor)
probs = torch.nn.functional.softmax(logits, dim=-1)
predicted_class_id = torch.argmax(probs, dim=-1).item()
print(
f"Predicted Class: {id2label[predicted_class_id]} ({probs[0][predicted_class_id]*100:.2f})"
)