Deep Learning and Machine Learning Based Method for Crop Disease Detection and Identification Using Autoencoder and Neural Network

ABSTRACT


INTRODUCTION
Crops are susceptible to various types of diseases which can effectively reduce production and negatively affect the agriculture economies.The problem of crop diseases is a significant and ongoing challenge in agriculture worldwide.Crop diseases can have catastrophic impacts on food production, leading to decreased yields, economic losses for farmers, and potential food shortages.These diseases are caused by different pathogens, including fungi, bacteria, viruses, and pests, which can infect a wide range of crops, from staple grains like wheat and rice to fruits like apples and citrus.Effective disease management is important to guarantee food security and sustainable agricultural applications.
Morocco is an agricultural country and produces several types of crops like tomato, potato, wheat, and pepper.That's why we worked on tree types of crops which are: Peppers, Potatoes and Tomatoes, and eight types of diseases which are: bacterial spot which affect pepper, potato early and light blight and tomato diseases (target spot, mosaic virus, yellow leaf curl, bacterial spot and early blight).To address these issues, we must detect early and automatically crop diseases.Many research works presented varied state-of-the-art systems for crop diseases identification using machine learning and deep learning algorithms.Nandhini and Ashokkumar [1] uses DenseNet-121 for plant leaf disease identification, Shadin et al. [2] use convolutional neural network and Inception V3 COVID-19 diagnosis from chest X-ray images, Khan et al. [3] use SqueezeNet to classify diseases in citrus fruits and the accuracy was 96%, Bharathi and Sonai [4] uses convolution encoder method to detect leaf disease and the accuracy was 98%.
The state-of-the-art techniques are time consuming and use a high trainable parameters number, so a machine with high computational power is required.So, we need a novel model which can reduce the training time significantly and the number of training parameters.
The main contribution of our novel model is shown as follows: (1) Data processing: after loading data from PlantVillage dataset, we resize all images and normalize them which can accelerate the convergence rate and improve the robustness of our proposed method.
(2) We built our variational autoencoder to encode the prepared data by Encoder, which can represent our data in low dimension called Latent Space or Bottleneck.This step compresses our data to speed up the training of our network.
(1) We reshaped all compressed data to use them for our neural network.
(2) The Encoder output serves as the input for our deep neural network.
We used TensorFlow to build our model that could identify crop disease with good accuracy using the dataset PlantVillage.We have tree steps in our proposed model.The first step is data processing, the PlantVillage dataset is preprocessed by resizing images, cutting and normalization of data to improve the model accuracy Khamparia et al. [5].Second step, we built our variational autoencoder to encode the dataset images and project all images in Latent Space.The third step, we train our neural network with the features extracted by our encoder.We used Adam optimizer algorithm for training which can enhance the learning efficiency of our model and leads to faster convergence of loss function.For ten kinds of diseases the model accuracy achieved 90% which demonstrates the effectiveness of our proposed model.

RELATED WORK
Several methods have already been used to accurately identify crop diseases through image classification.In all these methods, they have used several image processing methods like SVM, Neural Network (NN), K-mean algorithms and so on.
Bharathi and Sonai proposed a system to detect crop leaf disease using convolutional encoder architecture.They combined variational autoencoder for data extraction and convolutional neural networks for classification, this method named V-Convolution encoder network reached an accuracy of 98% after 150 epochs and with a convolution filter of 3*3.
Another work has been done by Khamparia et al. [5] where they used a convolutional neural network based autoencoder for crop leaf diseases detection, they have proposed hybrid technique to detect leaf diseases combining CNN and autoencoders.The dataset used contains 900 images.The accuracy of this approach reached 97.5% after 100 epochs.
Using five CNN architectures, Sanga et al. [6] proposed a banana disease identification system.They found that ResNet-152 outperformed all other architectures and the accuracy was 99.2%.
Chohan et al. [7] used Inception and VGG-19 architecture for plants disease identification using PlantVillage dataset.They found that VGG-19 outperformed Inception V3 with accuracy of 95% and 98% for testing and training respectively.
Mohameth et al. [8] combined various architectures to detect plant disease.For features extraction they used CNN architectures and for classification they employed k-Nearest Neighbor and Support Vector Machine (SVM) classifiers.The experiment shows that SVM and CNN combined reached an accuracy of 98% which outperformed all others.
Another similar work, for plant disease identification, has been done by Tiwari et al. [9] which combined various CNN architectures for features extraction, such as VGG-16, VGG19 and Inception V3, and classifiers like NN, SVM, KNN and Logistic Regression.After experiment, they observed that combining Logistic Regression with VGG-19 reached an accuracy of 97.8%.
Sibiya and Sumbwanyambe [10] use CNN for maize disease classification, Türkoğlu and Hanbay [11] combined three classifiers K-Nearest Neighbor, Extreme Learning Machine, and Support Vector Machines with state-of-the-art model (SqueezeNet, ResNet-50, ResNet-101, Inception-v3, InceptionResNetv2, and GoogLeNet) for plant disease recognition.Too et al. [12] presented a comparative study to select the best deep learning model for crop disease detection.
Pardede et al. [13] combined Convolutional Autoencoder (CAE) with SVM for corn and potato diseases identification.They used CAE architecture for features extraction and SVM for classification.Using PlantVillage dataset this proposed work achieved an accuracy of 87.01% and 80.42% for potato and corn diseases identification respectively.Ferentinos [14] use five CNN architecture to detect plant disease.Table 1 summarizes various research work using PlantVillage dataset.

