Pest Detection for Rice Using Artificial Intelligence

Agriculture not only provides food for humans, but it is also a major source of revenue for any nation. Millions of dollars are spent every year to protect rice crops from insects and pests that cause damage during harvest and storage. Early pest detection, which allows the crop to be protected from pest attack, is one form of crop protection. The best way to learn about the health of a crop is to examine it regularly. If pests are discovered, adequate steps may be taken to prevent the crop from suffering a major loss of yield. Early detection will help to reduce the use of pesticides and direct the pesticide selection process. It has grown into a large field of science, with a lot of work being done around the world to detect pests automatically. The typical way of inspecting the fields is with the naked eye. A farmer must manually search and assess over a vast landscape of fields, risking overlooking different affected areas and conducting thorough research across large lots. To analyse the entire area, several human experts are needed, which is both costly and time-consuming. This proposed system is mainly intended to develop an Intelligent IT-driven system using various Artificial Intelligence and Computer Vision Algorithms for precision farming, enabling the delivery of information directly to the farmer's phone, providing the details of damage localization, crop health, and needs for fertilizer and pesticide application.


Introduction 1.1 Agriculture
Plant and livestock cultivation is both a science and an art. Agriculture [1] was a pivotal step in the evolution of human society. Developing farmers started planting wild grains about 11,500 years ago, after collecting them for at least 105,000 years.

Indian Agriculture
The backbone of the Indian economy [2] is Agriculture, and it will maintain for a long time. It would be able to sustain nearly 17% of the world's people by using just 2.3% of the world's land area and 4.2 % of the world's water supplies. Economic reforms implemented in the country during the first decade of the 1990s have improved the economy's growth trajectory.

Agricultural Production and Productivity
Agricultural engineering is a discipline that aims to establish technologies that increase productivity while lowering cultivation costs [3]. Land operations and processing activities required the use of electricity. Agricultural engineering practises have increased as a result of the advent of electricity. To care for the projected population of 1.363 billion by 2025, productivity must increase by 100 % from its current level. The anticipated energy contribution to agriculture has increased from 1. 3

to 2.4 KW/ha
The limitations of low agricultural production were recognised, and as a result, state and federal governments stressed the importance of agriculture's rapid growth. Farmers who use highyielding varieties with additional fertiliser, pesticides, and assured irrigation by tube wells accelerate agricultural development. The adoption of better seeds, a higher fertiliser dosage, and plant protection chemicals, including irrigation, allowed for an increase in grain production.

Types of pests in Agriculture
We obtained images so twenty species of paddy field insect pests with ten shots per species from Google Images taken by the Department of Agricultural Biology, University of Jaffna, Sri Lanka. Fig. 1 shows some example images of these selected twenty species of insect pests primarily found in Jaffna. This image set has significant viewpoint changes, different backgrounds, arbitrary rotations, and scale differences within each class. Fig. 2 shows some of the intra-class variations in the image set and scale differences within each class 2. Agriculture by using Artificial Intelligence (AI) In agriculture, Artificial Intelligence (AI) advancements prove improvements in gaining yield and increasing and developing increasing crops. An AI algorithm [4] predicts the time takes for products like a tomato to be ready for picking, therefore increasing farming effectiveness. The advancement goes on, including Crop and Soil testing, Predictive Analytics, Agricultural Robots uses sophisticated algorithms and information collected to maintain and monitor crops' health. The growth of demand for food in the future due to the more population, they required no less than a 75% raise in production to maintain this demand from agriculture. People perceive that the alteration of these new techniques and AI will help reach that target. The Artificial Intelligence in agriculture shown in

Machine Learning
Machine learning (ML) is a subset of artificial intelligence (AI). Without being expressly programmed to do so, machine learning algorithms [5,6] made decisions based on a mathematical model supported sample data, referred to as "training data." Many programmes make use of machine learning algorithms. Computational statistics is what machine learning is said to be. The field of machine learning benefits from the study of mathematical optimization and theory, which provides methods and application domains. Data science is a related area of research that focuses on unsupervised learning for exploratory data analysis. Predictive analytics is a term used to describe machine learning algorithms.

