Developing AI to Identify British Earthworms from Photographs
Can artificial intelligence identify British earthworms from photographs? This proof-of-concept study was delivered by the UK Centre for Ecology and Hydrology and Biological Recording Company with guidance from the Earthworm Society of Britain, Department for Environment, Food and Rural Affairs (Defra) and the Joint Nature Conservation Committee as part of the Natural Capital and Ecosystem Assessment (NCEA) programme. The NCEA is undertaking a nationwide survey of England’s land, coast and sea with the aim of transforming environmental decision-making by building a ‘whole system’ picture of the state of our natural environment


The project investigated whether machine learning and computer vision could be used to identify live British earthworms from smartphone photographs. By combining ecological field surveys, volunteer engagement and artificial intelligence, the project produced one of the UK’s largest verified image libraries of live earthworms and provided valuable insights into the future potential of AI-assisted species identification.
The Challenge
Earthworms play a vital role in healthy soils, nutrient cycling and ecosystem functioning, yet they remain one of the least recorded groups of animals in Britain. Unlike many plants and insects, most earthworm species cannot currently be identified confidently from photographs alone. Identification usually requires microscopic examination of preserved specimens by experienced specialists.
This presents a major barrier to large-scale monitoring and citizen science. If artificial intelligence could reliably identify earthworms from smartphone photographs, it could transform earthworm recording by making surveys faster, more accessible and easier to undertake.
The Earthworm Image Recognition Project set out to test whether this was possible.
Our Approach
To create an AI model capable of recognising earthworms, we first needed a substantial library of accurately identified photographs.
Working alongside our project partners, we designed and delivered a nationwide programme of Earthworm Sampling Days. Volunteers collected live earthworms using standardised methods before photographing each specimen from multiple angles. Every earthworm was then preserved and identified by specialists to provide a verified identification for the image dataset.

This ensured that every photograph used for machine learning was linked to a confirmed species identification.
Across the project, we collected:
- 12,179 verified photographs
- 650 individual earthworms
- 21 British species
- 295 new biological records submitted to the National Earthworm Recording Scheme

The resulting dataset is a substantial collection of verified images of live British earthworms.
The following presentation explores the field aspect of the project
Developing the Classification Model
Using the verified image library, UKCEH developed a proof-of-concept machine learning model to investigate whether artificial intelligence could distinguish between British earthworm species.
The images were divided into training, validation and testing sets, and the algorithm underwent 34 epochs (training steps) until it no longer showed signs of improvement, reaching an overall accuracy of 42%. The confusion matrix below illustrates how the accuracy of the algorithm to correctly identify individual species was significantly variable and ranged from 0% to 69% depending on the species. A perfect algorithm would display a strong diagonal band, and significant values away from this diagonal band indicate common misclassification. Looking at the significant misclassifications helped us to recommend a number of improvements to the image collection protocol and algorithm development that can be implemented to improve the performance of the model.

We also established issues with the algorithm using the whole image (rather than just the area with the earthworm) for species classification and recommendations were made for reducing or eliminating this issue.
The following presentation explores the algorithm development aspect of the project
Project Outcomes
The project successfully demonstrated that artificial intelligence has genuine potential to support future earthworm identification, although further development is still required before it can be used reliably in the field.
The project showed that:
- It is possible to recruit volunteers to collect a large number of images of earthworms using a detailed protocol.
- These images can be used as a training dataset by combining collection with laboratory identification.
- The collection protocol should be refined to avoid the over-handling of specimens, keep the collection tray clean and avoid strong shadows.
- The image set is strongly biased towards common species and more sampling effort will be required to balance the existing library.
- Using a segmentation algorithm to mask out the earthworms prior to classification may improve the performance of the algorithm.
- Species that bare proving too difficult for the algorithm to classify should be grouped into aggregates to improve the overall results.
- Computer vision models show some promise but more development is needed for a usable solution.
Read the full report
Wider Impact
Beyond the development of the image recognition algorithm, the project delivered important wider benefits.
Hundreds of new earthworm records were added to the National Earthworm Recording Scheme, improving our understanding of species distributions across Britain. The project also demonstrated how citizen science, specialist verification and modern technologies can be combined to tackle ecological challenges.

The image library created through the project represents a valuable legacy resource that can support future research into artificial intelligence, species identification, and soil biodiversity monitoring.
Acknowledgements
We’d like to say thank you to Defra and JNCC for sitting on a steering group for the project and to all the organisations that helped us to deliver this programme of events.

We’d also like to say a huge thank you to all of the volunteers who contributed to the sampling, photography and identification of earthworm specimens.
Need an earthworm survey?
Earthworm surveys provide a powerful way to assess soil health, establish ecological baselines and monitor the success of habitat restoration, regenerative agriculture and land management projects.
If you’re an environmental, conservation, ecological, or agricultural professional looking to commission an earthworm survey, visit our Earthworm Consultancy, Surveys and Training page to learn more about the specialist surveys and consultancy we offer.

3 thoughts on “Earthworm Image Recognition Project”