Literature DB >> 36217500

A CNN-based image detector for plant leaf diseases classification.

Laura Falaschetti1, Lorenzo Manoni1, Denis Di Leo1, Danilo Pau2, Valeria Tomaselli3, Claudio Turchetti1.   

Abstract

Identifying diseases from images of plant leaves is one of the most important research areas in precision agriculture. The aim of this paper is to propose an image detector embedding a resource constrained convolutional neural network (CNN) implemented in a low cost, low power platform, named OpenMV Cam H7 Plus, to perform a real-time classification of plant disease. The CNN network so obtained has been trained on two specific datasets for plant diseases detection, the ESCA-dataset and the PlantVillage-augmented dataset, and implemented in a low-power, low-cost Python programmable machine vision camera for real-time image acquisition and classification, equipped with a LCD display showing to the user the classification response in real-time. Experimental results show that this CNN-based image detector can be effectively implemented on the chosen constrained-resource system, achieving an accuracy of about 98.10%/95.24% with a very low memory cost (718.961 KB/735.727 KB) and inference time (122.969 ms/125.630 ms) tested on board for the ESCA and the PlantVillage-augmented datasets respectively, allowing the design of a portable embedded system for plant leaf diseases classification. Source files are available at https://doi.org/10.17605/OSF.IO/UCM8D.
© 2022 The Authors.

Entities:  

Keywords:  Esca disease; Image detector; convolutional neural network; embedded systems; plant diseases recognition

Year:  2022        PMID: 36217500      PMCID: PMC9547307          DOI: 10.1016/j.ohx.2022.e00363

Source DB:  PubMed          Journal:  HardwareX        ISSN: 2468-0672


Specifications table

Hardware in context

Identifying diseases from images of plant leaves is one of the most important research areas in precision agriculture [1]. Several artificial intelligence approaches are currently used for detecting and classifying plant diseases. The most common approaches are the k-nearest neighbours (kNN), logistic regression, decision tree, support vector machine (SVM) [2]. Recently, deep neural networks (DNNs) and specifically convolutional neural networks (CNNs) have proven to be extremely effective to solve this task [3]. These approaches are combined with various image pre-processing methods in order to enhance feature extraction. In the context of precision agriculture, the availability of a low-cost, low-power, portable, easy-to-use vision system incorporating deep learning techniques, which could be combined with autonomous agricultural vehicles, plays a great role since it would offer the agronomist a valuable assistance for the plant disease detection and diagnosis. Such devices could be drones and other autonomous agricultural vehicles, equipped with an embedded vision system, to be used by growers or agronomists for real-time monitoring and dynamic disease detection on large-scale open-field cultivations. The realization of a low-cost, low-power, portable, easy-to-use intelligent vision system leads to several challenges: th ction of computational complexity and memory occupation so that the DNN can be integrated directly into the vision system, i.e. an embedded device based on a microcontroller with limited computational power and very low energy consumption, together with the reduction of inference time in order to realize a real-time application, by preserving the performance in terms of accuracy. Table 1 reports a summary of the state-of-the-art CNN models for plant diseases identification based on image classification.
Table 1

Summary of the state-of-the-art CNNs for plant diseases detection.