87.01%
Most of these works mentioned above had a high training time.That's why we are motivated to strive towards building a model that can reduce the training time and detect crop disease with a good classification accuracy as much as possible.
The significant advantage of ALS-NN is training time reduction and the number of training parameters is also reduced.

DATA PROCESSING
The first task of this step is loading data from the PlantVillage dataset, we collected images of ten crop diseases which are mostly affected diseases in Morocco.These are Potato Early blight, Late blight, Tomato Target Spot, Tomato mosaic virus, Tomato Yellow Leaf Curl Virus, Tomato Bacterial spot, Tomato Early blight.Examples of our dataset are displayed in Table 2 with disease name.The PlantVillage comprises a total of 54,303 images of leaves, which are further categorized into 38 different groups based on factors like the plant species and the presence of diseases.The dataset is usually organized into subfolders or directories, with each subfolder representing a specific plant disease or plant type.Within each subfolder, you will find images of plants belonging to that category.For example, there might be subfolders named "Tomato_Healthy," "Tomato_Early_Blight," "Potato_Late_Blight," and so on.Here's a simplified example of how the dataset might be structured:

PROPOSED MODEL
We will discuss in this section the techniques used to design our novel model.Section 4.1 offers a fundamental concept of the Autoencoder and Neural Network.In section 4.2 we detailed our hybrid system.Section 4.3 provides the experimental setup to implement our novel system.

Algorithms used
This part outlines Vanilla Autoencoder and Deep Neural Network architecture.

Autoencoder
Autoencoder is a deep learning algorithm used on feature selection and extraction, based on unsupervised learning, and uses backpropagation algorithms to learn the weight parameters of the network.The output and input vectors have the same dimensionality because the network reconstructs its own inputs after training process.Figure 3 shows the pipeline of an autoencoder: Autoencoder compress data into lower representation named bottleneck or code and tries to reconstruct the output from the bottleneck.An autoencoder have three components: Encoder, code (or bottleneck or Latent-Space) and Decoder.The objective of the Encoder is to compress data into low dimension named code or Latent-Space (or bottleneck).Encoder is a Neural Network which contains many layers; the last layer is the bottleneck layer.We assume that we have N layers; The equation bellow (1) shows the operation of each Encoder layer: (1) For the ith Encoder layer: Xei: is the input; Xei+1: the result; Wei: the weight; bei: the bias; fei: the activation function.
In general, the Encoder can be represented by the mathematical function bellow: where, Z is the latent dimension (code), f is the activation function, W and b are weight and bias respectively.The decoder reconstructs the input based on latent space.The input of the Decoder is the output of bottleneck layer (code).The Decoder can be represented by the following equation: (3) For the ith Decoder layer: Xdi: the input; Xdi+1: the result; Wdi: the weight; bdi: the bias; fdi: the activation function.
In general, the Decoder can be represented by the mathematical function bellow: The difference between the reconstructed data X R and the original data X O is called Reconstruction Loss (RL).To minimize the RL, we used backpropagation algorithm to train the autoencoder.To compute the RL, we can use two loss functions which are BCE and MSE.The mathematical equations for these two-loss functions shown in ( 5) and ( 6): (5) Vanilla autoencoder proposed by LeCun et al. [16] contain only one hidden layer with a number of neurons less than the number of neurons in the input and output layer.The hidden layer is considered as a bottleneck layer which restricts and minimizes the information that would be stored.The main goal of Vanilla autoencoder is to learn how to develop a compressed input at the Latent Space layer.Figure 4 bellow illustrates the architecture of Vanilla autoencoder:

Vanilla autoencoder:
A vanilla autoencoder, often referred to simply as an "autoencoder," is a kind of artificial neural network employed for unsupervised learning and dimensionality reduction.It's called "vanilla" to distinguish it from more complex variations like convolutional autoencoders or recurrent autoencoders.
Here's a breakdown of the components and purpose of a vanilla autoencoder: •Encoder: is the first part of the autoencoder.Encodes data into a lower-dimensional representation.This lowerdimensional representation is often referred to as the "encoding" or "latent space.".
•Bottleneck Layer: The bottleneck layer, which is part of the encoder, is where the dimensionality reduction occurs.The number of neurons is fewer than the number of neurons in the input layer.This forces the network to capture the most essential features of the input data while discarding less important details.
• Decoder: The decoder is the second part of the autoencoder.It takes the encoded data and attempts to recreate the original input as closely as possible.
•Loss Function: calculates the dissimilarity between the reconstructed output and the original input.The autoencoder is trained to minimize this loss.
The primary purpose of a vanilla autoencoder is dimensionality reduction and feature learning.By training the network to compress and then reconstruct the data, it learns to capture crucial features in the data.This can be useful in various applications, such as: • Data Compression: Autoencoders can be used to compress data, reducing storage or transmission requirements.
• Anomaly Detection: When the reconstructed output significantly deviates from the input, it can indicate anomalies or outliers in the data.
• Feature Learning: Autoencoders extract features from data, which can be useful in tasks like image denoising, text generation, and more.
•Image and Signal Processing: Autoencoders are applied in image and signal denoising, inpainting, and superresolution tasks.
• Preprocessing for Supervised Learning: Autoencoders can be employed to preprocess data for subsequent supervised learning tasks, improving the performance of classifiers or regression models.
Overall, a vanilla autoencoder is a fundamental neural network architecture used for representation learning, dimensionality reduction, and various applications in unsupervised learning scenarios.
This work deals with crop images, so we use Vanilla autoencoder to get the compressed data representation before the step of classification.This operation of data compression reduces the number of extracted features which can significantly reduce the training time of our hybrid system and reduces the classification time.Neural networks contain units which are organized into input, hidden and output layers as shown in Figure 5. Shallow networks contain one hidden layer, the nodes within each layer are linked to nodes in neighboring layers.The computations in steps 1 and 2 occur for all neurons in the neural network, we talk about forward propagation.The results of forward propagation are compared, by the output layer, to the truth labels and adjust the weights if they have difference between results (predicted values) and truth labels.This process is called backpropagation, and the basics of this process can be summarized in 5 steps: (1) the neural network tries to reduce an objective function.( 2) the network takes the derivative of total error, i.e., difference between predicted values and actual.This derivative is named gradient of the layer.(3) based on the gradient obtained in step 2, the weights are updated using the same gradient or a factor of it (called learning rate).( 4) the process is repeated for each layer (5) values of gradients from previous layer can be used in next layer to make the gradient computation more efficient.

Figure 5. Neural network architecture
Noted that after one pass forward propagation and backpropagation the network layer's weight is changed.The Gradient minimizes the overall error, so parameters number are converging to a low value and this convergence is named gradient descent.
Deep neural networks contain several hidden layers.Deep learning can be applied to various problems like classification, NLP, pattern recognition, predictive analysis, etc. Deep learning outperforms its predecessors.
The first model of deep learning was introduced in 1943 is the McCulloch-Pitts [17].Based on the neural networks, the first computer model was created to mimic the neocortex of human brain [18].The theory of Hebbian, employed in biological systems, was introduced [19] after the MCP model.After that, Frank Rosenblatt was created the "perceptron" the first electronic device in 1957 [19] based on MCP neuron.There are two types of perceptron's: •Perceptron with single layer which can only works with linear separation of data points (linearly separable patterns).
•Multilayer perceptron or know as feed forward neural network which contain two or more layers with more processing power.
In 1969, researchers indicate that neural networks couldn't learn a basic XOR function [20], this phase know as AI-winter which AI didn't get more interest and funding.At the end of AI winter, a backpropagation algorithm was introduced in 1970 [21] by Werbos.Backpropagation learning algorithms uses errors for training deep learning models, this technique was applied to neural networks in 1980.The difference between DNNs (deep neural networks) and earlier generation of machine learning techniques is the Automated feature extraction.In 1980 Kunihiko proposed the "neocognitron" [22] a hierarchical and multilayered neural network which inspired the convolutional neural networks, this network has been used for Japanese handwritten character recognition.In 1986, the Recurrent neural networks (RNN) were proposed.In 1990, LeNet [23] is the earliest convolutional neural networks which is trained and used to identify the handwritten digits in MNIST data set.In 2006, Deep Belief Network (DBN) was proposed by Hinton [24].DBN is a deep generative network composed of several layers of stochastic latent variables, DBN is based on reinforcement learning and contains a stacked layer of RBM (Restricted Boltzmann Machine).
In contrast with shallow learning model (which contain few processing layers), deep learning contains deeper number of processing layers.Shallow architectures can't be used for nonlinear and complex functions.
Neural Network: Often referred to as an artificial neural network (ANN), inspired from the structure of the human brain is a computational system.It is used for different tasks, such as regression and classification of data.Neural networks (NN) contain neurons organized in layers (input layer, one or more hidden layers, output layer).
Here's an overview of the key components and concepts related to NN: 1. Neurons (Nodes): Each neuron receives one or more inputs, processes them, and produces an output.Nodes are arranged into layers (input, output and one or more hidden layers).
2. Weights and Biases: Neurons apply weights to their inputs, and these weights determine the strength of the connections between neurons.In addition, each neuron has a bias term that can be adjusted to control its activation.Weight and bias values are learned during the training process.
3. Activation Function: is applied to the input weighted sum and biases to determine the neuron output; it can influence the network's learning capacity and behavior.Common activation functions include the sigmoid, ReLU (Rectified Linear Unit), and tanh functions.
4. Feedforward Propagation: In feedforward propagation, information travels through the network from the input to the output layer.In each layer, units apply the activation function to their inputs and pass the results to the next layer.This process generates predictions or outputs.
5. Loss Function: Measures the difference between the predicted output and the actual target values.The goal during training is to minimize this loss, typically using optimization techniques like gradient descent.
6. Backpropagation: updates the weights and biases in the network to minimize the loss.It involves calculating the loss gradients without modifying the model's parameters and adjusting those parameters in the direction that reduces the loss.
7. Hidden Layers: Neural networks can have one or more hidden layers.These layers contain neurons that capture and transform features from the input data.

