Recommended production model. Fine-tuned MobileNetV2 for malaria parasite detection from thin blood smear microscopy images. Achieves
97.97% test accuracy — the highest in our model family. Part of
LocalMedScan.
MobileNetV2 outperforms PlasmoSENet by 1.42 percentage points while being 3x smaller and 3x faster. Transfer learning from ImageNet provides a decisive advantage on this dataset size (27K images).
Strong augmentation pipeline with RandomResizedCrop, RandomRotation(90), ColorJitter, GaussianBlur, and RandomErasing. The TransformSubset wrapper ensures training and validation use independent transforms.
1import torch
2import torchvision.models as models
3
4# Load model
5model = models.mobilenet_v2(weights=None)
6model.classifier[1] = torch.nn.Linear(model.last_channel, 2)
7state_dict = torch.load("model.pth", map_location="cpu", weights_only=True)
8model.load_state_dict(state_dict)
9model.eval()
10
11# Inference
12from torchvision import transforms
13from PIL import Image
14
15transform = transforms.Compose([
16 transforms.Resize((224, 224)),
17 transforms.ToTensor(),
18 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
19])
20
21img = Image.open("blood_smear_cell.png").convert("RGB")
22tensor = transform(img).unsqueeze(0)
23
24with torch.inference_mode():
25 probs = torch.softmax(model(tensor), dim=1)
26 # probs[0][0] = Parasitized, probs[0][1] = Uninfected