AuthorMethodsDatasetClassesAccuracyParametersImplementation on embedded system
Mohanty et al. [4]AlexNet [5] and GoogleNet [6]PlantVillage [7]3899.27%, 99.34%AlexNet: 60 million GoogleNet: 5 million
Ramcharan et al. [8]Inception V3 [9] based on GoogleNetCassava dataset [10]693%Inception V3: 27 million
Fuentes et al. [11]Faster R-CNN [12], R-FCN [13], SSD [14] combined with VGG-16 [15] and ResNet [16]custom Tomato Diseases and Pests Dataset 5000 images983%Faster R-CNN with VGG: 2.4 million
Pawara et al. [17]AlexNet [5] and GoogleNet [6]AgriPlant Dataset [18]1096.37%, 98.33%AlexNet: 60 millionGoogleNet: 5 million
LeafSnap Dataset [19]18489.51%, 97.66%
Folio Dataset[20]3297.67%, 97.63%
Ferentinos et al. [21]AlexNetOWTBn [22] and VGG [15]custom dataset 87848 images5899.49%, 99.53%AlexNetOWTBn: 60 million VGG: 138 million
Ramacharan el al. [23]MobileNet [24] - SSD [14]Cassava dataset [10]680.6% on images 70.4% on videoMobileNet-SSD: 6 million✓Samsung Galaxy S5 Android device
Geetharamani et al. [25]CNNPlantVillage with data augmentation [26]3996.46%212,543
Chen et al. [27]VGG-19 pre-trained on ImageNet with Inception module [28]Maize PlantVillage [7]492%VGG-19: 143 million
Chen et al. [29]DenseNet [30]Maize PlantVillage [7]498.50%33.97 million
Chen et al. [31]MobileNet-V2 [32]PlantVillage [7]3899.71%3.83 million
Chen et al. [33]DenseNet [30]custom dataset 1000 images597.60%3.40 million
Li et al. [34]CNNNBAIR [35]5095.4%0.75 million✓FPGA
Li et al. dataset [34]1096.2%
Chen et al. [36]MobileNet-V2 [32] and Attention Mechanism along with a Classification Activation Map [37]Li et al. dataset [34]1099.14%3.83 million
Chen et al. [38]Semantic Segmentation and CNNGrape PlantVillage [7]493.75%44.51 million
Mishra et al. [39]CNNPlantVillage [7] subset  + custom images388.46%22.75 million✓ Intel Movidius NCS with Raspberry Pi 3
Gajjar et al. [40]SSD [14] combined with CNNPlantVillage [7] subset2096.88%6.07 million✓ NVIDIA Jetson TX1
Summary of the state-of-the-art CNNs for plant diseases detection. As you can see in Table 1, the state-of-the-art plant diseases models achieve a very high classification accuracy, requiring a large number of parameters and higher computation cost, which prohibit their usage in embedded devices. In recent years the models have achieved very high accuracies, exploring different methods: transfer learning applied to existing architectures in literature [4], [21], [8], [23], [27], existing DNN models combined with different features extraction methods [11], [17], modified versions of existing networks [31], [33], [41], [36], novel network architectures [25], [29], [34], [38], [39], [40]. Such a higher accuracy, in most cases, has been reached using complexed architectures that require a high number of parameters. In [25], the authors proposed a simple nine-layer CNN model to identify plant diseases, applying the proposed CNN to the PlantVillage dataset with data-augmentation techniques to increase the data size. Despite the simplicity of this architecture, the authors reported better accuracy than that of a traditional machine-learning-based approach. As mentioned above, in order to realized an embedded system that could be deployed in precision agriculture, the constrains must be the reduction of computational complexity and the memory occupation, still maintaining a good accuracy. According to our knowledge, few works in literature proposed a hardware implementation of these plant diseases models [23], [34], [39], [40]. Following the above motivations, the aim of this paper is to propose an image detector for plant leaf diseases classification based on a lightweight and accurate CNN, that can be implemented on a low cost, low power core, while preserving good performance in terms of accuracy and inference time. This image detector has been presented in [42] where the severe constraints typical of embedded systems were satisfied with a network compression using tensor decomposition techniques. In this paper instead the final lightweight model was obtained with a filter pruning compression method [43] applied to a similar architecture as [42]. The pruning step is followed by a final retraining to recover the loss of accuracy introduced by compression. The CNN has been trained on two datasets specific for plant diseases recognition and implemented in a low-power, low-cost Python programmable machine vision camera, named OpenMV H7 Plus, for real-time classification. The obtained results show that the system is able to obtain good performances both in the case of binary and multi-class classification. In addition, a comparison with a state-of-the-art lightweight CNN for plant disease recognition [25] has been conducted. The manuscript is organized as follows. Section 2 describes the CNN-based image detector in all its components. Section 3 provides a list and a description of the scripts implemented both to train the CNNs and to embed these networks on the OpenMV Cam H7 Plus. Section 4 lists the materials needed to reproduce the presented image detector. Detailed software building and installation instructions are given in Section 5 and Section 6. Section 7 presents the architecture of the proposed CNN and the experimental carried out to validate the performance of the vision system principally in terms of inference time, frame per second (FPS) and memory occupancy.

Hardware description

An example hardware setup is shown in Fig. 1 and Fig. 2.
Fig. 1

OpenMV Cam with LCD display (a) used connected to a PC provided with OpenMV IDE that shows on the serial terminal the classification response applied to different leaves (CNN trained on PlantVillage-augmented dataset), (b) used in stand-alone mode powered by a power bank.

Fig. 2

OpenMV Cam with LCD display that shows the classification response applied to Esca disease (CNN trained on ESCA-dataset). (a) Healthy leaf (no tag), (b) Leaf affected by Esca disease correctly detected as shown in the LCD display (tag ‘E’).

