A vision model that passes its tests is not a model that works in the field. The difference comes down to one word: robustness, meaning the ability to keep performing when conditions change. In farming, everything changes. Seasons alter the light, the crop stage and the look of the foliage. Soils alter the background of the image, the colour of surfaces and the presence of residues. Regions alter varieties, sowing densities, practices and sensors. A project in computer vision in agriculture that does not face this variability head on produces a model that shines in the laboratory and disappoints at the customer.
This article describes what “changing domain” means in an agricultural context, the three kinds of drift to watch, how to measure robustness with worked numbers, and the role of annotation in the strategy. It extends the review of the uses of computer vision in agriculture and prepares the question that always comes next, the cost of a computer vision project in agriculture, since robustness is one of its first cost items.
Why robustness decides the fate of a project in computer vision in agriculture
Most industrial vision applications operate in a controlled environment: fixed lighting, a fixed camera, a product presented the same way each time. Farming is the opposite. The camera is outdoors, the light changes every minute, the crop evolves every week, and the background of the image is a soil that does not have the same colour from one plot to the next.
In these conditions, 95 percent accuracy on a test set means nothing by itself. It only says that the model can handle images that resemble those it was trained on. The useful question lies elsewhere: what accuracy is obtained on images that do not resemble them? The founding work on leaf disease diagnosis illustrates the problem bluntly: 99.35 percent on a test set drawn from the same corpus as the training data, 31.4 percent on images from external sources taken under other conditions (Mohanty et al., 2016).
A project in computer vision in agriculture must therefore be designed for variability, not against it. This is decided at scoping, when the conditions to cover are defined, and it is paid for at every later stage: collection, annotation, validation, monitoring. The longer the question is postponed, the more costly the correction.
What “changing domain” means in the field
Specialists speak of domain shift, or drift, when the data met in operation no longer follow the same distribution as the training data. The model has not become poor: the world has changed around it.
In farming, three combined factors produce these changes. The first is time: season, growth stage, time of day, weather. The second is place: soil, terrain, climate, region. The third is the set up: sensor, shooting height, angle, resolution, platform, whether an unmanned aircraft, a tractor or a phone.
These factors combine. A model trained on wheat at heading stage, in spring, in northern Europe, with a camera two metres above the crop, will one day meet ripening wheat, in summer, in another country, photographed from an aircraft. In a project in computer vision in agriculture, each isolated change is manageable, but their combination moves the model away from its learning ground much faster than one imagines.
Seasonal drift: stage, light, calendar
Time is the first factor of variability. A plant does not look the same at sowing, at stem elongation, at flowering and at maturity: shape, colour, size, texture, share of visible soil. A model trained on one stage has no reason to work well on another.
The wheat literature gives an illustration. The authors of the wheat head counting dataset note that detection models may be sensitive to the developmental stage, and that during ripening heads bend and overlap, which makes labelling more erratic (David et al., 2021). The stage therefore affects both what the model sees and the reliability of the labels used to evaluate it.
Light adds its own drift. The same field photographed at nine in the morning, at noon and at six in the evening does not give the same shadows, reflections or contrasts. An overcast sky removes cast shadows but flattens colours. A backlit shot creates halos that hide details.
Finally, the calendar itself imposes a constraint: a stage can be collected only once a year. A stage missed at collection is a stage absent from training for a whole year. For a model in computer vision in agriculture, planning image campaigns is therefore a lever of robustness, just like the choice of model architecture.
Soils and farming systems in computer vision in agriculture
The soil is the background of the image. Its colour, moisture and texture, and the presence of straw, stones or residues of the previous crop vary from one plot to another and from one day to the next. A dark soil after rain and a pale soil after three weeks of drought do not look alike, and the model may learn to rely on this background rather than on the plant.
This risk is not theoretical. A study of the PlantVillage dataset showed that a classifier trained on only eight background pixels per image reached 49.0 percent accuracy on 38 classes, against 2.6 percent for chance. The model therefore also learns the signature of the background and of the capture, not only the target object. In a field, where the background changes, this habit is paid for immediately.
The farming system matters as much as the soil. Row sowing does not look like broadcast sowing. An irrigated crop does not look like a rainfed crop. A cover crop, a mulch, an intercrop or reduced tillage change what surrounds the target plant. For a project in computer vision in agriculture aimed at several farms, the diversity of practices is a parameter to document and cover, just like the diversity of varieties.
Geographies: varieties, densities, sensors
Geographic drift combines several effects. Varieties differ from one region to another, with different habits, colours and cycles. Sowing densities and row spacing vary. Protection, fertilisation and harvest practices change the look of the plot. Climate changes the light, the dust in suspension and the humidity of the air.
Sensors add a drift of their own. Two different cameras photographing the same scene do not produce the same colours, the same sharpness or the same noise. A different flight height changes the apparent size of objects. The authors of the wheat head dataset define their domains, or sub-datasets, as sets of images acquired on the same experimental unit, with the same session, the same platform and the same sensor: two sites in the same place but with different sensors form two distinct domains.
A less visible but very real effect concerns the culture of operators: how an image is framed, the altitude chosen, the time of day at which one flies. These habits are specific to each team, and they appear in the data as systematic biases.
For teams working in computer vision in agriculture, the practical consequence is to treat every new region as a new domain until it has been measured otherwise. A model validated in one country is a hypothesis, not a guarantee, for the next.
What datasets built for diversity show
The Global Wheat Head Detection dataset is an interesting laboratory, because it was built explicitly to test robustness. In its 2021 version, it brings together images from 12 countries and 16 institutions, organised in 47 sub-datasets according to the summary table of the paper (David et al., 2021).
The split of the associated challenge is instructive. The training set has 3,657 images from 18 sub-datasets, all European. The evaluation and test sets, with 1,476 and 1,373 images, come from sub-datasets in Africa, Asia and North America. In other words, the model is trained in one geography and judged in another. This rule of the game reproduces the real situation of a deployed product: it has to generalise to conditions it has not seen.
The authors also found that the initial test set was biased relative to training, using an analysis of the space of visual features, and that the 2021 additions were spread more evenly. They finally designed a metric, the weighted domain accuracy, so that the largest sub-datasets would not dominate the evaluation. This precaution deserves to be remembered: an average over images mechanically favours the best represented domains.
Measuring the robustness of a model in computer vision in agriculture
Measuring robustness means evaluating the model on conditions it did not see during training, and reporting the result condition by condition.
The most telling method is leave one domain out evaluation: train the model on every site except one, test it on the excluded site, then repeat in rotation. With five sites, that makes five training runs and five measurements of generalisation. The gap between the average accuracy on seen sites and that on the excluded site gives the measure of fragility.
A second method is stratified evaluation: split the test set by season, soil type, region and sensor, and report results by stratum. A global average hides weak strata, yet these are the ones that will cause complaints.
A third, simpler method is to build a small, deliberately difficult test set that gathers borderline conditions: late afternoon, backlight, wet soil, transition stages. A model that succeeds on this set has a good chance of succeeding elsewhere, and a model that fails offers a clear roadmap for the next collection.
Whatever the method, the rule is the same in computer vision in agriculture: the conditions used for judging must be kept separate from the conditions used for learning.
Worked example: an average that hides what matters
An illustrative example shows why stratification is needed. Suppose a model is evaluated on a test set in which 60 percent of images come from conditions close to training, with 95 percent accuracy, and 40 percent from distant conditions, with 60 percent accuracy. Global accuracy is 0.6 × 0.95 + 0.4 × 0.60, or 81 percent. That figure is neither catastrophic nor satisfying, and it hides the fact that in two cases out of five the model is wrong four times out of ten.
The weighting trap shows better with three domains. Site A has 3,000 images with 95 percent accuracy, site B 300 images with 70 percent, site C 200 images with 55 percent. Weighted by number of images, accuracy is (2,850 + 210 + 110) / 3,500, or 90.6 percent. Averaged by domain, it is (95 + 70 + 55) / 3, or 73.3 percent. That is more than seventeen points between two readings of the same result. The first reassures, the second warns. A domain weighted metric, like the one the wheat dataset authors defined, gives each condition the same weight, whatever its share in the data.
The honest reading is to give both figures, then detail by stratum. A client who operates three sites does not care about the average over images: they care about what happens on each of theirs.
How many images per stratum to conclude
A stratified evaluation raises a question of volume. How many images does each stratum need for the measurement to be meaningful?
With an expected accuracy of 90 percent and a desired precision of ± 5 points at 95 percent confidence, about 139 images per stratum are needed. For 12 strata, for example three seasons, two soil types and two regions, that makes 1,668 test images, independent of training. If each image contains on average 20 objects to outline, annotating this test set represents 33,360 objects. The figure is modest on the scale of a training set, but it requires annotation of particular care, because this set acts as the judge. A test set built this way is the backbone of any evaluation in computer vision in agriculture, and it should be frozen before any tuning begins.
This order of magnitude also points to a trade off. Doubling the number of strata doubles the test set, while the gain in information is uneven. It is better to choose the strata that carry the most risk, those that are both frequent in operation and far from training, than to cover uniformly a space of conditions that is not yet known.
The role of annotation in a robustness strategy for computer vision in agriculture
Annotation intervenes at four levels in a robustness approach.
The first is consistency across sites and seasons. If two teams apply different guidelines to images from different seasons, the model learns an inconsistency and mistakes it for a phenomenon. Guidelines must be unique, versioned, illustrated with examples of each condition, and applied in the same way by everyone.
The second is the tagging of conditions. Each image benefits from carrying metadata: season or date, stage, soil type, region, sensor, time, weather. This information enables stratified evaluation and failure analysis. It can be captured partly automatically and partly by hand, notably for visual attributes such as soil state or cloud cover.
The third is handling difficult cases. Occlusions, backlight, transition stages, ambiguous symptoms: these cases are rare in naive sampling, but they concentrate the errors. Annotating them with particular care, and over representing them in the training or test set, improves robustness far more than adding thousands of easy images.
The fourth is re-annotation. When one discovers that a class was poorly defined or that the test set was biased, as in the wheat dataset story, it must be possible to take the images back and apply new guidelines in a traceable way.
Infoscribe AI works on these stages, with fully manual annotation, structured quality control and an annotation tool hosted on its own infrastructure, within an ISO 27001:2022 certified approach. Its annotation service for agriculture relies on agronomic supervision for the definition of classes and the validation of ambiguous cases, which ensures the consistency of labels from one campaign to the next.
Augmentation, domain adaptation, targeted collection: what to choose
Three broad families of techniques seek to improve robustness, with uneven effectiveness.
Data augmentation consists of artificially modifying images: brightness, contrast, rotation, blur, noise. It helps manage variations in light and viewpoint, but it does not create a new stage, a new variety or a new soil. Work on more elaborate augmentation methods recalls that plant diagnosis applications often suffer from overfitting and that their performance drops on test sets from new environments. Augmentation attenuates the problem but does not remove it.
Domain adaptation consists of adjusting an already trained model to a new domain, with few or no labels in it. It is promising and prone to failure when the gap is large. Its practical value depends on a small annotated set in the target domain, if only to check that the adaptation worked.
Targeted collection is the simplest and most effective: go and get images in the missing conditions, and annotate them. It is also the slowest, because it depends on the agronomic calendar. For a project in computer vision in agriculture, the best strategy combines all three: a collection planned over several seasons, reasoned augmentation and, when the gap remains too large, an adaptation checked on a target set.
Monitoring a model after deployment in computer vision in agriculture
Robustness does not end at delivery. A crop changes variety, a sensor is replaced, a practice evolves, and the model degrades without anyone noticing. Monitoring in operation is the only way to detect it.
The set up is simple: regularly sample a small set of images, have them annotated, and compare the result with the predictions. With 50 images per week and 90 percent accuracy, the standard error is about 4.2 points. A real drop of 10 points, from 90 to 80 percent, is 2.4 times that standard error: detectable over a few cumulated weeks, but hard to spot in a single sample. Over 26 weeks, the cumulated sample reaches 1,300 images, which makes it possible to follow changes by stratum.
This monitoring feeds a retraining cycle: badly predicted images, once annotated, enrich the training set, and new conditions are added to the test set. A project that plans this loop from the start ages better than one that delivers a frozen model.
Frequent mistakes in robustness for computer vision in agriculture
- Validating the model on images from the same sites, dates and sensors as the training data.
- Reporting a global average without detailing it by season, soil, region and sensor.
- Weighting the evaluation by number of images, at the expense of poorly represented conditions.
- Training on a single season and deploying all year round.
- Letting the image background, soil or mulch, become a clue the model exploits.
- Mixing datasets annotated with different guidelines depending on sites or campaigns.
- Not recording the metadata that make it possible to stratify the evaluation.
- Counting on data augmentation to replace collection in missing conditions.
- Using the test set to tune the model until it is no longer independent.
- Delivering a model without a monitoring set up or a retraining plan.
Key takeaways
In farming, conditions change with time, place and shooting set up, and these changes combine. A model that succeeds on its test set can fail in the field: 99.35 percent against 31.4 percent in the founding study on leaf diseases, 49.0 percent with only eight background pixels in the study on PlantVillage bias. Robustness is therefore measured on conditions the model has not seen.
Measurement relies on leave one domain out evaluation, stratified evaluation and a deliberately difficult test set. A global average hides what matters: 81 percent overall for 95 percent in close conditions and 60 percent in distant ones, 90.6 percent weighted by image against 73.3 percent averaged by domain. About 139 images per stratum are enough for a precision of ± 5 points.
A robust project in computer vision in agriculture combines collection planned over several seasons, unique and versioned annotation guidelines, condition metadata, attention to difficult cases and monitoring after deployment. The cost of a computer vision project in agriculture depends directly on it, and the overview of the discipline places these questions within the full range of uses.
To assess the diversity of conditions covered by your current images and define a stratified test set, describe your project to the team.
References: Mohanty, Hughes, Salathé, 2016, deep learning for image based diagnosis of plant diseases (arXiv:1604.03169); Uncovering bias in the PlantVillage dataset, 2022 (arXiv:2206.04374); David et al., 2021, Global Wheat Head Detection 2021 (arXiv:2105.07660); LeafGAN, 2020 (arXiv:2002.10100). The numerical examples on weighting, sampling and monitoring are illustrative.