Author
Types of NN Diseases Accuracy Ferentinos et al. [14] VGG 65.59% Lee et al. [25] CNN 1269 tea disease images Amara et al. [26] LeNet three kinds of banana diseases 99.71% Wang et al. [27] VGG16, VGG19, GoogLeNet and ResNet50 apple leaf black rot 90.4% with VGG16 Fujita et al. [28] four-layer CNN cucumber diseases 82.3% Abdulridha et al. [29] RBF, MLP Laurel wilt (Lw) disease 98% Mohanty et al. [30] AlexNet and GoogleNet 99.35% Neural networks are very popular in recent years, especially deep neural networks, due to their capability to learn intricate patterns and representations.They are at the core of many breakthroughs in artificial intelligence and have transformed industries such as healthcare, finance, and technology.
Table 3 illustrates the contributions of authors according to different Neural Networks for plant disease identification.

Proposed work
We propose a new technique to detect crop disease combining Autoencoder architecture and neural network.The idea is to compress all images using the Encoder; the output is called Latent space of autoencoder (or Bottleneck) which contains all unique features extracted by the Encoder.The Latent space represents data into low dimensional in vector form.We then used neural network architecture for classification; the input of this NN is the compressed data that we have got by our Encoder.After training, our algorithm achieves 90% accuracy which is a satisfactory outcome.
The entire tactic of crop disease classification is divided into three steps: after data processing, the Encoder extracts features, and we use neural network for classification.Autoencoder can extract a compressed representation of an input.It's used for dimensionality reduction which is an approach to filter just the essential features of our crop data.Autoencoder is an unsupervised neural network used for automatic feature extraction from data.The autoencoder architecture is illustrated in the Figure 6.

Autoencoder for data compression
We have three parts of autoencoder: Encoder, Latent space (Bottleneck) and Decoder.The encoder extracts essential feature from data and Decoder attempt to rebuild the original data based on compressed data in latent space vector.The output of autoencoder is the same as input with some loss.
In this paper we use just the first part of Autoencoder: Encoder and Latent space representation, the output is then reshaped to be inputted into neural network.Our novel proposed method has not been introduced in any previous research study.
The experiment demonstrates that Neural Network is the most effective classifier compared with other algorithms like CNN [31].
The architecture of our approach is illustrated in the Figure 7 below: The Encoder compress data into latent space vector that contains all unique features from input data, we use then the NN as classifier.The training steps is illustrated in Figure 8 below: Figure 9 illustrates all steps of the proposed model.
We have three steps in the process of creating our novel model: the first step is to process data; we crop and resize images with size of 62*62 pixels.Resizing images can significantly speed up the model training.Then Vanilla autoencoder is created to minimize the dimensionality of data from 256*256 to 32*32, so we get the compressed data.Our autoencoder has three layers, we have used Adam optimizer and MSE function.In this paper, we don't use the Decoder of our autoencoder which try reconstructing the original.The loss function is mean squared error (MSE).The MSE formula is illustrated in Eq. ( 7): where, y is the input crop image and ỹ represent the reconstructed image, while n is the number of crops images.
After the operation of dimensionality reduction made by Vanilla autoencoder, the result of the Bottleneck layer serves as the input of our Neural Network classifier.Table above illustrates all parameters used in a NN.

PlantVillage dataset
In this paper, the dataset used is PlantVillage.We trained our model for three types of crops: Potato, Pepper, and Tomato and 8 types of crop diseases.Figure 11