OpenMV Cam with LCD display (a) used connected to a PC provided with OpenMV IDE that shows on the serial terminal the classification response applied to different leaves (CNN trained on PlantVillage-augmented dataset), (b) used in stand-alone mode powered by a power bank. OpenMV Cam with LCD display that shows the classification response applied to Esca disease (CNN trained on ESCA-dataset). (a) Healthy leaf (no tag), (b) Leaf affected by Esca disease correctly detected as shown in the LCD display (tag ‘E’). Fig. 1a shows the OpenMV Cam connected to a laptop via micro USB cable. The PC is equipped with the OpenMV integrated development environment (IDE) that shows in the serial terminal the classification results of the images acquired by the camera of the OpenMV Cam H7 Plus. Fig. 1b shows how the OpenMV Cam H7 Plus can be supplied by a power bank, avoiding to use the PC and obtaining a portable system to classify the leaf image in real-time. With the setup used in Fig. 1b, Fig. 2 shows an application example of the leaf image detector: Fig. 2a and Fig. 2b show the different responses of the system when acquires the frame of a healthy leaf or a leaf affected by esca disease. In the first case no message is expected but in the second case an alert message (’E’) has shown on LCD display to notify the presence of the plant disease. The main components of the embedded system are: OpenMV Cam H7 Plus The OpenMV Cam STM32H7 Plus camera 1 is a low-power Python programmable machine vision camera that supports an extensive set of image processing functions and neural networks. It is based on the STM32H743II ARM Cortex-M7 MCU running at 480 MHz featuring 32 MBs off-chip SDRAM, 1 MB SRAM, 32 MB off-chip FLASH and 2 MB on-chip FLASH. The OV5640 image sensor can capture images up to size 2592 ×  1944 but most algorithms run between 10–15-25–50 FPS on QVGA (320  ×  240) resolutions and below. OpenMV LCD Shield The LCD shield 2 gives OpenMV Cam the ability to display what it sees on-the-go while not connected to the computer. It features a 1.8” 128  ×  160 16-bpp (RGB565) TFT LCD display with a controllable backlight. The OpenMV Cam’s firmware has built-in support for controlling the LCD Shield using the lcd API module. PC equipped with OpenMV CAM IDE OpenMV IDE3 is the an integrated development environment specifically designated for use with OpenMV Cam. It features a text editor, a debug terminal and a frame buffer viewer with a histogram display. OpenMV IDE simplifies programming the OpenMV Cam and integrates a serial bootloader to flash the board. Micro SD card The micro SD card is extremely useful to save the model (specifically tflite int8 format) previously trained on a specific dataset and the main.py script written for the classification application, delegating the execution of the application to the Micro Python interpreter embedded in the board. Micro USB cable The micro USB cable can be used to connect the board to the PC or to a power supply. Power bank The power bank can be used to powered the board avoiding to connecting it to PC and realizing a portable system.

Design files

Design files summary

Below is a brief description of the file listened above: CNN_Esca.ipynb: This file contains the code to train, to validate and to test the initial CNN architecture for the ESCA-dataset [44]. It generates both the h5 and tflite models and then evaluates the models’ performances, such as accuracy, memory cost, number of parameters. CNN_Esca_pruned.ipynb: This file contains the code to apply the filter pruning compression on the model trained on Esca dataset and then to perform the retraining. It generates the final model for Esca dataset in h5 and tflite format and then evaluates its performaces in terms of accurary, memory cost, number of parameters. CNN_PV.ipynb: This file contains the code to train, to validate and to test the initial CNN architecture for the PlantVillage-augmented dataset [7], [26], together with a section to split the dataset in three partitions (training, validation, testing set). It generates both the h5 and tflite models and then evaluates the models performaces, such as accurary, memory cost, number of parameters. CNN_PV_pruned.ipynb: This file contains the code to apply the filter pruning compression on the model trained on PlantVillage-augmented dataset and then to perform the retraining. It generates the final model for Plant Village dataset in h5 and tflite format and then evaluates its performaces in terms of accurary, memory cost, number of parameters. CNN_Esca_model.h5: The Keras model file (h5 format) generated by CNN_Esca.ipynb. CNN_Esca_model.tflite: The TensorFlow Lite model file (tflite format) generated by CNN_Esca.ipynb. CNN_Esca_pruned_model.h5: The Keras model file (h5 format) generated by CNN_Esca_pruned.ipynb. CNN_Esca_pruned_model.tflite: The TensorFlow Lite model file (tflite format) generated by CNN_Esca_pruned.ipynb. CNN_PV_model.h5: The Keras model file (h5 format) generated by CNN_PV.ipynb. CNN_PV_model.tflite: The TensorFlow Lite model file (tflite format) generated by CNN_PV.ipynb. CNN_PV_pruned_model.h5: The Keras model file (h5 format) generated by CNN_PV_pruned.ipynb. CNN_PV_pruned_model.tflite: The TensorFlow Lite model file (tflite format) generated by CNN_PV_pruned.ipynb. conversion_DatasetEsca_into_bmp_format.ipynb: This file converts the images of the Esca dataset from jpg format to bmp format in order to be used in the OpenMV Cam. conversion_DatasetPV_into_bmp_format.ipynb: This file converts the images of the PlantVillage-augmented dataset from jpg format to bmp format in order to be used in the OpenMV Cam. augmented_esca_dataset_9transformation_splitted.zip: In this work we use a version of the ESCA-dataset with applied 9 data augmentations transformations. This dataset can be also generated by the scripts available in the ESCA-dataset repository, but, for your convenience, we provides the dataset already generated. Dataset_Esca_Test_bmp_128x128.zip: The ESCA-dataset converted in bpm format (pixel size 128  ×  128). Dataset_PV_Test_bmp_128x128.zip: The PlantVillage-augmented dataset converted in bpm format (pixel size 128  ×  128). openmv_demoEsca_SD_testingSet.py: This file contains the MicroPython code to be used in OpenMV Cam. This file loads the tflite model file and the bpm version of the testing set of ESCA-dataset, both saved in the OpenMV SD card, and it performs the classification on the testing set. openmv_demoEsca_SD_realtime.py: This file contains the MicroPython code to be used in OpenMV Cam. This file loads the tflite model file saved in the OpenMV SD card, and it performs a real-time classification of the images captured by the on board camera. openmv_demoEsca_SD_realtime_responseOnLCD.py: This file contains the MicroPython code to be used in OpenMV Cam. This file loads the tflite model file saved in the OpenMV SD card, and it performs a real-time classification of the images captured by the on board camera, displaying the results on the LCD display. openmv_demoPV_SD_testingSet.py: This file contains the MicroPython code to be used in OpenMV Cam. This file loads the tflite model file and the bpm version of the testing set of PlantVillage-augmented dataset, both saved in the OpenMV SD card, and it performs the classification on the testing set. openmv_demoPV_SD_realtime.py: This file contains the MicroPython code to be used in OpenMV Cam. This file loads the tflite model file generated from the training on the PlantVillage-augmented dataset and then saved in the OpenMV SD card, and it performs a real-time classification of the images captured by the on board camera. demo_Esca-1.mp4: This video shows how the board performs when a healthy/unhealthy leaf is captured (ESCA-dataset). demo_Esca-2.avi: Same as demo_Esca-1.mp4 but using pre-saved images of leaves displayed on a tablet (ESCA-dataset). demo_PV.mp4: This video shows how the board performs when different species of healthy/unhealthy leaves are captured (PlantVillage-augmented dataset).

