Intermediate level · Module 8: Transfer Learning · Lesson 2 of 3
Domain Shift and Adapting to Local Images
Learners measure how a model trained on public images performs on local photographs, and test strategies to close the gap: local fine-tuning data, augmentation and capture rules.
In this lesson you will
- Measure domain shift between public and local data
- Test strategies to reduce it
Key concepts
domain shiftlocal fine-tuning setmixed training datacapture protocolsper-source evaluation
The lesson
Public plant and object datasets are often photographed in different places, with different varieties, cameras and backgrounds from local images. For example, a public leaf-disease image set published on Mendeley Data (CC0 1.0) is a useful starting point, but its photos differ from field photos taken with local phones.
Always report accuracy separately for public and local test images. Then test fixes: add a small number of labelled local images to training, use augmentations that mimic local conditions, and improve capture rules.
Even a few dozen local images per class can help substantially, but the local test set must stay separate and untouched.
Step by step
- Evaluate the transfer-learning model on public and local test sets separately.
- Fine-tune again with 20–30 local images per class added to training.
- Re-evaluate on the untouched local test set.
- Report the change and the remaining errors.
A leaf-disease classifier meets field photos
A composite, illustrative case: a model that scored highly on a public leaf image set struggled on phone photos from local farms until local data and capture rules were added.
Context
A fictional agricultural training centre fine-tuned a small pretrained CNN on a public leaf-disease image set to help extension officers screen tomato leaves. Most public images showed single leaves on plain backgrounds, photographed in good light.
Challenge
On the public test images the model performed very well, but on photos taken by officers in local fields, with soil, other plants, shadows and older phones, it often gave confident wrong answers. Grad-CAM heatmaps showed it sometimes focusing on the background.
What they did
- Built a separate local test set of field photos labelled by an experienced officer and kept it untouched for evaluation.
- Reported accuracy for public and local test images separately, instead of one combined figure.
- Wrote capture rules (one leaf filling most of the frame, shade not direct sun, a plain card behind the leaf when possible) and trained officers in them.
- Added a small number of labelled local photos per class to training, with augmentations for lighting and blur.
- Added an 'uncertain, ask an expert' result for low-confidence predictions.
Results
- Local accuracy improved substantially and was reported alongside public accuracy, so officers knew how far to trust the tool.
- Uncertain cases went to an expert, and the centre began collecting consented local photos to extend the test set each season.
Lessons for your own work
- High accuracy on public data says little about performance in local conditions; measure it separately.
- Capture rules and a little local data often help more than a bigger model.
- A screening tool supports an expert's decision; it should say when it is unsure.
Practice activity
Run a domain-shift experiment and write a recommendation for local deployment.
Expected result: Measured public and local accuracy before and after adding local data, with an honest recommendation.
Check your understanding
-
Why must the local test set stay untouched?
Show answer
To measure real performance on local images fairly.
-
Name two ways to reduce domain shift.
Show answer
For example adding local training images, task-specific augmentation or better capture rules.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.