Deep Learning
Deep Learning [6] can detect the existence of pests and disease in farms with great accuracy. CART, a machine learning algorithm, can reliably forecast the likelihood of potential illness and pest attacks. Regular human monitoring is unable to reliably predict the quantity and severity of pests and diseases attacking the plant, allowing for the application of appropriate and sufficient fertilizers, pesticides to eradicate the horde. As a result, simulated perception provides a corrective indicator of the amount of fertilisers and pesticides to spray at specific goal areas. This paper aims to assist farmers in protecting their farms from pest and illness attacks and removing them with no disrupting the soil's demureness or new plant sections. Farmers in India mostly rely on physical monitoring and a few apps that have large database restrictions and are only reliable for recognition. Since avoidance is preferable to heal, our paper aims to forecast pests/diseases in the future, allowing farmers to avoid such attacks. In the development of farms and agro-based industries, technology plays a critical role. In agriculture, automation is the most in-demand technology. Many companies have developed the most cuttingedge solutions in ML and AI, transform cultivation into Digital cultivation. The application of Deep Learning in cultivation is discussed and tested in this paper. For growers, diagnosis is normally a top priority. Farmers use pesticides/fertilizers throughout their whole farm because they are afraid of disease or pest attack, which can damage the soil and plants. This paper aims to teach farmers how to apply a small amount of pesticide/fertilizer only to a functional area where a pest/disease is present or may be present in the future. This assists farmers in preventing and eliminating such attacks on their farms by spraying in a small quantity and not polluting soil and other plant pieces. This has a number of advantages, including growing farmers' annual monetary income and reducing crop loss due to pest/disease attacks.

Vegetation Index
A vegetation index [7][8][9][10] is a number that indicates how healthy the vegetation is. The physics of light reflection and absorption through bands is used to calculate the math for calculating a vegetation index. Good vegetation reflects light strongly in the near-infrared band but not so much in the visible spectrum. As a result, a ratio of light reflected in the near-infrared to light reflected in the visible spectrum can be used to identify areas of potentially safe vegetation.

Normalized Difference Vegetation Index
The Normalized Difference Vegetation Index (NDVI) is a greenness index that ranges from 0 to 1, with 0 indicating minimal or no greenness and 1 indicating full naturalness. Over wide areas, NDVI is used as a quantitative proxy measure of vegetation health, cover, and phenology (life cycle stage).

Fig.4. NDVI
The visible and near-infrared light reflected by vegetation is used to calculate the NDVI [11,12]. (1) NRI-near-infrared radiation VIS-visible radiation the result of this formula is called the Normalized Difference Vegetation Index (NDVI). NDVI for a given pixel results in a number that ranges from minus one (-1) to plus one (+1); however, no green leaves offer a value close to zero. A zero indicates no vegetation, and close to +1 (0.8-0.9) indicates the highest possible density of green leaves.

Algorithm 4.1 Artificial Neural Networks Algorithm
With soil review, it detects the plant's welling (moisture content), burning sensation, disease, and pest. The dataset of plant leaves, pests, a variety of diseases, and soil images is categorised into multiple clusters using the MATLAB device, which organises multiple labels. The labels are distinguished from our enter check image and assigned to the closest corresponding label based solely on Euclidian distance. The fuzzy C-means algorithm [13,14] is used to detect pests and diseases on the farm. Convolutional Neural Networks (CNNs) are used to perform ideal analysis. Since the photograph used to enter is unknown, the classification method is Unsupervised Learning.

Confusion Matrix
To understand the merits of a classification algorithm, a confusion matrix is used. When there is an unequal variety of findings in each classification or more than two training in the dataset, the accuracy of classification on my own can be deceiving. A confusion matrix's desired form is shown in Fig.5

True Positive
An output where the model correctly predicts the positive class.

True Negative
An output where the model correctly predicts the negative class

False Positive
An output where the model incorrectly predicts the positive class.

False Negative
An outcome where the model incorrectly predicts the negative class. Besides, some terms define the model, such as sensitivity, accuracy, precision, specificity.

Accuracy
The ratio of exact predictions to the total predictions made is known as accuracy.

Precision
It is sometimes also known as positive predictive value. It is defined as the ratio of correct optimistic predictions to the total predicted positives. Precision = TP / (TP+FP) (3)