Bill of materials

Build instructions

Generate networks: Load on your Google Drive the notebook files: CNN_Esca.ipynb, CNN_Esca_pruned.ipynb, CNN_PV.ipynb, CNN_PV_pruned.ipynb. Load on your Google Drive the augmented_esca_dataset_9transformation_splitted.zip to be used with the CNN_Esca.ipynb and CNN_Esca_pruned.ipynb files in order to train, prune and then retrain the Esca model. Load on your Google Drive the PlantVillage-augmented Dataset from [26] to be used with CNN_PV.ipynb and CNN_PV_pruned.ipynb files in order to train, prune and then retrain PlantVillage model. Open the file CNN_Esca.ipynb with Google Colaboratory, choose runtime session from the Menu and execute. Repeat this step for the same procedure for the file CNN_Esca_pruned.ipynb. The output model files will be saved in the same directory of the notebook file, download them for the next steps. Repeat steps 4 and 5, but using CNN_PV.ipynb and CNN_PV_pruned.ipynb files, to obtain the CNN models for the PlantVillage-augmented dataset. Generate OpenMV Cam application through MicroPython code: Generate MicroPython code: Open the OpenMV IDE to test the scripts openmv_demoEsca_SD_testingSet.py, openmv_demoEsca_SD_realtime.py and openmv_demoPV_SD_testingSet.py, openmv_demoPV_SD_realtime.py in oder to change, if necessary, the path of ESCA and PlantVillage models respectively and to test the model performance on board. Using the scripts openmv_demoEsca_SD_testingSet.py and openmv_demoPV_SD_testingSet.py the board makes the predictions on the test sets Dataset_Esca_Test_bmp_128x128.zip and Dataset _PV_Test_bmp_128x128.zip respectively, both saved on SD together with the corresponding tflite models CNN_Esca_model.tflite and CNN_PV_model.tflite. Using the scripts openmv_demoEsca_SD_realtime.py and openmv_demoPV_SD_realtime.py the board makes the predictions on the images acquired by the camera, dumping also the FPS and the inference time as well as the accuracy for each image. Using the script openmv_demoEsca_SD_realtime_responseOnLCD.py a feedback for the detection of an unhealthy leaf has shown in the LCD display. Setting up OpenMV Cam for MicroPython code: Once chosen the more appropriate script for your application, save the selected script on the SD card renaming it as main.py. This script will be executed when the board starts. Power the board with a power bank connected with a micro USB cable in order to have your image detector.

Operation instructions

Please refer to Hardware description and Build instructions sections, specifically to step Setting up OpenMV Cam for MicroPython code in Build instructions section.

Validation and characterization

In order to validate the image detector for real-time plant disease detection previously discussed, two different experiments, i) the experiment on ESCA-dataset [44] and ii) the experiment on the PlantVillage-augmented dataset [7], [26], were conducted. The first aims to validate the image detector performances in a binary classification and the second aims to determine that, with the same model, the system shows good performances also for the multi-class classification task. The experiments were conducted using the TensorFlow v. 2.5.0 and Keras v. 2.5.0 to train the models on Google Colaboratory with the ESCA-dataset and the PlantVillage-augmented datasets partitioned as reported in Table 2 and Table 3 respectively, the STM32Cube.AI extension X-CUBE-AI v. 7.1.0 4 to analyse the generated models, and the OpenMV firmware v. 4.1.1 on board.
Table 2

Consistency of the Esca dataset partition considered for training, validation and testing.

CategoryTraining Samples 60%Validation Samples 15%Testing Samples 25%Total samples
esca5328133222208880
healthy5292132322058820



Total106202655442517700
Table 3

