Cereal fungal diseases detection using autoencoders

According to the data of the Food and Agriculture Organization of the United Nations (FAO), diseases and pests destroy 20-40% of the world’s agricultural crops. At the same time, fungal diseases cause enormous economic damage. Farmers suffer significant financial losses every year due to fungal diseases. It is very important accurately and at an early stage to identify the symptoms of the disease in order to take the necessary measures to combat it in a timely manner. Symptoms of fungal diseases often appear in the form of spots around the infected areas, so the initial detection of the disease is reduced to the analysis of these spots. At present, farmers mainly rely on their own experience, disease-identifying atlases or involve expert agronomists. However, the identification is complicated by the fact that different diseases can have similar types of spots and vice versa, the same disease can manifest itself differently in different crops varieties and depending on growing conditions. This research shows that modern neural network approaches can be used instead of conventional colour and brightness filters to detect fungal infections in cereal crops. In particular, the use of autoencoders can significantly simplify the task of automatically detecting diseased areas. The authors prove that after complementing the pipeline of image processing using filters, usual for such tasks, with a neural network autoencoder, in some cases it is possible to explicitly highlight the affected area.


Introduction
The possibility of automatic localization of the sites of rice infestation by fungal diseases using modern methods of computer vision is being investigated.
A new approach based on the use of autoencoders -special neural network architectures that allows detecting areas on rice leaves affected by a particular disease -is considered.
It is shown that the autoencoder can be trained in such a way that it will remove the affected areas from the image, which in some cases makes it possible to clearly highlight the affected area by comparing the resulting image with the original one. At the same time, modern architectures of convolutional autoencoders provide quite acceptable visual quality of detection.
Fungal diseases cause significant economic losses for farmers every year. In order to take timely measures to combat them, it is very important that the symptoms of the disease are detected accurately and at an early stage. Symptoms of fungal diseases often appear in the form of spots around the infected areas, therefore, the initial detection of the disease is reduced to the analysis of these spots. At present, farmers mainly rely on their own experience, disease-identifying atlases, or involve expert agronomists [2].

Materials and methods
The idea behind autoencoders is as follows: some image is fed to the input of the network, which is compressed by the first network -encoder into a vector of dimensions smaller than the size of the original image, giving it a dense representation. Further, this vector is fed to the input of the second network -decoder, which tries to decode it back into the original image. Thus, at the output, the original image is compared with itself.
If the original image is similar enough to the output, this has a number of advantages at once. First, it gives a kind of compression effect: if we are ready to neglect some loss of image quality, then we can easily replace the image with its dense representation -the vector that gives the encoder a part of the network at the output. Indeed, in this case, it is quite easy to restore (with some accuracy) the original image by feeding it dense to the decoder input of the neural network autoencoder part.
Secondly, it is possible to extract in coded form useful features that fully or partially characterize our image. In this case, we talk about data projections -the presentation of original images in a space of a lower dimension without significant loss of information reflected on them.
If we are not faced with the task of directly interpreting these vectors of lower dimension, then they may well be used further in other models, for example, predicting a specific type of disease affecting a plant, or the size of a lesion focus.
Third, autoencoders are often used to smooth out image noise. Due to its specificity, the autoencoder memorizes in a dense representation of each image submitted to it at the input of its most essential features, and noise is usually ignored.

Results and discussion
It is the last feature of autoencoders that gives the main result of this work. The autoencoder can be trained in such a way that it will remove the lesions of the disease from the original image.
Thus, comparing the image at the output of the model with that supplied to the input, in a number of cases it is possible to quite clearly automatically localize the lesion of the plant with a fungal disease.
In this work, we use a dataset to train our models [3]. It contains about 3500 photos of both healthy rice leaves and those affected by three types of diseases -hispa, brown spot, leaf blast.
The images in the dataset are of sufficient quality for the use of computer vision, are practically free of extraneous noise and other shooting defects.
In the study, we are not interested in the classification of plants by types of diseases, types, but in the presence or absence of such a disease in general. Such a task is easier, since it is not necessary to additionally train the neural network to distinguish plant diseases among themselves. However, it is solved here together with the task of determining the most affected area, which is already much more difficult. What may be obvious to a specialist phytopalologist may turn out to be a complex task for a computer.
As mentioned above, autoencoders have a number of interesting features that distinguish them from other neural networks. So, they allow by compressing the data obtained from the image to eliminate trifles that are insignificant for this dataset.
Moreover, if the lesion on the sheet is not too large, the autoencoder can, after learning, "erase it" from the original image. After comparing the original image with the obtained one, it is quite easy to clearly highlight the affected area.
It is noteworthy that the described image processing scheme is possible (and even preferable) precisely at the early stages of the development of the disease, which increases the value and potential benefit of the proposed approach.  (3, 16, 8x8) Here conv2d (i, o, wxw) is a convolutional layer with kernel size w x w, which accepts a block of data of depth i as input and outputs a block of depth o; conv_t2d is a symmetric convolutional layer giving the inverse operations to conv2d.
Between all convolutional blocks are blocks with the ReLU activation function, usually used in image analysis tasks. The number of parameters of such a model was 18.4 M.
To increase the generalizing ability of the model, augmentations were applied to the input datavarious distortions and transformations such as rotations by small angles, reflections around the coordinate axes and adding a little noise.
This increased both the overall quality of the model and its confidence in its predictions.

Conclusions
The model training process and the final model pipeline are shown in Fig. 1. It took about 120 epochs for the quality of the model to reach its maximum level. After training the model, the results it produced were subtracted from the original ones, and then they underwent additional post-processing -the imposition of filters by colors and brightness to more clearly highlight the area of plant disease. We identified the most optimal thresholds for color channels to identify the affected areas: |red -0.14| < 0.1, |green -0.29| < 0.1, blue < 0.08. The above-described image processing scheme made it possible, in a number of cases, to clearly segment the image with a diseased plant, highlighting the areas of disease affection on it. Figure 2 shows a typical example of brown spot rice, as well as the result of processing it with our algorithm. It can be seen that the inclusion of a neural network autoencoder, along with conventional filters in the image processing pipeline, makes it possible to clearly and clearly highlight the area of plant damage by a harmful fungus (Fig. 2). According to our estimates, the proposed model makes it possible to clearly and automatically visualize diseased areas on rice leaves in 40-50% of cases, which can be considered a fairly good result. Moreover, the described method is perfect in the early stages of infection, when the affected areas are still small.
In this case, the autoencoder removes them from the image most accurately, taking them for insignificant noise, thereby increasing the quality of the selection of these areas after subtracting the resulting image from the original.
Thus, the method turns out to be quite working in the most important case of applications for the detection of plant diseases at the early stage of vegetation.
It is shown in this work that more modern approaches based on neural networks can be used instead of conventional color and brightness filters to detect the sites of rice infestation by fungal diseases. In particular, the use of autoencoders can significantly simplify the task of automatically detecting diseased areas.
It is shown that after complementing the pipeline of image processing, which is usual for such tasks, with the help of filters with a neural network autoencoder, in a number of cases, it is possible to achieve an explicit selection of the affected area.