Next Article in Journal
Discussion on Satisfaction and Loyalty of Women with Pelvic Treatment in Postpartum Period
Previous Article in Journal
Powering the Future: A Comprehensive Review of Polymer Composite Energy Storage Applications
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Proceeding Paper

A Lightweight Deep Learning Model for Identifying Weeds in Corn and Soybean Using Quantization †

1
Department of Computer Science, Bayero University, Kano 700006, Nigeria
2
Department of Software Engineering, Bayero University, Kano 700006, Nigeria
3
Software Engineering Lab, University of Aizu, Aizu-Wakamatsu 965-8580, Fukushima, Japan
*
Authors to whom correspondence should be addressed.
Presented at the 4th International Electronic Conference on Applied Sciences, 27 October–10 November 2023; Available online: https://asec2023.sciforum.net/.
Eng. Proc. 2023, 56(1), 318; https://doi.org/10.3390/ASEC2023-15811
Published: 2 November 2023
(This article belongs to the Proceedings of The 4th International Electronic Conference on Applied Sciences)

Abstract

:
Deep learning models are applied in precision agriculture for site-specific weed management by identifying weeds in farmlands. Unfortunately, because deep learning models are usually large, they are rarely adopted in resource-constrained devices (like edge devices) used in precision agriculture. In this study, we propose a lightweight deep learning model for detecting weeds in corn and soybean plants. We used transfer learning to train an InceptionnetV3 model for the task. The dataset used consists of a total of 13,177 samples of corn, soybean, and weeds. The InceptionV3 model, whose size is 183.34 MB, achieved a classification accuracy of 97%. We then applied the quantization technique to reduce the size of the model. The quantized model was reduced to a size of 23.38 MB, achieving an accuracy of 87%. The results show that quantization can reduce the size of a deep learning model while maintaining a reasonable amount of performance.

1. Introduction

Weeds are unwanted plants that grow along with cash and food crops [1]. They compete for water, nutrients, space, and sunlight, making it difficult for these crops to thrive. This problem causes a significant reduction in crop yield. Weeds cause about a 30% reduction in crop yield worldwide. For example, every year, weeds cause a loss of about USD 25 billion for North America’s corn and soybean crops. Therefore, there is a need to control the growth of weeds in farmlands. Weed control usually involves the spread of herbicides on farmlands. Herbicides can pollute land and deposit hazardous chemical substances on crops if applied carelessly. When using herbicides, farmers should target weeds. For site-specific weed management, automated techniques have been employed in precision agriculture, where weeds are precisely detected and treated with herbicides. These computerized techniques include machine learning and computer vision. Support Vector Machines and other machine learning approaches have been used to train computers to recognize weeds [2].
For instance, programmers can teach robotic devices with vision technology to identify weeds in corn and soybean plants. Deep learning is a subset of machine learning in which convolutional neural networks train models for tasks like object classification and detection [3]. However, these models are often characterized by large sizes, making them challenging to deploy in low-resource devices for precision agriculture. Model compression techniques (such as weight quantization, pruning, and knowledge) must be applied to these models to reduce their size. This makes it possible to deploy them in low-resource devices. Quantization involves converting model weights from high-precision floating-point form to low-precision floating-point or integer representation, such as 16-bit or 8-bit. One can change the high-precision floating-point representation of a model’s weights to a lower-precision form, reducing the model’s size and inference time (latency) without compromising too much accuracy. Weight quantization is a method used to reduce the model’s size. On the other hand, activation quantization is applied to enhance the model’s latency. Additionally, quantization will enhance a model’s performance by lowering memory bandwidth needs and raising cache utilization [4].
i. Weight Quantization: By applying weight quantization, the model size is decreased, and the training and inference processes are sped up. By lowering the number of bits required to represent the weight matrices, ref. [4] suggested a weight quantization technique to compress the deep neural network. Compressing the network helps to minimize the quantity of weights that must be kept in memory. By doing this, similar weights are taken out of the equation, and the remaining weight is used to create many connections [5]. Some quantization strategies use integer arithmetic to improve the inference time of the model. Compared to floating-point operations, integer arithmetic is more efficient and requires fewer bits for representation.
ii. Activation Quantization: The network training process can be accelerated even more by using quantized activations to replace inner products with binary operations. By avoiding full precision activations, we may also lower the amount of memory required [6]. The activations were quantized to 8 bits. After training the network, they quantized the activations using a sigmoid function that restricts activations to the range [0, 1]. To quantify activation and weights, the authors proposed wide reduced-precision networks (WRPN). They discovered that activations take considerably more memory space than weights do. To counteract the accuracy loss brought on by quantization, they used an approach that involved increasing the number of filters in each layer [6].
Figure 1 depicts the concept of weight quantization. The original network with 32-bit precision weight is supplied as input. Quantization is applied and the weight reduced to 8-bit precision.
In this study, we report the performances of two deep learning models trained for classifying weeds in corn and soybean: the large base model (trained using the InceptionV3 pre-trained model) and the lightweight model (trained using quantization-aware training).
The remainder of the paper is divided into three parts. Section 2 will discuss the “Methods”, which introduces the dataset used, explains the deep learning techniques used, and explains the different evaluation metrics for assessing results. The results and findings are then reported and discussed in Section 3. The conclusion is reported in Section 4.