Consistency of the PlantVillage-augmented dataset partition considered for training, validation and testing.

CategoryTraining Samples 60%Validation Samples 15%Testing Samples 25%Total samples
Apple_scab6001502501000
Apple_black_rot6001502501000
Apple_cedar_apple_rust6001502501000
Apple_healthy9872464121645
Background_without_leaves6851712871143
Blueberry_healthy9012253761502
Cherry_powdery_mildew6311572641052
Cherry_healthy6001502501000
Corn_gray_leaf_spot6001502501000
Corn_common_rust7151782991192
Corn_northern_leaf_blight6001502501000
Corn_healthy6971742911162
Grape_black_rot7081772951180
Grape_black_measles8292073471383
Grape_leaf_blight6451612701076
Grape_healthy6001502501000
Orange_haunglongbing330482613775507
Peach_bacterial_spot13783445752297
Peach_healthy6001502501000
Pepper_bacterial_spot6001502501000
Pepper_healthy8862213711478
Potato_early_blight6001502501000
Potato_late_blight6001502501000
Potato_healthy6001502501000
Raspberry_healthy6001502501000
Soybean_healthy305476312735090
Squash_powdery_mildew11012754591835
Strawberry_leaf_scorch6651662501081
Strawberry_healthy6001502781028
Tomato_bacterial_spot12763195322127
Tomato_early_blight6001502501000
Tomato_late_blight11452862501681
Tomato_leaf_mold6001504441194
Tomato_septoria_leaf_spot10622654201747
Tomato_spider_mites_two-spotted_spider_mite10052513521608
Tomato_target_spot84221013402392
Tomato_yellow_leaf_curl_virus32148033994416
Tomato_mosaic_virus6001502501000
Tomato_healthy9542384781670



Total3688492131538961486
Consistency of the Esca dataset partition considered for training, validation and testing. Consistency of the PlantVillage-augmented dataset partition considered for training, validation and testing.

Datasets

ESCA-dataset: The ESCA-dataset [44] containing 1770 photographs of the leaves of healthy and infected plants was used for the training, validation and testing of the CNN architecture. The sizes of the acquired images are and pixels with random portrait and landscape orientation. To enhance the size and quality of training dataset a data augmentation technique has been adopted, by using geometric transformations (horizontal and vertical flip, rotation, width and height shift), color transformations (brightness, contrast, saturation, hue, gamma), plus other image manipulations like zoom and blur. The classes and the consistency of the Esca dataset used in this experiment are reported in Table 2. PlantVillage-augmented dataset: The PlantVillage dataset [7] consists of 54303 healthy and unhealthy leaf images divided into 38 categories by species and disease. The original dataset is not yet available from the original source 5, therefore it can be downloaded from several well-known online repository, such as GitHub 6 and Kaggle 7. Moreover, an augmented version of this dataset can be used directly by the plant_village struct embedded in TensorFlow 8 or can be downloaded from the source Mendeley Data repository [26]. Particularly, the dataset in [26] has been presented by Geetharamani et al. in [25], where the authors, starting from the original PlantVillage dataset, realize an augmented version of this dataset applying several data augmentation techniques in order to improve classification performance and propose a simple nine-layer CNN specifically designed for this dataset. Authors use six different data augmentation techniques for increasing the data-set size: image flipping, Gamma correction, noise injection, PCA color augmentation, rotation, and scaling. In the final augmented data-set, 39 different classes of plant leaf and background images are available, for a total of 61486 images. In this work, the aforementioned version of the PlantVillage dataset, which for simplicity will be called PlantVillage-augmented dataset, has been chosen and a comparison with the simple CNN proposed by Geetharamani et al. has been performed, to validate the proposed approach. The classes and the consistency of the PlantVillage-augmented dataset used in the experimentation are reported in Table 3.

CNN architecture

The starting CNN architecture is depicted in Fig. 3 and comprises 5 weight layers in total: it consists of 3 convolutional layers each followed by a ReLU activation function and a max-pooling operation, and 2 fully-connected layers with a final softmax classifier. A detailed description of this simple architecture is provided in Table 4. The network was trained for 30 epochs on the previously described ESCA-dataset and PlantVillage-augmented dataset with images of size , by using an Adadelta optimizer with categorical cross entropy, a learning rate of 0.5 and a batch size of 64.
Fig. 3

Design TensorFlow of CNN architecture.

Table 4

CNN architecture in detail.

TypeFilter shapeInput sizeNumber of parameters
conv_13×3×3×16128×128×3448
relu_1128×128×160
maxpool_1 (3×3)128×128×160
conv_23×3×16×3242×42×164640
relu_242×42×320
maxpool_2 (3×3)-42×42×320
conv_33×3×32×6414×14×3218496
relu_314×14×640
maxpool_3 (2×2)14×14×640
flatten7×7×640
dense_13136×5121×31361606144
relu_41×5120
dropout (0.5)1×5120
dense_2512×2/512×39*1×5121026/20007*
softmax1×2/1×39*0

