Smear reader: computer vision that finds malaria-infected blood cells in the browser

Smear reader on a desktop in a laboratory: the view moves across a blood smear and the models ring every cell, infected ones in violet

Type

Orangesoft R&D

Industry

Healthcare

Work involved

Dataset preparationModel design and trainingValidation across hospitalsIn-browser inferenceWeb interface

Data

Open datasets only

Built

November 2026

About the project

Smear reader is Orangesoft’s own computer vision research project. It takes a photo of a stained blood smear, finds every red blood cell, flags the ones infected with the malaria parasite Plasmodium falciparum, and computes parasitemia, the share of infected cells.

We built it on open data to work through the full path of a medical imaging project, from labelling rules to an honest test on hospitals the model never saw. Everything runs in the browser tab: the photo is never uploaded.

The challenge

A parasite is 10 to 15 pixels across on a cell about 110 pixels wide, inside a 5312×2988 photo. A model that reads such photos has to stay right when the lab, the camera and the stain change.

The training data came from one hospital in Chittagong, Bangladesh: 965 photos of thin smears from 193 patients, taken with a phone through the microscope eyepiece, with 196,934 cells labelled by an expert. 7,952 of them, 4%, are infected (Kassim et al., 2020; images courtesy of the U.S. National Library of Medicine).

Three goals shaped the project:

  • Find every red cell and flag the infected ones on a full-resolution photo.
  • Measure the model only on patients and hospitals it never saw in training, and show where it fails.
  • Run in an ordinary browser, with nothing sent to a server.

Delivered solution

A browser app with two small neural networks trained from scratch: about 1.06 million parameters and 4.2 MB together.

The first network finds the centre of every cell on a copy of the photo four times smaller. The second looks at each cell at full resolution and decides whether it is infected. The app draws the result on the smear, counts red and white cells, computes parasitemia and shows the expert’s own count for the same image next to it.

The models run with ONNX Runtime Web on WebGPU and fall back to WebAssembly when the device has no suitable GPU. In Chrome on a laptop with an Apple M5 Pro, a 5312×2988 photo takes 84 to 120 ms with WebGPU and 1.2 to 1.6 s on a single WebAssembly thread. On six test photos the browser gave the same counts as the Python reference, with one photo off by a single cell.

Training took 12 minutes for the detector and 3.5 minutes for the classifier, on a laptop.

Key features

One screen: the smear with every cell marked, the counts next to the expert’s, and a threshold the lab controls.

Every red cell, found and counted

Every red cell, found and counted

The detector rings each red blood cell. On 28 held-out patients it found 97.1% of the cells the expert labelled, and 98.4% of its marks were real cells.

Infected cells flagged, with a loupe to check

Infected cells flagged, with a loupe to check

Infected cells get a violet ring, and a loupe magnifies any cell with the parasite in view. On the same patients the model found 81.7% of infected cells, and 86.9% of its flags were right.

Parasitemia next to the expert’s count

Parasitemia next to the expert’s count

For each photo the app shows red cells, infected cells and parasitemia, with the expert’s own count for the same photo. Per patient, the model’s parasitemia was 0.89 percentage points away from the expert’s on average, with a correlation of 0.98.

The lab sets the threshold

The lab sets the threshold

A slider sets the confidence above which a cell is flagged: the balance between a missed infection and a false alarm is the lab’s call, not the model’s. The default, 80%, was chosen on separate patients: training batches held 25% infected cells, while the smears in this dataset hold 4%.

A clean smear stays clean

A clean smear stays clean

On a smear from a patient without infection the model rings every cell and flags none. On the four healthy test patients, its parasitemia never went above 0.36%.

How the model works

Two small networks instead of one. Shrink the photo enough to find cells quickly and a parasite shrinks to 3 pixels, too small to see. So one network finds cells on a small copy, and the other checks each cell at full resolution.

  1. A part of a thin blood smear photo with red blood cells and a few parasites

    The photo

    A thin smear stained with Giemsa, photographed with a phone through the microscope eyepiece at 5312×2988 pixels.

  2. The detector heatmap: a bright spot at the centre of each red blood cell

    Find the cells

    The detector reads a copy four times smaller and lights up the centre of each red cell. It also measures the image scale itself, from the cell edges, so a new lab needs no settings.

  3. Single-cell crops with the model’s confidence: infected cells above, uninfected below

    Check each cell

    The classifier looks at every cell at full resolution and gives its confidence that the cell is infected.

  4. The same smear with teal rings on uninfected cells and violet rings on infected ones

    Decide and count

    Cells above the threshold are flagged in violet, the rest in teal, and the app computes parasitemia for the photo.

Results on patients the model never saw

0.1 s
to read a 5312×2988 photo in the browser (WebGPU, Apple M5 Pro)
97%
of red cells found on 28 held-out patients
0.98
correlation of parasitemia with the expert, per held-out patient

Trained in one hospital, tested in six others

