Object Recognition through Machine Learning in Beekeeping. Part 1
Machine Learning has been taking its place in our daily lives step by step. With the help of neural networks, many problems have already been solved: from sorting cucumbers on farms to data analysis essential for autonomous driving. The SoftTeco team decided to explore this technology and find the possibility of applying it in one particular area – beekeeping.
Our team decided to create an application that will analyze and provide the user with information about hive conditions and the bees’ life level. There is a weekly procedure for a beekeeper to inspect bee families in their hives. This procedure is done in the following way: a beekeeper opens the hive, takes out the frames (containing honeycombs and bees) and does an inspection of each frame. There are about 10 to 20 frames in each hive, and each frame hosts around 1,000-2,000 bees.
A beekeeper has to be capable of taking note of a large amount of information in a short period of time; in particular, the following data:
– number of bees in the hive,
– queen bee’s state of health and life level, and
– presence of immature bees (brood) in the hive.
While creating the architecture of the system, we were focused on making processes as simple as possible. The Android platform was chosen as the main stage for the work, and we designed it in a simple and clean way. Photo/video stream processing goes through the neural network model on the server. The counting of selected areas is carried out automatically. Analytical information is stored in the cloud where the user can interact with it, particularly if he provides photos and video materials for neural network depth training in the detection and labeling of bees.
System architecture for image processing and analysis
Neural network model
Before building the model, we identified two tasks that our neural network would solve:
- Object detection
When preparing for the solution of the above-mentioned problems, we had no idea what dataset would be necessary to train. The choice of concrete images numbered in dataset is a task that requires the analysis of a classified object. To handle this, we divided the images into two groups: 400 images of bees and 100 validation images, which included other types of objects. The total dataset contains 500 images.
An environment is the second aspect which helps to solve the classification problem. For model training, we used Google Colab, which in turn has a possibility of learning on the GPU. For learning, we used the Python library – PyTorch. The convolutional neural network consisted of 36 layers. At the entry, an image of 256×256 pixels was fed, and as the output we received a binary classifier with the options “bee” or “not_a_bee.”
Epoch – one iteration in the learning process. It includes the presentation of all training data examples and the quality training test made with test dataset. The duration of training was 11 epochs, (603 seconds). Each era stood for 50 seconds on average.
The result was better than we expected! The trial dataset allowed the neural network to recognize the bee in the image. Based on the test sample, the classification result was 100%, and the sample in the “Not_a_Bee” class was 94% (there was a 6% deviation due to the lack of an adequate number of bumblebees in the training sample). The graphs below show the data obtained:
The image with the fly shows that our neural network is working correctly and can classify with excellent probability. This example shows that when properly set up, the neural network can distinguish two very similar in its parameters object, which are in the same class – insects.
An image containing a crowd of many bees was defined as a “Bee.” That was one of our goals – for the neural network to recognize a crowd of bees. This experiment is ongoing, and we plan to achieve accurate object detection in the next iteration.