2. Methods

2.1. Dataset

In this study, two publicly available datasets were used, the “Soybean weed dataset” and the “Corn weed dataset”. Soybean and weed images were acquired using a “Sony EXMOR” RGB camera mounted on an Unmanned Aerial Vehicle. The images with a size of 4000 × 3000 were then segmented [7]. The Corn weed dataset was taken from a corn field in China. The size of the images was 800 × 600 [8]. The combined dataset used consisted of 7404 images of soybean, 4573 images of weed, and 1200 images of corn. In total, there were 13,177 images. Figure 2 shows a sample of the images in the dataset:

2.2. Data Augmentation

Due to dataset imbalance, we carried out data augmentation on the data before splitting it into training, validation, and test data. In the dataset, the corn class with a total of 1200 samples was less represented. The augmentation parameters and values used are as follows:
rescale=1.0/255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True

2.3. Image Classification

In this study, we used the Keras deep learning framework with the TensorFlow backend to train the image classification model. We used transfer learning to train an InceptionV3 model. InceptionV3 uses a deeper network with fewer training parameters (23,851,784). The model consists of symmetric and asymmetric building blocks with convolutions, average pooling, max pooling, concatenations, dropouts, and fully connected layers. After training the InceptionV3 model, we then applied the technique of quantization to reduce the size of the model as depicted in the diagram below.

2.4. Experimental Setup

This section describes the environment in which the experiment was carried out. The models were trained using Keras framework with the Tensorflow backend. We used the Google Collaboratory Environment with T4 GPU to perform the training. Figure 3 shows a diagram of the models development.

3. Results and Discussion

After experimenting in this study, results show that the InceptionV3 model achieved an accuracy of 97% with a size of 183.34 MB, while the quantized model attained an accuracy of 87% with a size of 23.38 MB. The performances of the two models were also measured using other evaluation metrics, and values were recorded accordingly as shown in Table 1. Figure 4, Figure 5, Figure 6 and Figure 7 show the results obtained after experimentation.
From the results of the experiment, it can be seen that the base model performs better than the lightweight model in terms of accuracy, precision, f1-score, recall, and AUC, but the lightweight model is better in terms of size, and thus, it can be utilized in low-resource devices.

4. Conclusions

From the result of the experiment, we show that quantization technique can be used to compress the size of a large deep learning model without losing a significant amount of its performance. Also, the compressed model can be installed in low-resource devices for detecting weeds in corn and soybean [9].

Author Contributions