Platform requirement
In this paper we used Jupyter Notebook, TensorFlow and Python version 3.8.The operating system used is windows 10 64 bits with a graphic card NVIDIA GEFORCE GTX and a RAM capacity of 12 GO.We also used a Core i7 processor.
The optimizer used for Vanilla autoencoder is Adam [32] and the loss function is MSE, we trained this algorithm with batch size of 32 and only seven epochs.We trained Neural network using binary cross-entropy (BCE) and Adam optimizer with five epochs and batch size of 32.
The choice of the Adam optimizer algorithm for training neural networks is a common and popular one for several compelling reasons: 1. Adaptive Learning Rates: Adam, which stands for "Adaptive Moment Estimation," adjusts the learning rate during training for each parameter individually.This adaptability is crucial because it helps the model converge faster and more reliably.It dynamically scales the learning rates based on the gradients of each parameter, ensuring that small and large updates are made appropriately.Adam utilizes estimations of both the first and second moments of the gradient to adjust the weight learning rate dynamically.For a random variable, the moment is calculated as follow: m: moment, X: random variable.
2. Momentum and RMSprop Combination: Momentum helps the optimizer navigate through flat regions and accelerates convergence, while RMSprop helps control the learning rates for each parameter based on the magnitude of recent gradients.The combination of these two techniques often results in faster convergence and better optimization.
3. Low Memory Requirements: Adam maintains exponentially moving averages of the gradients and squared gradients, which requires relatively low memory compared to some other optimization algorithms.This is advantageous when dealing with large models or when training on hardware with limited memory.To calculate the moments, Adam uses exponentially moving averages based on the gradients calculated from the current mini batch: =  2  −1 + (1 −  2 )²  (10) m and v: moving averages.g: the gradient.4. Consistent Performance: While no optimizer is universally the best for every problem, Adam tends to provide consistently good performance across a variety of tasks.It has become a good choice in the deep learning community.

RESULT AND DISCUSSION
The first operation in our method is data processing, which we crop and resize all dataset images.Then we feed the new dataset in our autoencoder to compress data.After only 5 epochs, the loss of autoencoder reached 73 10 -4 ; Figure 12 below shows the loss of our Encoder, while Figure 13 illustrates an overview of compressed data.

Figure 12. Training loss and validation loss for vanilla autoencoder
The overview of the compressed images is show in Figure 13:  Here's how T-SNE works: 1. High-Dimensional Input Data: t-SNE takes as input a dataset with a high number of dimensions, such as data points with many features.
2. Pairwise Similarities: It begins by computing pairwise similarities between data points.Typically, t-SNE uses the Gaussian distribution to measure the similarity between points, with closer points having higher similarities.
3. Probabilities: These similarities are used to create probability distributions over pairs of points.In the highdimensional space, the probability is based on the similarities computed in step 2.
4. Minimizing Divergences: The T-SNE objective is to find a mapping that minimizes the divergence between these two probability distributions.This is achieved, in low-dimensional space, using an optimization process that adjusts the positions of the points.
5. Gradient Descent: is used in the low-dimensional space to minimize the divergence between the two probability distributions by adjusting the positions of the points.
6. Preservation of Structure: The optimization process continues until the low-dimensional representation aligns well with the high-dimensional data, saving the relationships and the structure of data.
One key characteristic of t-SNE is that it tends to group similar data points closely together in the low-dimensional space, which makes it excellent for visualizing clusters or patterns in the data.However, it's important to note that t-SNE is not suitable for dimensionality reduction for other machine learning tasks; it's primarily used for visualization.
Figure 15 below depicts the application of T-SNE on the MNIST dataset.The MNIST dataset is known for containing images of handwritten digits, making it a popular choice for tasks such as digit classification.T-SNE is used as a technique to visualize and cluster the data points within this dataset, providing insights into the distribution and relationships between different handwritten digits.Figure 15 illustrates T-SNE on mnist dataset.
In summary, T-SNE is a powerful tool for visualizing data by projecting it into a lower-dimensional area while preserving the underlying structure and relationships, making it a valuable technique for exploratory data analysis and pattern recognition.
The second step of our method is to build neural network for binary classification.The Encoder output is the input of the neural network with three layers.After five epochs our model reached 90% and 89% for training and validation accuracy respectively.Figure 16 and Figure 17 illustrates the accuracy and the loss of our classifier respectively.
As we can see in Table 5above, the proposed method ALS-NN (Autoencoder Latent Space -Neural network) identifies crop disease in less time than other works, after only 22.014 second the classifier neural network (NN) can identify accurately crop disease after 5 epochs only while CNN and ResNet-152 exceeds 100 seconds.So, our novel method outperforms other works, and it is less time consuming.
The accuracy comparison is illustrated in Table 6.As illustrated, our proposed technique outperforms all these algorithms after only 5 epochs (batch size = 30, epochs = 7).As illustrated in Table 6, the proposed method achieved 90% testing accuracy which is more than Resnet-152, VGG and CNN (with three layers).The validation accuracy of ALS-NN method is 90% which is a good accuracy compared with other techniques like VGG19 with validation accuracy 10%, and ResNet-152 with validation accuracy 90%, and CNN with validation accuracy 86% but after 7 epochs.
On the other hand, ALS-NN is trained using less parameters compared with VGG, Resnet159 and CNN networks.Table 7 below shows a comparative study of our methods and other techniques based on a number of trainable parameters.
As illustrated in Table 7, our method is trained with less parameters compared with VGG, Resnet-152 and CNN with less than 90 000 parameters for Vanilla autoencoder and only 163 parameters for NN classifier.To reach the same accuracy as our method, Resnet-152 needs more than 8 million trained parameters, so the proposed system outperformed the state-ofthe-art systems based on trained parameters.