* Different number of parameters for the architecture applied to ESCA and PlantVillage-augmented dataset, since the dense layer depends on the number of classes (2 and 39 classes respectively).

Design TensorFlow of CNN architecture. CNN architecture in detail. * Different number of parameters for the architecture applied to ESCA and PlantVillage-augmented dataset, since the dense layer depends on the number of classes (2 and 39 classes respectively). Despite the high number of classes, the simple proposed network can be efficiently applied also to the Plant Village dataset. Furthermore a pruning compression technique was applied to the proposed CNN in order to implement this network on the OpenMV Cam H7 constrained-resource system, maintaining a good accuracy.

CNN pruning

The previously trained network was then compressed with a pruning method in order to reduce computational complexity and to obtain acceptable values for storage cost and inference time on embedded platform. A filter pruning technique was used with a similar approach as in [43]. For each layer the filters with the lowest total norms were discarded by consequently pruning the corresponding input channels of the subsequent layer. The finetuning was simply performed in a single step without freezing any layer. Details about model compression and finetuning for Esca and Plant Village datasets can be found in Table 5, Table 6. The final pruned network architecture is described in Table 7.
Table 5

Compression factors for the pruned models.

Esca datasetPlant Village dataset
conv_10.350.35
conv_20.50.5
conv_30.50.5
dense_10.90.9
Table 6

Details for the finetuning of the pruned models.

Esca datasetPlant Village dataset
pruning methodl2 norml1 norm
optimizerAdadeltaAdadelta
learning rate1.01.0
epochs2025
Table 7

Pruned CNN architecture.

TypeFilter shapeInput sizeNumber of parameters
conv_13×3×3×5128×128×3140
relu_1128×128×50
maxpool_1 (3×3)128×128×50
conv_23×3×5×1642×42×5736
relu_242×42×160
maxpool_2 (3×3)42×42×160
conv_33×3×16×3214×14×164640
relu_314×14×320
maxpool_3 (2×2)14×14×320
flatten7×7×320
dense_11568×4601×1568721740
relu_41×4600
dropout (0.5)1×4600
dense_2460×2/460×39*1×460920/17979*
softmax1×2/1×39*0

* Different number of parameters for the architecture applied to ESCA and PlantVillage-augmented dataset, since the dense layer depends on the number of classes (2 and 39 classes respectively).

Compression factors for the pruned models. Details for the finetuning of the pruned models. Pruned CNN architecture. * Different number of parameters for the architecture applied to ESCA and PlantVillage-augmented dataset, since the dense layer depends on the number of classes (2 and 39 classes respectively).

Results

To show the validity of the described models, firstly the performance achieved on PC has been considered and then the model has been evaluated on the chosen embedded system, the OpenMV Cam H7 Plus. Regarding the performance on PC, Table 8 and Table 9 report the results achieved by the initial and the pruned CNN in terms of storage cost, number of parameters, testing accuracy, inference time, MACC (multiply-accumulate operation), ROM Bytes and RAM Bytes, on ESCA and PlantVillage-augmented dataset respectively. Moreover, as reported in Table 10 and Table 11, a detailed analysis of the implemented models has been performed using the STM32Cube.AI extension X-CUBE-AI v. 7.1.0. Specifically, MACC, ROM Bytes and RAM Bytes have been computed using the X-CUBE-AI to analyse the models using in the terminal the following command:
Table 8

Model performance on PC — ESCA-dataset.

Model typeInput sizeMemory cost [KB]Test accuracy[%]Inference time[ms/img]
CNNh5128 × 12819164.7597.8853.22
tflite128 × 1281602.55597.9075.45
Pruned CNNh5128 × 1285739.28997.7951.95
tflite128 × 128718.96197.6919.94
Table 9

Model performance on PC — PlantVillage-augmented dataset.

Model typeInput sizeMemory cost[KB]Test accuracy[%]Inference time[ms/img]
CNNh5128 × 12819386.68896.5252.93
tflite128 × 1281621.19596.5078.67
Pruned CNNh5128 × 1288786.45795.8744.44
tflite128 × 128735.72795.7222.70
Table 10

Details of the model analyzed with X-CUBE-AI — ESCA-dataset.

Model typeParameters numberMACCROM BytesRAM Bytes
CNNh51630754210810406523016334088
tflite163075420749400163263288515
Pruned CNNh572817853385852912712242000
tflite728178522171772972462315
Table 11

Details of the model analyzed with X-CUBE-AI — PlantVillage-augmented dataset.

Model typeParameters numberMACCROM BytesRAM Bytes
CNNh51649735211005766598940334236
tflite164973520769084165172488552
Pruned CNNh574523553561972980940242148
tflite745235523947774689262352
$ stm32ai analyze -m $model_name.$ext --allocate-inputs --allocate-outputs -o $destination_dir Model performance on PC — ESCA-dataset. Model performance on PC — PlantVillage-augmented dataset. Details of the model analyzed with X-CUBE-AI — ESCA-dataset. Details of the model analyzed with X-CUBE-AI — PlantVillage-augmented dataset. where $model_name is the name of the model to analyze, $ext the extension of the file (h5 or tflite) and $destination_dir is the destination directory chosen to save the log file. Regarding the performance on board Table 12 and Table 13 report the results achieved for testing accuracy, inference time and frame per second (FPS), on ESCA and PlantVillage-augmented dataset respectively.
Table 12

