225 | International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Coffee Tree Detection Using Convolutional Neural Network Ahmed Abdulsalam Naji Hasan Department of Computer Science, Faculty of Applied Science Taiz University, Republic of Yemen Corresponding Email: aaftername@gmail.com A B S T R A C T S A R T I C L E I N F O Identifying plants is an important field in the environment because of their roles in the continuation of human existence. Finding a plant by using the traditional methods such as looking at its physical properties is a burdensome task. Thus, several computational-based methods have been introduced for detecting trees. In this study we constructed the coffee tree dataset due there is no publicly available coffee tree dataset for detection and classification of the coffee tree in orchard environments for what this tree has a role in health, industrial and agricultural fields, and raising the wheel of economic development. Many machine learning algorithms have been used to detect and classify trees which resulted in reliable results. In this study, we presented a deep learning-based approach, in particular a convolutional neural network, for coffee tree detection and classification. The current study focused on providing a dataset for the detection and classification of coffee trees and improving the efficiency of the algorithm used in the detection and classification model. This study achieved the best results, the proposed system achieved an accuracy of 0.97%. Article History: Submitted/Received 05 May 2022 First Revised 01 Jul 2022 Accepted 19 Sept 2022 Available online 21 Oct 2022 Publication Date 01 Dec 2022 Aug 2018 __________________ Keywords: Coffee Tree Dataset, Al- Mawasit, Wadi Balabil, Al-Ghayl, Joreenat, Al-Zeila International Journal of Informatics, Information System and Computer Engineering International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 https://doi.org/10.34010/injiiscom.v3i2.9504 Ahmed Abdulsalam Naji Hasan. Coffee Tree Detection Using Convolutional…| 232 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 1. INTRODUCTION 1.1. Overview of the study Agriculture is extremely important to continue human existence. It remains a major driver of many economies around the world, particularly in developing and underdeveloped economies. There is a growing demand for food and cash crops. Machine learning techniques have been widely used in the control and management of agricultural crops, and the identification of types of agricultural Crops. Several machine learning algorithms have been used in the agricultural field since the beginning of the twentieth century. For example, Convolutional neural networks (CNN) have been used to identify trees, It still needs need a standard data set designed to achieve high efficiency, by taking full advantage of from different assembly devices. To help identify and detect different crop trees. Coffee is one of these important crops, driving forces of the economy in various countries of the world (Clarence et al., 2003). For the importance of coffee 1 October 2015 World Coffee Daybasis of the economy of many of them, especially in the Yemeni environment. Thousands of families depend on the coffee crop to increase their annual income. Approximately, one million people are working in this field starting from its cultivation until its exportation. It can be considered the main commodity that Yemen exports to the world after oil. With the coffee crop, Yemen has recorded a distinguished presence at the global level since the beginning of the sixth century as the first source of coffee (Amamo, A. A.,2014). Yemen is the only country in the world where the coffee tree is grown under climatic and environmental conditions that are not similar to other regions of the world. Yemeni coffee, which is called Arabica coffee, is considered the most famous and the most expensive coffee in the world (INCOMES et al., 2005). In the field of health, many studies have shown that coffee extracted from this tree is one of the substances that contain a great benefit to the body, as it treats many diseases such as type 2 diabetes colon and prostate cancer (Kolb et al., 2020). And liver diseases (Nieber et al., 2017). Coffee also helps to increase focus and endurance (Karayigit et al., 2021). It protects the liver from cirrhosis, as it reduces liver enzymes and prevents liver cancer, coffee is a rich source of antioxidants that protect people from tooth loss (Priya et al., 2020). And gum disease (Nagpal et al., 2014). Thus, people have become more interested in planting coffee trees (Al- Zaidi et al., 2016). This study aims to detect and classify the coffee tree using a convolutional neural network to encourage farmers to plant coffee trees. It will assist in developing the coffee tree in different countries, knowing the taxes of coffee trees, inventory, the farm management plan, and increasing the yield. Detection and classification of the coffee tree are useful in making smart systems to classify many other important trees, especially those used in the field of medicine. 1.2. Literature Review Computer vision has become very important in the knowledge of agricultural cash crops, and it is an easy and inexpensive way compared with the traditional methods (Chandra et al., https://doi.org/10.34010/injiiscom.v3i2.9504 233 | International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 2020). Several works have been introduced for detecting trees based on computer vision techniques. For example, Zortea et al., presented a method for detecting citrus trees at high- density orchards from images captured by unmanned aerial vehicles (UAVs). They used the CNN method depicted in Fig. 1 which provided good results ((Zortea et al., 2018). Fan et al., proposed a new algorithm based on deep neural networks, as shown in Fig 2., to detect tobacco plants in images captured by UAVs. The results showed that the proposed algorithm performs well (Fan et al., 2018). Wu et al., present an extracting apple tree crown information from remote imagery using (UAVs).by using a Faster R-CNN object detector. An automatically detect and segment individual trees and measure the crown width, perimeter, crown projection area of apple trees. The results were close to the manual delineation and this technique can bey used to detect and count apple an overall accuracy of 0.97%, estimate crown parameter with an overall accuracy exceeding 0.92% (Wu et al., 2020). Sun et al., presented image dataset collected by mobile phone in natural scene. which contains 10,000 images of 100 ornamental plant species in Beijing Forestry University campus. A 26-layer deep learning model consisting of 8 residual building blocks is designed for largescale plant classification in natural environment. The proposed model achieves a recognition rate of 0.91% on the BJFU100 dataset, demonstrating that deep learning is a promising technology for smart forestry (Sun et al., 2017). Santana et al., developed an algorithm for automatic counting of coffee plants and to determine the best age to carry out monitoring of plants using remotely piloted aircraft (RPA) images, it presented 96.8% accuracy with images without spectral treatment (Santana et al., 2023). Zheng et al., presented the CropDeep Agricultural Dataset. CropDeep species classification and detection dataset, consisting of 31,147 images with over 49,000 annotated instances from 31 different classes Images were collected with different cameras and equipment in greenhouses, captured in a wide variety of situations. Results show that current deep-learning-based methods achieve well performance in classification accuracy over 0.99% (Zheng et al., 2019). Diez et al., have published a review focused on studies that use DL and RGB images gathered by UAVs to solve practical forestry research problems. The review discussed three main forestry problems including (1) individual tree detection, (2) tree species classification, and (3) forest anomaly detection (forest fires and insect infestation) this study useful for researchers that want to start working in this area (Diez et al.,2021). Gurumurthy et al., They presented a method for semantic segmentation of mango trees in high resolution aerial imagery, and, a novel method for individual crown detection of mango trees using segmentation output. Results obtained demonstrate the robustness of the proposed methods despite variations in factors such as scale, occlusion, lighting conditions and surrounding vegetation (Gurumurthy et al., 2019). https://doi.org/10.34010/injiiscom.v3i2.9504 Ahmed Abdulsalam Naji Hasan. Coffee Tree Detection Using Convolutional…| 234 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 2. METHOD In this chapter, we presented dataset of coffee tree, due to the lack of publicly available datasets to detect and classify the coffee tree, and system to detect and classify the coffee tree based on CNN deep learning algorithm for detection and classification of the coffee tree among more than one type of trees. As show in Fig. 1. We briefly explain the main steps of the proposed method used to construct the dataset and model based on CNN technique (Sk et al., 2021). The main phases are illustrated in the following Table 1. Table 1. Proposed System Phases Dataset Acquisition Images Preprocessing CNN Classifier Experiments Testing of Model 2.1. Dataset Acquisition We have constructed our own dataset from 417 coffee images and 493 other trees due to the lack of publicly available datasets to detect and classify the coffee tree, the images used in this work were collected from different regions of the Yemeni environment. Coffee trees and other trees were collected from the city of Taiz, from Al-Mawasit department, from several orchards from the region of Bani Hammad, from Wadi Balabil and Al- Ghayl, as well as from several valleys in the region of Joreenat and Al-Zeila. We collected RGB images of coffee tree and other types of trees. We used a similar standard (Rodrguez et al., 2020). Which are captured directly in place by midrange phone Samsung J1 to capture the images (3 Megapixels resolution, focus of f/2,2, sRGB color JPG format 1536 × 2560 and 1920 × 1920 pixels). The pictures were taken at different distances in different lighting conditions. Other images obtained from Google Image search with different format. We collected and stored them in dataset called (Coffee Tree Dataset). We collected and stored them in dataset called (Coffee Tree Dataset). Combined in these ways in order to remove complexity for researchers and agricultural engineers. As shown in Fig. 2. Fig. 1. Proposed System. https://doi.org/10.34010/injiiscom.v3i2.9504 235 | International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Fig. 2. Coffee Tree Dataset. 2.2. Images Pre-Processing The collected images of coffee trees and other trees used in this study are of different sizes, as shown in Fig 3. Thus, the first step We divided the data as follows: 60% for training, 20% for cross validation, and 20% for testing. When training the network, the input picture size is diversified, so that the network has better generalization (Zheng et al., 2019). All of these transformations are contained within the ImageDataGenerator. This function takes an image as input It. Then, it uses a set of transformations such as increasing or decreasing brightness, flipping the image vertically or horizontally, rotating the image, shifting pixels. We processed these images, We used the rotation range=4, validation split = 0.20, rescale=1/255, width shift range=0.5, height shift range=0.5,shear range=0.10, zoom range=0.10,horizontal flip=True and fill mode=”nearest”. The second step we converted all of the images to the size of (100 ×100 × 3 pixels). (See Fig 4). https://doi.org/10.34010/injiiscom.v3i2.9504 Ahmed Abdulsalam Naji Hasan. Coffee Tree Detection Using Convolutional…| 236 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Fig. 3 Images before preprocessing Fig. 4 Images after preprocessing 2.3. CNN Classifier A deep convolutional neural network has become the dominating approach for image classification. Year after year, various new architectures have been proposed. However, when choosing a deep architecture to solve a realistic problem, some aspects should be taken into consideration such as the type or number of layers, as a higher number of parameters increases the complexity of the system and directly influences the memory computation, speed and results of the system. Although with specific characteristics according to realistic applications, a deep-learning network has the same goal to increase accuracy while reducing operation time and computational complexity. Therefore, this study selected modern deep learning architecture. A model is proposed to detect and classify coffee tree among different trees. trees grading by human is inefficient, labor intensive (see Fig. 4). From the equation shown in Fig. 5, we used "Adam" optimizer, we trained the model. During the training process, the model stopped at epoch=8. We noticed the model achieved better speed and good results. It achieved an accuracy 0.97% and an error rate of 0.04% is small, although the images were complex. https://doi.org/10.34010/injiiscom.v3i2.9504 237 | International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Fig. 5 Equation for CNN Classifier 3. TESTING OF MODEL We used 20% from coffee dataset a cross- validation as an initial stage to evaluation the performance of the model and adjust some parameters after completing the training process for the model and to get good results. We tested the model, we used 20% from dataset. The model achieved an accuracy 0.75%, error rate 0.17% good results as long as the data is few, new and contains different characteristics compared to the training sample. We used a new data sample that had not been previously trained to test the model. Fig. 4 CNN Classifier After finishing we found that the model achieved better results. We also made predictions for two images one of the coffee tree images and one's unknown image, the images contain noise when looked at the images cannot be classified in a human way the two images have been uploaded to the model Then we looked at the results we found the model correctly classified the images. https://doi.org/10.34010/injiiscom.v3i2.9504 Ahmed Abdulsalam Naji Hasan. Coffee Tree Detection Using Convolutional…| 238 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 4. RESULTS Through experiences we believe these results are satisfactory when visualized data with similar characteristics are considered, images inputs which were more contain noise. As well as the image taken of the coffee tree adjacent to other trees. Despite these limitations, we achieved excellent results. We achieved 0.97% accuracy, precision 0.98%, recall 0.95% and the error rate very low 0.08%. 5. CONCLUSIONS In this study, we proposed a new and fast technique to detect and classify the coffee tree. This study provided a dataset of coffee trees, this study proved that using the machine learning algorithm, the Convolutional Neural Network (CNN) is able to detect and classify the coffee tree from images. Convolutional layers can extract different abstract level features for a classification. We got an average accuracy 0.97%, an average error 0.04%. These results which achieved by the CNN algorithm are the best is very close to the features of manual measurement and visual inspection. This study can be relied upon instead of the traditional methods in detecting and classifying the coffee tree as well as other trees. REFERENCES Al-Zaidi, A. A., Baig, M. B., Shalaby, M. Y., & Hazber, A. (2016). Level of knowledge and its application by coffee farmers in the Udeen Area, Governorate of Ibb – Republic of Yemen. The Journal of Animal and Plant Sciences, 26, 1797-1804. Amamo, A. A. (2014). Coffee production and marketing in Ethiopia. Eur J Bus Manag, 6(37), 109-22Essien, E. R., Atasie, V. N., Okeafor, A. O., & Nwude, D. O. (2020). Biogenic synthesis of magnesium oxide nanoparticles using Manihot esculenta (Crantz) leaf extract. International Nano Letters, 10(1), pp. 43-48. Chandra, A. L., Desai, S. V., Guo, W., & Balasubramanian, V. N. (2020). Computer vision with deep learning for plant phenotyping in agriculture: A survey. arXiv preprint arXiv:2006.11391. Clarence-Smith, W. G., & Topik, S. (Eds.). (2003). The global coffee economy in Africa, Asia, and Latin America, 1500–1989. Cambridge University Press. Diez, Y., Kentsch, S., Fukuda, M., Caceres, M. L. L., Moritake, K., & Cabezas, M. (2021). Deep learning in forestry using uav-acquired rgb data: A practical review. Remote Sensing,13(14), 2837. Fan, Z., Lu, J., Gong, M., Xie, H., & Goodman, E. D. (2018). Automatic tobacco plant detection in UAV images via deep neural networks. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing,11(3), 876-887. https://doi.org/10.34010/injiiscom.v3i2.9504 239 | International Journal of Informatics Information System and Computer Engineering 3(2) (2022) 231-240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Gurumurthy, V. A., Kestur, R., & Narasipura, O. (2019). Mango Tree Net–A fully convolutional network for semantic segmentation and individual crown detection of mango trees.arXiv preprint arXiv:1907.06915. INCOMES, S. I., & TRADE, E. (2005). MOVING YEMEN COFFEE FORWARD. Karayigit, R., Naderi, A., Akca, F., Cruz, C. J. G. D., Sarshin, A., Yasli, B. C., ... & Kaviani, M. (2021). Effects of Different Doses of Caffeinated Coffee on Muscular Endurance, Cognitive Performance, and Cardiac Autonomic Modulation in Caffeine Naive Female Athletes. Nutrients, 13(1),2. Kolb, H., Kempf, K., & Martin, S. (2020). Health effects of coffee: Mechanism unraveled?. Nutrients, 12(6), 1842. Nagpal, I. (2014). Can Milk, Coffee and Tea Prevent Dental Caries?. INTERNATIONAL JOURNAL, 1(4), 129. Nieber, K. (2017). The impact of coffee on health. Planta medica, 83(16), 1256-1263. Priya, S. L., Jagannathan, R., Balaji, T. M., Varadarajan, S., Venkatakrishnan, C., Rajendran, S., ...\& Devi, S. (2020). Resveratrol and green coffee extract gel as anticaries agent. Indian J. Res. Pharm. Biotechnol, 8, 15-21. Rodrguez, J. P., Corrales, D. C., Aubertot, J. N., & Corrales, J. C. (2020). A computer vision system for automatic cherry beans detection on coffee trees.Pattern Recognition Letters,136, 142-153. Santana, L. S., Santos, G. H. R. D., Bento, N. L., Faria, R. D. O. (2023). Identification and Counting of Coffee Trees Based on Convolutional Neural Network Applied to RGB Images Obtained by RPA. Sustainability, 15(1), 820. Sk, Rakibul, and Ankita Wadhawan. ”Identification of Plants using Deep learning: A.” (2021). Sun, Y., Liu, Y., Wang, G., & Zhang, H. (2017). Deep learning for plant identification in natural environment. Computational intelligence and neuroscience, 2017. Wu, J., Yang, G., Yang, H., Zhu, Y., Li, Z., Lei, L., & Zhao, C. (2020). Extracting apple tree crown information from remote imagery using deep learning. Computers and Electronics in Agriculture,174, 105504. Zheng, Y. Y., Kong, J. L., Jin, X. B., Wang, X. Y., Su, T. L., & Zuo, M. (2019). CropDeep: the crop vision dataset for deep-learning-based classification and detection in precision agriculture. Sensors, 19(5), 1058. https://doi.org/10.34010/injiiscom.v3i2.9504 Ahmed Abdulsalam Naji Hasan. Coffee Tree Detection Using Convolutional…| 240 DOI: https://doi.org/10.34010/injiiscom.v3i2.9504 p-ISSN 2810-0670 e-ISSN 2775-5584 Zheng, Y. Y., Kong, J. L., Jin, X. B., Wang, X. Y., Su, T. L., & Zuo, M. (2019). CropDeep: the crop vision dataset for deep-learning-based classification and detection in precision agriculture. Sensors, 19(5), 1058. Zortea, M., Macedo, M. M., Mattos, A. B., Ruga, B. C., & Gemignani, B. H. (2018, October). Automatic citrus tree detection from UAV images based on convolutional neural networks. In2018 31th SIBGRAPI Conference on Graphics, Patterns and Images (SIBGRAPI)(Vol. 11). https://doi.org/10.34010/injiiscom.v3i2.9504