Conceptualization, A.A. and M.H. (Muhammad Hassan); Methodology, A.A.; writing—original draft preparation, A.A.; writing—review and editing, M.H. (Muhammad Hassan) and M.H. (Mohamed Hamada); Supervision, M.H. (Muhammad Hassan) and H.K. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Lee, N.; Thierfelder, C. Weed control under conservation agriculture in dryland smallholder farming systems of southern Africa. A review. Agron. Sustain. Dev. 2017, 37, 48. [Google Scholar] [CrossRef]
  2. The Vocabulary Memorisation Strategy Before Entering the Classroom and the Usage of the Memorisation Card. Available online: https://journal.uin-alauddin.ac.id/index.php/Eternal/article/view/25018 (accessed on 10 August 2023).
  3. Dewi, N.; Ismawan, F. Implementasi deep learning menggunakan CNN untuk sistem pengenalan wajah. Faktor Exacta 2021, 14, 34–43. [Google Scholar] [CrossRef]
  4. Han, S.; Mao, H.; Dally, W.J. Deep compression: Compressing deep neural networks with pruning, trained quantization and Huffman coding. In Proceedings of the 4th International Conference on Learning Representations, ICLR 2016—Conference Track Proceedings, San Juan, Puerto Rico, 2–4 May 2016. [Google Scholar]
  5. Anwar, S.; Hwang, K.; Sung, W. Fixed point optimization of deep convolutional neural networks for object recognition. In Proceedings of the ICASSP, IEEE International Conference on Acoustics, Speech and Signal Processing—Proceedings, South Brisbane, QLD, Australia, 19–24 April 2015. [Google Scholar] [CrossRef]
  6. Jacob, B.; Kligys, S.; Chen, B.; Zhu, M.; Tang, M.; Howard, A.; Adam, H.; Kalenichenko, D. Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference. In Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018. [Google Scholar] [CrossRef]
  7. Hasan, S.M.M.; Sohel, F.; Diepeveen, D.; Laga, H.; Jones, M.G.K. Weed recognition using deep learning techniques on class-imbalanced imagery. Crop Pasture Sci. 2022. [Google Scholar] [CrossRef]
  8. Virmani, J.; Kumar, V.; Kalra, N.; Khandelwal, N. PCA-SVM based CAD system for focal liver lesions using B-mode ultrasound images. Def. Sci. J. 2013, 63, 478–486. [Google Scholar] [CrossRef]
  9. Tan, K.; Wang, D. Towards Model Compression for Deep Learning Based Speech Enhancement. IEEE/ACM Trans. Audio Speech Lang. Process. 2021, 29, 1785–1794. [Google Scholar] [CrossRef] [PubMed]
Figure 1. The concept of weight quantization.
Figure 1. The concept of weight quantization.
Engproc 56 00318 g001
Figure 2. Sample data.
Figure 2. Sample data.
Engproc 56 00318 g002
Figure 3. Model diagram.
Figure 3. Model diagram.
Engproc 56 00318 g003
Figure 4. Accuracy and loss for base model.
Figure 4. Accuracy and loss for base model.
Engproc 56 00318 g004
Figure 5. Evaluation metrics for base model.
Figure 5. Evaluation metrics for base model.
Engproc 56 00318 g005
Figure 6. Accuracy and loss for quantized model.
Figure 6. Accuracy and loss for quantized model.
Engproc 56 00318 g006
Figure 7. Evaluation metrics for quantized model.
Figure 7. Evaluation metrics for quantized model.
Engproc 56 00318 g007
Table 1. Table of values for metrics used to evaluate the models.
Table 1. Table of values for metrics used to evaluate the models.
Accuracy (%)Precision (%)F1-Score (%)Recall (%)AUC (%)Model Size (MB)
Base Model9798989799183
Quantized Model879190879823
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Aaron, A.; Hassan, M.; Hamada, M.; Kakudi, H. A Lightweight Deep Learning Model for Identifying Weeds in Corn and Soybean Using Quantization. Eng. Proc. 2023, 56, 318. https://doi.org/10.3390/ASEC2023-15811

AMA Style

Aaron A, Hassan M, Hamada M, Kakudi H. A Lightweight Deep Learning Model for Identifying Weeds in Corn and Soybean Using Quantization. Engineering Proceedings. 2023; 56(1):318. https://doi.org/10.3390/ASEC2023-15811

Chicago/Turabian Style

Aaron, Alex, Muhammad Hassan, Mohamed Hamada, and Habiba Kakudi. 2023. "A Lightweight Deep Learning Model for Identifying Weeds in Corn and Soybean Using Quantization" Engineering Proceedings 56, no. 1: 318. https://doi.org/10.3390/ASEC2023-15811

Article Metrics

Back to TopTop