Significance of Results:
Our proposed model can be used in the agriculture area to speed up the process of crop disease identification which can increase crop yield by identifying and addressing crop disease promptly.So, farmers maintain healthier crops leading to increased yield.This is vital for food production to address the needs of an expanding global population.Our model can enable precise and targeted treatment by identifying diseases timely which can significantly reduce the need for chemical pesticides and fungicides, leading to cost savings for farmers and decreased environmental impact.
The use of ALS-NN can improve resource management with accurate disease identification, so farmers can allocate resources more efficiently.They can focus on the areas of their fields that need attention, saving time and resources.By reducing crop losses and optimizing resource use, our model ALS-NN can lead to cost savings for farmers.This is especially crucial for small-scale farmers and those in developing regions like Morocco.Our model is a good tool for farmers to tackle disease outbreaks effectively, maximize crop yields, and contribute to global food security.

IOT FOR SMART AGRICULTURE
The Internet of things plays a significant role in smart agriculture; IoT sensors can provide more information about crops which can positively affect crop production by monitoring environmental factors.Using IoT we can expect an increase of production with low cost by monitoring temperature, humidity, fertilizer, and soil efficiency.
Certainly, IoT has played a crucial role in smart agriculture, enabling farmers to monitor and manage their operations more efficiently.Here are some specific examples of how IoT has been used in agriculture and the impact it has had: 1. Precision Agriculture: IoT sensors are used for data collection (temperature or soil moisture…).This data helps farmers to take precise decisions about irrigation and fertilization.
2. Weather and Environmental Monitoring: Collect data like precipitation, humidity, and temperature.This information is vital for optimizing planting, irrigation management, and mitigating weather-related risks.
3. Crop Health Monitoring: using drones with cameras and IoT sensors.The data and captured images are analyzed to identify signs of disease.
4. Automated Irrigation: the system of irrigation is controlled based on IoT.This prevents over-irrigation, conserves water, and reduces energy costs.
5. Supply Chain Management: IoT helps in tracking the movement of crops and produce from farm to market.Sensors on storage containers monitor temperature and humidity to ensure perishable goods safety.
6. Livestock Feed Management: Smart feeders use IoT technology to dispense the right amount of feed for animals, reducing waste and ensuring optimal nutrition.7. Farm Equipment Maintenance: IoT sensors on tractors and other farming machinery monitor performance and send alerts when maintenance is needed.This proactive approach reduces downtime and improves operational efficiency.
8. Labor Efficiency: IoT can help with labor management by tracking worker activity and optimizing work schedules and assignments.
The impact of IoT in agriculture has been substantial: •Increased Productivity: IoT enables data-driven decisionmaking, resulting in higher crop yields, healthier livestock, and more efficient resource use.
• Resource Conservation: IoT helps reduce water and energy consumption by optimizing irrigation, reducing wastage, and promoting sustainable practices.
•Cost Reduction: By improving efficiency, IoT lowers operational costs, making farming more profitable.
•Sustainability: IoT supports sustainable agriculture by minimizing the environmental impact of farming practices.
•Improved Quality and Safety of agricultural products.
• Risk Mitigation: Early disease detection and weather monitoring allow farmers to take proactive measures, reducing crop and livestock losses.
In summary, IoT has revolutionized agriculture by giving farmers real-time information and control over various aspects of their operations.The impact is evident in increased productivity, resource efficiency, cost reduction, and overall sustainability.
In this paper we can monitor temperature and humidity in agriculture field through sensors using Raspberry Pi 3 model B+.The camera is connected to Raspberry Pi to capture crop images and use our proposed algorithm ALS-NN to identify crop diseases.

Concept of IoT
Internet of things (IoT) describes a system where the world is connected to Internet using several sensors.IoT is a vision where all objects (vehicles, furniture, roads, etc..) are controllable, locatable, and recognizable via the Internet.
Using IoT can improve accuracy, efficiency and economic benefit and reduce human intervention [42].

