Timothy Malche / Pest Detector Public

Timothy Malche / Pest Detector

This project is a part of 'Pestroyer' which is an agriculture DRONE that detects pests and sprinkle pesticides to kill them.

Object detection

About this project

The Pest Detector


The project Pest Detector is an ML model which will be implemented in project Pestroyer. The project Pestroyer is an agriculture DRONE that detects harmful pests and sprinkle pesticides.


The Hardware

I have decided to use NXP HoverGames drone development kit and NXP NAvQPlus Edge compute board to build this project.

How it works?

Pestroyer has a camera module to detect pests and it carries pesticides as payload. The Pestroyer can be remote controlled to sprinkle pesticides if harmful pests are detected.

The main aim of this project is to detect different classes of pests and identify whether the pest is harmful for crops or not. As shown in following figure, Pestroyer capture video of the field and detects pests. If it finds the pest, it further checks whether it is harmful or not. If pest is harmful, it sprays the pesticides otherwise does nothing.


Whether the detected pests are harmful or not, the inferencing results can either be stored locally or published on cloud for researching and better understanding of the field.


Following are the main objectives of this project:

  • To monitor crops/agricultural field for harmful pests remotely/distant position.
  • To detect classes of pests and identify harmful pests.
  • To destroy harmful pest by sprinkling pesticides.

Why it is important?

Following are the reason for building this project:

  • When agricultural field span over large area, it is time consuming to visit whole area, inspect crop and sprinkle pesticides.
  • Unnecessary sprinkling of pesticides can either lead to unhealthy crop or destroy it.
  • Using multiple drones can save lot of time.
  • Inhaling pesticides by farmers can cause health issues, using this project it can be avoided by sprinkling pesticides from distant position.
  • Larger agricultural area can be inspected by choosing random area.
  • Unnecessary sprinkling of pesticides can be avoided by detecting the affected area and only harmful pests.
  • Crop can be monitored more efficiently and production can be increased.

Dataset Collection

I have searched images for following three classes of pests from the Internet and resize it to 640x640. Then the images are divided into training set and test set. Finally images are uploaded and labelled.

  • Beetle (Harmful Pest)
  • Grasshopper (Harmful Pest)
  • Ladybug (Not Harmful Pest)


Dataset can also be collected on real plants, and using drone. The idea is to collect and identify more and more classes of pests which is an ongoing research.

Blocks & Image settings

Following blocks are used:

  • Image
  • Object Detection

Image resolution used is 96x96 and resize mode is Squash.


The color depth chosen is RGB.


Model Settings & Performance

For NN the number of training cycles used are the 60 and learning rate is 0.01. After training the F1 score achieved is 90.4% as shown in following figure.


Live Classification

The live classification results shows that model is able to identify the pests for which it is trained.


Following is the result of live classification in video. Detected all three classes. (Click image below to watch the video)


I have also tested model in real conditions and find it working well. I tested it on a beetle found in my garden! The following video show live inferencing on real conditions.

live pest detector.png

Model Testing

When tested model on whole test dataset, I received 85.19% accuracy as there were 4 inaccurate results. As shown in following figure, the anomaly is not due to incorrect classification of pests class but it is because at on instance the model detected multiple objects and at one instance it skipped one object. It may be due to the imperfect image but the model is able to identify the objects correctly for which it is trained.



The Pestroyer project is very useful for farmers which helps them to continuously monitor the crops which can lead to increase in the crop production. It not only saves time for farmers but it is also good for their health as they do not have to sprinkle pesticide by carrying or remaining in close contact with the pesticides. The project may also be used by non-expert as it is easy to use and it can identify harmful pests and help farmers to decide whether to sprinkle pesticides or not. Avoiding unnecessary sprinkling of pesticides is not only good for crop health but also for the general users who use it as food. Larger area can be covered using this project and farmer can also choose to inspect random locations of the field. The future aspect is to build another ML model for crop health monitoring so that it will be easier for farmer to detect pests only in the area where crop health is unusual.

Creating your first impulse (100% complete)

Acquire data

Every Machine Learning project starts with data. You can capture data from a development board or your phone, or import data you already collected.

Design an impulse

Teach the model to interpret previously unseen data, based on historical data. Use this to categorize new data, or to find anomalies in sensor readings.


Package the complete impulse up, from signal processing code to trained model, and deploy it on your device. This ensures that the impulse runs with low latency and without requiring a network connection.

Download block output

Title Type Size
Image training data NPY file 126 windows
Image training labels JSON file 126 windows
Image testing data NPY file 27 windows
Image testing labels JSON file 27 windows
Object detection model TensorFlow Lite (float32) 83 KB
Object detection model TensorFlow Lite (int8 quantized) 56 KB
Object detection model TensorFlow SavedModel 187 KB
Object detection model Keras h5 model 90 KB

Clone project

You are viewing a public Edge Impulse project. Clone this project to add data or make changes.


Data collected
153 items

Project info

Project ID 117819
Project version 3
License No license attached