The model learned from 136 patients at one hospital. Then, without any retraining, we ran it on 285 photos from six French hospital labs: other cameras, another stain protocol, cells from 0.7 to 2.3 times the size in pixels. Images from these labs are not shown, only the numbers.

How the model did on held-out patients from its own hospital and on six French hospital labs it never saw
LabImagesCells foundInfected cells foundFlags that were right
Chittagong, held-out patientsSame hospital as the training data14097%82%87%
Lille4099%96%47%
Montpellier4096%91%38%
Nantes2599%80%98%
Rouen4096%90%76%
Saint-Louis, Paris4097%50%5%
Toulouse4099%96%96%

Cells found: the share of the expert’s red cells the model found. Infected cells found: the share of the expert’s infected cells the model flagged. Flags that were right: the share of the model’s flags that the expert also marked infected.

Sample of the French test set: up to 40 P. falciparum photos per lab, spread across smears (Nantes has 25 in total), plus 60 photos of Montpellier smears without infection. Counted are cells fully inside the frame. One run.

French data: Guemas et al., Zenodo, CC BY 4.0.

What carried over, and what did not

Finding cells carries over between labs. Spotting infection carries over much less reliably than finding cells.

Cells: 96 to 99% found in every lab

Across all six labs the model found 96 to 99% of the red cells fully inside the frame, and 92 to 98% of its marks were real cells. The scale is measured from each photo, with no settings per lab.

Infection: uneven, with one lab failing

In five of the six labs, 38 to 98% of the cells it flagged were really infected. In the sixth, Saint-Louis, the sample held only 6 infected cells and the model raised 53 false flags, so 3 of its 56 flags were right.

Labelling rules differ between labs

At first the model seemed to miss 14 to 35% of cells in the French labs. Of those misses, 87 to 99% were cells cut by the frame edge: the French labels include them, the training labels do not. Without that check, a good detector is easy to call a bad one.

Healthy smears: 1.7% false flags

On 60 photos of Montpellier smears without infection, the model flagged 1.7% of red cells as infected.

Where it fails

The worst calls on held-out patients the model never trained on. Each crop is one cell, with the model’s confidence that it is infected.

Need computer vision for your medical images?Discuss your project

What we learned

What this project taught us applies to most medical imaging work.

A research model is not yet a product that can inform a diagnosis: see what medical device software development takes. For the wider field, read our overview of AI in medical imaging.

Split by patient, not by photo

Each patient has five photos of the same smear. Split photos at random and the model learns to recognise the smear, and the numbers come out too good. All our tests hold out whole patients.

The reference makes mistakes too

Among the most confident false alarms are cells with a dot that looks like a parasite. The reference was labelled by one expert, so measured precision is capped by the reference itself.

Stain colour is the main source of misses

Colour augmentation in training (channel gain, contrast, blur) covered most of the difference between labs, but not the pinkest smears. In the French labs, false flags gather where platelets lie on a red cell and where the stain shifts the colour.

Check the data before the model

Three NIH annotation files carry a typo in the frame height (29888 instead of 2988). Folder names carry patient codes and photos carry EXIF data, so every image in the app is re-encoded and renamed.

Data and privacy

Open data still comes with conditions. We checked each licence at the source and published only what those terms allow.

Nothing leaves the browser

The models run in the tab. The photo is never uploaded to a server.

No patient codes, no metadata

Images are re-encoded without EXIF data and renamed, so no patient code reaches the page.

French images stay unpublished

The French dataset’s paper has no statement on patient consent, so we publish numbers from those labs and never their images.

Licences checked at the source

Both datasets are used under their published terms and credited the way each one asks.

Technology stack

Training in PyTorch on a laptop, inference in the browser through ONNX Runtime Web, with WebGPU first and WebAssembly as the fallback.

Model training

Python

Python

PyTorch

PyTorch

Apple Metal (MPS)

Apple Metal (MPS)

NumPy

NumPy

SciPy

SciPy

Pillow

Pillow

Export and inference

ONNX

ONNX

ONNX Runtime

ONNX Runtime

ONNX Runtime Web

ONNX Runtime Web

WebGPU

WebGPU

WebAssembly

WebAssembly

Web app

JavaScript

JavaScript

HTML5

HTML5

CSS

CSS

See how we build computer vision for healthcare productsExplore the service

Let’s talk about your product

Tell us where your product is today and what comes next. Our team will reply and suggest the next step.

Talk to our team

We're trusted by:

How does it work?
  • 1. Intro call
    During a 30-minute meeting, our domain expert dives into your business and describes the steps for future collaboration.
  • 2. Free discovery workshop
    Together with you, our technical team defines the user flow, feature list, and project risks.
  • 3. Project planning
    We provide the implementation plan, timelines and estimations for your project.
By clicking the button, I agree with the collection and processing of my personal data as described in the Privacy Policy
Our clients' success stories
Take a look at some of the projects we’ve delivered since 2011.
View all cases