Raspberry Pi
The Raspberry Pi is a compact single-board computer used for small networking operations and computing.It's one of the important elements in the field of IoT.Using the Internet, Raspberry Pi can connect remote location controlling devices with automation system.In this paper we used Raspberry Pi version 3 B+, it has quad-core has quad-core ARM Cortex-A53 CPU of 900 MHz, and 1GB LPDDR2 SDRAM.It has 4 usb ports, Ethernet port, HDMI port, video camera interface, display interface DCI, and SD card slot.Here are some reasons why the Raspberry Pi 3 Model B+ might be chosen over other options: •Performance: It offers a significant boost in performance compared to its predecessors.
•Built-in Wireless Connectivity: The Model B+ comes with built-in dual-band Wi-Fi (2.4GHz and 5GHz) and Bluetooth 4.2.This integrated wireless connectivity simplifies connectivity and communication, which is important for many IoT and networked projects.
•Availability and Community Support: The Raspberry Pi 3 Model B+ benefits from a large and active user community, ensuring easy access to tutorials, documentation, and community support.The availability of resources and expertise is a major advantage for both beginners and experienced users.
•Cost-Efficiency: Raspberry Pi boards are known for their cost-effectiveness.The Model B+ offers a good balance of performance and features for its price, making it an attractive choice for projects with budget constraints.
•Compatibility: The Model B+ maintains compatibility with many of the existing Raspberry Pi accessories, including cases, power supplies, and HATs (Hardware Attached on Top).This can save time and money when transitioning from a previous Raspberry Pi model.
•GPIO Pins: It comes with a 40-pin GPIO header, which is important for hardware and DIY projects that require interfacing with sensors, motors, and other external components.
• Energy Efficiency: It is relatively energy-efficient, consuming only a modest amount of power.This can be important for projects where power consumption is a consideration.
•Operating System Support: The Model B+ enjoys wide operating system support, including various flavors of Linux and even Windows 10 IoT Core, making it versatile and compatible with a variety of software applications.Temperature, humidity, and camera sensors are commonly chosen for agricultural monitoring systems because they provide critical data that can significantly impact crop and livestock management.Here's why these specific sensors are commonly used: 1. Temperature Sensors: • Crop Health: Temperature affects plant growth and development.Monitoring temperature helps farmers assess the suitability of their environment for specific crops.Different crops have specific temperature requirements for optimal growth.
•Frost and Freeze Protection: Monitoring temperature is essential to protect crops from frost and freezing temperatures.When temperatures drop below critical levels, automated systems can activate heaters or fans to safeguard crops.
• Energy Efficiency: Temperature data allows for the efficient use of heating and cooling systems.This reduces energy consumption and lowers operational costs.
2. Humidity Sensors: • Irrigation Management: Humidity levels are closely related to the need for irrigation.Monitoring humidity helps in determining when and how much to irrigate.It prevents overor promoting healthy crop growth.
• Disease Prevention: Certain plant diseases thrive in humid conditions.Monitoring humidity can help in disease prediction and management.Farmers can take preventive measures when humidity levels are conducive to disease development.
• Storage and Preservation: In post-harvest storage, humidity control is crucial to prevent spoilage and maintain the quality of agricultural products.Sensors help maintain the optimal storage environment.
3. Camera Sensors: • Crop Health Assessment: Cameras capture images of crops, allowing for visual assessment of their health and growth.ALS-NN models can be used to analyze images for crop disease identification.
• Pest and Weed Detection: Cameras can detect the presence of pests and weeds, enabling farmers to take timely action.This reduces the need for chemical treatments and minimizes crop damage.
• Quality Control: Cameras in packing and processing facilities help in quality control by ensuring that agricultural products meet the desired standards.They can detect defects and sort produce accordingly.
•Research and Data Collection: Images collected from cameras can be valuable for research and historical data analysis.They provide a visual record of the development and health of crops over time.These sensors are chosen to produce real-time information that is critical for decision-making in agriculture.By monitoring temperature, humidity, and using cameras for visual data, farmers can improve crop management, minimize risks, and optimize resource usage.These sensors are integral to the shift towards data-driven precision agriculture, where decisions are made based on accurate and timely information, ultimately leading to better yields and sustainability in farming.

Proposed system model
To monitor crop healthiness, we used an intelligent system with various sensors which can collect information from the fields accurately.The camera connected to Raspberry Pi takes pictures of crops and sends them to our proposed system ALS-NN to identify crop disease.
Figure 18 below illustrate how we can identify crop disease with camera of Raspberry Pi and our system: The Raspberry Pi microcontroller is the core component of this system.It controls the working of each device connected to it.The important device connected to Raspberry Pi is camera with 5 Megapixels: (1) A camera is fitted which will capture pictures of the crop.
(2) This image is sent to our system to be analyzed.
(3) After image processing, we used our proposed algorithm ALS-NN to identify crop disease.

CONCLUSIONS
Crop disease identification is a challenging task, much research used deep learning and neural network to identify crop diseases.However, the downside of these methods is that they are time consuming and trained with millions of parameters which need performed computer.To address these issues, the proposed method ALS-NN used two networks, the first network is Vanilla autoencoder and Neural Network (NN).The first network compress data using the Encoder and feeds this output to the second network for classification.The autoencoder reduces extracted features number, without losing the important features, which also reduces the training time of our system which is the main contribution of this paper.The ALS-NN model works by compressing the data to utilize only the most critical information during the classification process.Vanilla Autoencoder is used for data compression by using the Encoder which is the first half of Autoencoder.The encoder takes high dimensional input data and transforms it into lowerdimensional representation without losing the important information.The encoder ultimately compresses data, and the result is called bottleneck, which represents a compact and informative representation of the original data.The compressed data is classified using neural network.This compression significantly speeds up the model and reduces the parameters number which outperform the state-of-the-art model.By combining Autoencoder and Neural Network [43] technologies effectively, we achieve a fast model with fewer parameters.As a result, disease detection operations are much quicker, which helps mitigate the negative impact of these plant diseases on crop yields.
Our system attained a testing accuracy of 90% and a validation accuracy of 90%.This system uses a few numbers of trained parameters (163 for Neural Network, 87139 for autoencoder).The implementation of the ALS-NN model can enhance resource management through precise disease identification.This allows farmers to allocate their resources more efficiently, as they can concentrate their efforts on the specific field's areas.This not only saves time but also conserves valuable resources, resulting in more effective and sustainable farming practices.