Model performance on OpemMV Cam H7 Plus — ESCA-dataset.

Model typeInput sizeTest accuracy[%]Inference time[ms/img]FPS
CNNtflite128 × 12898.40276.4043.61
Pruned CNN128 × 12898.10122.9698.13
Table 13

Model performance on OpemMV Cam H7 Plus — PlantVillage-augmented dataset.

Model typeInput sizeTest accuracy[%]Inference time[ms/img]FPS
CNNtflite128 × 12896.24283.303.52
Pruned CNN128 × 12895.24125.637.95
Geetharamani et al. [25]tflite128 × 12894.34270.613.69
Model performance on OpemMV Cam H7 Plus — ESCA-dataset. Model performance on OpemMV Cam H7 Plus — PlantVillage-augmented dataset. As you can see, the pruned model preserves a high accuracy for both binary and multi-class classification. Meanwhile a considerable reduction is obtained for storage cost, inference time and FPS for the tflite models implemented on the OpenMV Cam thus obtaining a suitable model for embedded platform applications. In addition, a comparison with a state-of-the-art lightweight CNN for plant disease recognition by Geetharamani et al. [25] has been shown in Table 13, showing the better performance achieved by the proposed pruned CNN in terms of accuracy and inference time. A further experimentation has been conducted by testing the models trained on the CNNs trained on ESCA and PlantVillage-augmented dataset on a different testing set realized following the procedure of Mohanty et al. [4]. In this work, in order to assess the performance of the model on a “real world” data set, the authors downloaded images from Bing Image performing a search with the query “crop and disease name leaf leaves”, where crop and disease name was replaced by the crop and disease name pairs given for each of the PlantVillage dataset classes. Following this procedure, firstly a research on Bing Image (on July 4, 2022) has been conducted to download the top 10 images for each class (2 classes for ESCA and 39 for PlantVillage-augmented models) and then a visual verification step has been made to verify that the image was by a reputable source and that it was showing leaves in approximately the same configuration. The final testing set so realized consists of 20 and 390 images to test the Esca leaf disease and the plant leaf diseases through the models trained on ESCA and PlantVillage-augmented dataset (both pruned and not pruned). Authors show that this test leads to an accuracy drop from 99.34% to about 31.69%, using the best model trained on PlantVillage dataset. This is reasonable since the PlantVillage dataset contains images collected in a controlled environment unlike the new images that contains different background, such as fruits and stems. Also in the proposed work, the accuracy drops from 96.24% to 36.41% with the not-pruned CNN and from 95.24% to 30.51% with the pruned CNN, both tested on 39 classes, testing the models on OpenMV H7 Cam board. However, the achieved accuracy is better than that obtained using the model Geetharamani et al. [25] with this testing set: 27.69%. The experimental results show that the proposed models trained on ESCA-dataset reaches a lower accuracy drop: from 98.40% to 51.00% with the original CNN and from 98.10% to 50.00% with the pruned CNN, both tested on 2 classes and with the models embedded on board. In this case the drop is mitigated by the fact that, unlike the PlantVillage-augmented dataset, the ESCA-dataset contains images that has been directly taken in-place by different cameras with various resolutions, considering multiple lighting brightness, different sides and backgrounds, i.e. including not only single healthy/infected leaf but also groups of leaves and other parts of the plant, such as stems. Future works regard the improvement of this aspect in order to deploy the CNN-based plant leaf diseases detector in real scenarios without loss in accuracy.

Ethics statements

The work did not involve any human or animal subjects, nor data from social media platforms.

CRediT author statement

Laura Falaschetti: Conceptualization, Methodology, Investigation, Data curation, Software, Validation, Writing - Original Draft, Writing - Review & Editing, Visualization; Lorenzo Manoni: Conceptualization, Methodology, Investigation, Software, Validation, Writing - Review & Editing, Visualization; Denis Di Leo: Data curation, Software, Validation; Danilo Pau: Conceptualization, Methodology, Investigation, Writing - Review & Editing, Visualization, Supervision, Project administration, Funding acquisition; Valeria Tomaselli: Conceptualization, Writing - Review & Editing, Visualization, Funding acquisition; Claudio Turchetti: Conceptualization, Methodology, Investigation, Writing - Review & Editing, Visualization, Supervision, Project administration.

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Hardware nameOpenMV Cam Plant Diseases Detector

Subject area Environmental, planetary and agricultural sciences
General
Hardware type Imaging tools
Closest commercial analogWio Lite AI Single Board:https://www.hackster.io/news/seeed-s-new-wiolite-ai-packs-computer-vision-into-a-feather-sized-board-30a1eb8b08b3; Available at:https://www.seeedstudio.com/Wio-Lite-AI-Single-Board-p-5120.html
Open source licenseMIT License
Cost of hardware$136.47
Source file repositoryhttps://doi.org/10.17605/OSF.IO/UCM8D