Sensitivity
The model's sensitivity is a measure of how well it can detect events in the positive category. It's calculated by dividing the number of true positives by the total number of positive events in the dataset, i.e. the positive class events that were correctly predicted. Positive class events were expected incorrectly. Sensitivity=TP/(TP+FN) (4)

Specificity
It assesses how precise the positive class assignment is. It's calculated by dividing the number of true negatives by the total number of adverse events in the dataset, with the negative class events correctly predicted and the adverse class events incorrectly predicted. Specificity = TN / (FP+TN) (5)

4.7Image Processing Algorithm
There are several advantages to convert snap shots to grayscale and understanding how to do so. The most obvious advantage of convert a shaded image to grayscale is that takes up considerably fewer spaces. If you're unfamiliar with how pictures are saved on a computer, this is a good place to start. An RGB image [15] is made up of three images stacked on top of each other: a red scale, a green scale, and a blue scale image, each with eight bits per pixel (intensity value ranging 0 -255). A single pixel of an RGB image needs 8 bits for each of the three colours, for a total of 24 bits per pixel.

Fig.6. RGB to Greyscale conversion 5. Results and Discussion
The training phase has done on the image dataset. We also used K-Means clustering to classify the given input dataset into its corresponding labels and trained an algorithm to do so. We used a builtin function in MATLAB called Bag of Features to categorise the images. The moisture content of Edge Detection is also completed, as is the number of days the crop can withstand without external attacks during the post-harvest season. This section is beneficial to agro-based industries because, according to a survey, 20 percent of crop postharvest is lost due to moisture levels that are not kept at optimal levels. In comparison to a perfect moisture leaf, Figure.7 depicts the moisture content in the given input test picture. Via an edge detection algorithm, it has established a math relation for determining moisture levels. We estimated the approximate moisture levels from the input levels, as well as the number of days the crop will survive without external infections, using trial and error math If the moisture is more than usual, the leaf will swell; if humidity is less, it will drain. The leaf will swell if there is more moisture than normal, and it will drain if there is less. Based on the current humidity content, this parameter is used to predict disease attacks. There's a risk of fungal attacks if there's a lot of moisture. As a result, this is one of the most important factors to consider when predicting foreign agent attacks. Figure  .8.shows how to extract features using the MATLAB built-in function collection -Of-Features. K-Means Clustering is used by the algorithm to classify the images. The number of features was 53055, and the number of clusters was 500, thanks to the algorithm. Following the development of training fundamentals, the clusters are ready for training and labelling for the detection process. The images get into those corresponding labels for identification purposes after the clustering. The SVM's X-Y axes are formed by this. We developed a Perception in which image extraction is performed in hidden layers. The number of iterations is measured in Epochs. We've been through 500 iterations. Based on the size of the image dataset, the algorithm will automatically stop when it reaches the most accurate value. The algorithm is implemented in MATLAB after Image categorization, Feature Extraction, and Training Data have been completed. Statistics and Machine Learning Toolbox, Neural Network Toolbox, and Image Processing Toolbox are among the toolboxes used. The coaching statistics in the form of photograph categories, picture classification using K-Means clustering, and moisture quality, as well as predicting withstanding, are the outputs. The algorithm is used to classify the photograph dataset and apply coaching information. The visual representation contrasts with the informed data for identification and prediction. For increased precision, unsupervised learning is used. Take ordered statistics from Indian rice flowers and check the box to enter as an African rice plant. Because of the minor difference in appearance, the accuracy will be compromised. As a result, we're concentrating on Unsupervised Learning. Using the Fuzzy C-Means algorithm, the instance will achieve 99% accuracy. The records may be hazy, but they will be becoming more precise. As a result, we are refraining from using Supervised Learning methods. Future Scope Furthermore, we plan to transform this project from a concept to a complete end-user product. This can be accomplished by using the Tensor Flow library function in the Python IDE with a large number of processors. The product will be capable of both predicting and identifying disease/pest attacks. For the education network, a more comprehensive collection of data will be provided. The entire algorithm will be created using Tensor Flow to create a higher-level framework open CV for Image analytics, similar to the Image Processing Toolbox in MATLAB.