Mughees Ul Haq

Work 03 / 18

Click a few plants, find the rest of the field

A tool for drone maps of farmland. You click 5 to 20 examples of a plant and it looks for every other one across the field. There is no training per field and no GPU.

For
An agriculture-technology partner in Europe
When
July to September 2026
My part
Research, engine design, benchmarking, the CPU app, data pipeline
Status
CPU app shipped. Backbone training designed, not yet run.
A public field photo. Clicking a plant highlights every patch with similar DINOv3 features.
A public field photo. Clicking a plant highlights every patch with similar DINOv3 features.
A public field photo. Clicking a plant highlights every patch with similar DINOv3 features.
A public field photo. Clicking a plant highlights every patch with similar DINOv3 features.
Try it. Click a plant in the photo and every patch whose DINOv3 features look like your clicks lights up. The features were computed once with the real backbone and reduced to 24 numbers per patch so they fit on this page; the matching runs in your browser. The app uses all 384 numbers and a small classifier, so it does better than this.

Photos: FARMERS GOV - Huerta del Valle - Community G… by USDAgov, Public domain; Lewis Taylor Farms seven months after Hurric… by USDAgov, Public domain; Erdmandelgras (Cyperus esculentus) in Möhren… by Schlaghecken Josef, CC BY 4.0; Bismarck Plant Materials Center - North Dako… by USDAgov, Public domain. What I changed.

Detection F1, pea seedlings
about 0.82
40 px targets
Detection F1, Poa weeds
about 0.73
24 px targets; with the 30× slower engine
Clicks needed
about 5
More clicks lowered F1
App size
about 140 MB
CPU only, GUI and command line

The problem

An orthomosaic of one field can be 28,000 × 37,000 pixels, with weeds 24 pixels wide. Training a detector per crop and per field costs a labelling cycle each time. The target machine is a laptop with no GPU.

How it works

A frozen feature model describes every patch of the map once. Your clicks become the training examples for a tiny classifier, which fits in under a second and then scores every patch.

There are two engines: a patch engine built on DINOv3 ViT-S (83 MB) for accuracy, and a dense engine built on a 1.4 MB ShuffleNetV2 for speed, which covers a 1,040-megapixel field in 1.5 to 2 minutes.

What I measured

Detection F1 is about 0.82 on pea seedlings (40-pixel targets) and about 0.73 on Poa weeds (24-pixel targets, 19 pixels apart).

Detection F1 on pea seedlings by number of clicks
5 clicks0.844
10 clicks0.836
20 clicks0.823
40 clicks0.799
80 clicks0.748

More clicks made the result worse. About five is enough.

  • Judge on detection F1, never on point AUC. Two configurations with AUC 0.906 and 0.903 scored F1 0.615 and 0.090.
  • About five clicks is enough, and more can hurt. On peas, F1 went from 0.844 with 5 clicks to 0.748 with 80.
  • The stride between patches should be about a third of the spacing between plants. That one rule predicted the result on all three datasets.

What failed

Compressing the features with PCA dropped AUC from 0.948 to 0.817. RepViT, a stronger ImageNet model, lost to the 1.4 MB ShuffleNetV2.

On the Poa weeds, the accurate engine at 4× scale gets F1 0.707 against the fast engine’s 0.607, and takes 119 seconds per crop against 3.9. That is 30 times slower for 0.10 of F1, and I report it that way.

Limits

The Poa labels are another detector’s predictions, which the client asked me to treat as ground truth, so that score is agreement with a model.

The plan to train a farm-specific backbone is designed and its data pipeline is built, but no backbone has been trained. In the one test I ran, a better backbone was worth +0.069 F1 where resolution was worth +0.455, and under a stricter protocol the backbone gain turned into −0.015.

From the run log

cd.01Judging on detection F1AUC 0.906 vs 0.903 gave F1 0.615 vs 0.090Finding

Setup: Detection F1 with greedy 1:1 matching against point-classification AUC

Two configurations almost tied on AUC and differed sevenfold on detection F1. AUC put configurations in the wrong order four separate times. After that, every decision in the project was gated on detection F1.

cd.02How many clicksF1 0.844 at 5 clicks, 0.748 at 80Finding

Setup: Pea field, 5 to 80 clicks

F1 by click count: 5 gave 0.844, 10 gave 0.836, 20 gave 0.823, 40 gave 0.799, 80 gave 0.748. About five clicks is the knee, and adding more made it worse.

cd.04The accurate engine at 4× on PoaF1 0.707 vs 0.607, 119.4 s vs 3.9 sFinding

Setup: Patch engine at 4× scale against the dense engine, 1536 × 1536 crop

On the small weeds the patch engine at 4× scale gains 0.10 F1 and takes 30 times as long. Both numbers go in the report together.

cd.07Dense engine backboneThe smaller model wonShipped

Setup: ShuffleNetV2 x0.5 (1.4 MB) against RepViT

RepViT is the stronger ImageNet model, at about 80% against 60%, and it lost. The 1.4 MB ShuffleNetV2 covers a 1,040-megapixel field in 1.5 to 2 minutes and is the dense engine in the app.

cd.08Would a better backbone help?+0.069 F1 against +0.455Finding

Setup: Backbone change against a resolution change

In the one test I ran, a better backbone was worth +0.069 F1 where resolution was worth +0.455. Under a stricter protocol the backbone gain became −0.015. No farm-specific backbone has been trained.

All 9 runs for this project

Tools

DINOv3 ViT-S/16, ShuffleNetV2 x0.5, ONNX Runtime.

DINOv3 is used under Meta’s DINOv3 licence.

The full write-up

There is a longer write-up of this project. It has client details in it, so email me if you’d like a redacted copy.