Design filenameFile typeOpen source licenseLocation of the file

CNN_Esca.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
CNN_Esca_pruned.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
CNN_PV.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
CNN_PV_pruned.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
CNN_Esca_model.h5model fileMIT LicenseOSF Repository
CNN_Esca_model.tflitemodel fileMIT LicenseOSF Repository
CNN_Esca_pruned_model.h5model fileMIT LicenseOSF Repository
CNN_Esca_pruned_model.tflitemodel fileMIT LicenseOSF Repository
CNN_PV_model.h5model fileMIT LicenseOSF Repository
CNN_PV_model.tflitemodel fileMIT LicenseOSF Repository
CNN_PV_pruned_model.h5model fileMIT LicenseOSF Repository
CNN_PV_pruned_model.tflitemodel fileMIT LicenseOSF Repository
conversion_DatasetEsca_into_bmp_format.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
conversion_DatasetPV_into_bmp_format.ipynbGoogle Colaboratory Notebook fileMIT LicenseOSF Repository
augmented_esca_dataset_9transformation_splitted.zipdata fileMIT LicenseOSF Repository
Dataset_Esca_Test_bmp_128x128.zipdata fileMIT LicenseOSF Repository
Dataset_PV_Test_bmp_128x128.zipdata fileMIT LicenseOSF Repository
openmv_demoEsca_SD_testingSet.pymicropython fileMIT LicenseOSF Repository
openmv_demoEsca_SD_realtime.pymicropython fileMIT LicenseOSF Repository
openmv_demoEsca_SD_realtime_responseOnLCD.pymicropython fileMIT LicenseOSF Repository
openmv_demoPV_SD_testingSet.pymicropython fileMIT LicenseOSF Repository
openmv_demoPV_SD_realtime.pymicropython fileMIT LicenseOSF Repository
demo_Esca-1.mp4media fileMIT LicenseOSF Repository
demo_Esca-2.avimedia fileMIT LicenseOSF Repository
demo_PV.mp4media fileMIT LicenseOSF Repository
DesignatorComponentNumberCost per unit - USDTotal cost - USDSource of materials

OpenMV Cam H7 PlusOC1180.0080.00https://openmv.io/products/openmv-cam-h7-plus
OpenMV LCD ShieldLCD1120.0020.00https://openmv.io/products/lcd-shield
Micro SD CardSD118.698.69https://www.amazon.com/SanDisk-Ultra-UHS-I-Memory-Adapter/dp/B00M55C0VU
micro USB cableUSB117.797.79https://www.amazon.com/AmazonBasics-Male-Micro-Cable-Black/dp/B07232M876/
power bankPW1119.9919.99https://www.amazon.it/OKZU-10000mAh-Caricabatterie-Portatile-Powerbank/dp/B07JNSXRP2
  7 in total

1.  Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks.

Authors:  Shaoqing Ren; Kaiming He; Ross Girshick; Jian Sun
Journal:  IEEE Trans Pattern Anal Mach Intell       Date:  2016-06-06       Impact factor: 6.226

2.  Using Deep Learning for Image-Based Plant Disease Detection.

Authors:  Sharada P Mohanty; David P Hughes; Marcel Salathé
Journal:  Front Plant Sci       Date:  2016-09-22       Impact factor: 5.753

3.  Deep Learning for Image-Based Cassava Disease Detection.

Authors:  Amanda Ramcharan; Kelsee Baranowski; Peter McCloskey; Babuali Ahmed; James Legg; David P Hughes
Journal:  Front Plant Sci       Date:  2017-10-27       Impact factor: 5.753

4.  A Mobile-Based Deep Learning Model for Cassava Disease Diagnosis.

Authors:  Amanda Ramcharan; Peter McCloskey; Kelsee Baranowski; Neema Mbilinyi; Latifa Mrisho; Mathias Ndalahwa; James Legg; David P Hughes
Journal:  Front Plant Sci       Date:  2019-03-20       Impact factor: 5.753

Review 5.  Convolutional Neural Networks for the Automatic Identification of Plant Diseases.

Authors:  Justine Boulent; Samuel Foucher; Jérôme Théau; Pierre-Luc St-Charles
Journal:  Front Plant Sci       Date:  2019-07-23       Impact factor: 5.753

6.  A grapevine leaves dataset for early detection and classification of esca disease in vineyards through machine learning.

Authors:  M Alessandrini; R Calero Fuentes Rivera; L Falaschetti; D Pau; V Tomaselli; C Turchetti
Journal:  Data Brief       Date:  2021-01-29

7.  A Robust Deep-Learning-Based Detector for Real-Time Tomato Plant Diseases and Pests Recognition.

Authors:  Alvaro Fuentes; Sook Yoon; Sang Cheol Kim; Dong Sun Park
Journal:  Sensors (Basel)       Date:  2017-09-04       Impact factor: 3.576

  7 in total

北京卡尤迪生物科技股份有限公司 © 2022-2023.