Figure 1 . 4 Figure 2
Figure 1. 4 Steps to process data Figure 2 illustrates some data examples after cropping and resizing images:

Figure 2 .
Figure 2. Leaf images after cropping and resizing operation

4. 1 . 2
Neural network Deep learning models are trained on large volumes of data involving numerous computations to perform predictions.Its architecture mimics human brain structure.Deep learning architecture contains a computational unit called "perceptron" which receives signals and transfers the input to the output signals.The perceptron stacks many layers which are essential to understand the input data.The architecture of perceptron mimics the structure of neurons in the brain, this architecture is named artificial neural networks.Each perceptron performed by the following steps: (1) weighted sum is calculated: the inputs (x1,x2….xn)are multiplied by the respective weight (w1,w2,…..wn) and summed at each node plus a bias term b (2) activation function: before sending the results to the next layer it convert the output into a wanted nonlinear format, the input of step 1 is passed to the activation function (tan hyperbolic, sigmoid…).

Figure 7 .
Figure 7. Overview of our proposed method Figure 10 illustrates the architecture of Vanilla autoencoder.

Figure 8 .
Figure 8. Training sequence of neural network classifier

Figure 13 .
Figure 13.Compressed images by the encoderVisualize latent space data:To visualize latent space data, we can use T-SNE technique to project our data into autoencoder Latent space.Figure14below shows the projection of our data into Latent space of autoencoder:

Figure 14 .
Figure 14.Projection of data into latent space T-SNE is a technique for dimensionality reduction employed in machine learning and data visualization.It's particularly useful for visualizing data in a lower-dimensional space without losing important data.Here's how T-SNE works:1.High-Dimensional Input Data: t-SNE takes as input a dataset with a high number of dimensions, such as data points with many features.2.Pairwise Similarities: It begins by computing pairwise similarities between data points.Typically, t-SNE uses the Gaussian distribution to measure the similarity between points, with closer points having higher similarities.3.Probabilities: These similarities are used to create probability distributions over pairs of points.In the highdimensional space, the probability is based on the similarities computed in step 2.4.Minimizing Divergences: The T-SNE objective is to find a mapping that minimizes the divergence between these two probability distributions.This is achieved, in low-dimensional space, using an optimization process that adjusts the positions of the points.5.Gradient Descent: is used in the low-dimensional space to minimize the divergence between the two probability distributions by adjusting the positions of the points.6.Preservation of Structure: The optimization process continues until the low-dimensional representation aligns well with the high-dimensional data, saving the relationships and the structure of data.One key characteristic of t-SNE is that it tends to group similar data points closely together in the low-dimensional space, which makes it excellent for visualizing clusters or patterns in the data.However, it's important to note that t-SNE is not suitable for dimensionality reduction for other machine learning tasks; it's primarily used for visualization.Figure15below depicts the application of T-SNE on the MNIST dataset.The MNIST dataset is known for containing images of handwritten digits, making it a popular choice for tasks such as digit classification.T-SNE is used as a technique to visualize and cluster the data points within this dataset, providing insights into the distribution and relationships between different handwritten digits.Figure15illustrates T-SNE on mnist dataset.In summary, T-SNE is a powerful tool for visualizing data by projecting it into a lower-dimensional area while preserving the underlying structure and relationships, making it a valuable technique for exploratory data analysis and pattern recognition.

Figure 18 .
Figure 18.Using camera Raspberry Pi and our proposed method to identify crop disease

Figure 19 .
Figure 19.Blog diagram for smart agriculture

Table 1 .
Some of the proposed works by the authors.

Table 3 .
Deep neural networks, or deep learning models, have many hidden layers and are capable of learning complex patterns.8. Training Data: Neural networks require labeled training data to learn the input and output relationships.The network learns from this data by adjusting its weights and biases during training.9. Overfitting: Neural networks can be susceptible to overfitting, which signifies they might exhibit strong performance on the training data but poorly on unseen or new data.Methods like dropout, regularization, and crossvalidation are used to mitigate overfitting.10.Applications: Neural networks are used in image recognition, autonomous vehicles, and many more.Different network architectures and configurations are tailored to specific tasks.Examples of methods using NN to detect crop disease.

Table 4 .
Parameters used in NN.

Table 5 .
Benchmarks based on training time

Table 7 .
Benchmark based on number of trainable parameters between ALS-NN and other works