International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 1 Classification of Apple Fruits by Deep Learning Mohammed O. Al-Shawwa and Samy S. Abu-Naser Department of Information Technology, Faculty of Engineering and Information Technology, Al-Azhar University Gaza, Palestine Abstract: Apple is a plant species that follows the apple genus, which is a fruit because it contains seeds of the pink family. It is one of the most fruit trees in terms of agriculture. The apple tree is small in length from 3 to 12 meters. Several recent studies have shown many health benefits of apples. It helps with the strengthening of the brain, heart, and stomach. It is used in the treatment of joint pain and limberness. It is opposite. It stops vomiting. It goes to dyspnea. It corrects the liver, purifies the blood of toxins, strengthens the heart muscle, and kills the abdominal dentures. Which are richer in cell nutrition and development, bone strengthening and neuronal regeneration is an important source of detoxification, viruses, bacteria, and microbes in the body. In this paper, machine learning based approach is presented for identifying type of Apple with a dataset that contains 8,554 images. We used 4,488 images for training, 1,928 images for validation and 2,138 images for testing. A deep learning technique that extensively applied to image recognition was used. 70% from images were used for training and 30% from image for validation. Our trained model achieved an accuracy of 100% on a held-out test set, demonstrating the feasibility of this approach. Keywords: Type of Apple, Deep Learning, Classification, Detection. INTRODUCTION Apples are rich in vitamins A, B, C, and sugary substances, protein, fatty substances, organic acids and mineral salts such as potassium, calcium, sodium and others [1]. Apple benefits are:  Good for Weight Loss Apples are high in fiber and water - two qualities that make them filling. In one study, people who ate apple slices before a meal felt fuller than those who consumed applesauce, apple juice, or no apple products. In the same study, those who started their meal with apple slices also ate an average of 200 fewer calories than those who didn't [2].  Good for Your Heart Apples have been linked to a lower risk of heart disease. One reason may be that apples contain soluble fiber the kind that can help lower your blood cholesterol levels. They also contain polyphenols, which have antioxidant effects. Many of these are concentrated in the peel [1]. One of these polyphenols is the flavonoid epicatechin, which may lower blood pressure. An analysis of studies found that high intakes of flavonoids were linked to a 20% lower risk of stroke [1].  Promote Good Gut Bacteria Apples contain pectin, a type of fiber that acts as a prebiotic. This means it feeds the good bacteria in your gut. Your small intestine doesn't absorb fiber during digestion. Instead, it goes to your colon, where it can promote the growth of good bacteria. It also turns into other helpful compounds that circulate back through your body. New research suggests that this may be the reason behind some of the protective effects of apples against obesity, type 2 diabetes, and heart disease [1].   Help Prevent Cancer Test-tube studies have shown a link between plant compounds in apples and a lower risk of cancer. Additionally, one study in women reported that eating apples was linked to lower rates of death from cancer. Scientists believe that their antioxidant and anti-inflammatory effects may be responsible for their potential cancerInternational Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 2 preventive effects [1].  Help Fight Asthma Antioxidant-rich apples may help protect your lungs from oxidative damage. A large study in more than 68,000 women found that those who ate the most apples had the lowest risk of asthma. Eating about 15% of a large apple per day was linked to a 10% lower risk of this condition. Apple skin contains the flavonoid quercetin, which can help regulate the immune system and reduce inflammation. These are two ways in which it may affect asthma and allergic reactions [1].  Good for Bone Health Eating fruit is linked to higher bone density, which is a marker of bone health. Researchers believe that the antioxidant and anti-inflammatory compounds in fruit may help promote bone density and strength. Some studies show that apples, specifically, may positively affect bone health. In one study, women ate a meal that either included fresh apples, peeled apples, applesauce, or no apple products. Those who ate apples lost less calcium from their bodies than the control group [1]. Deep Learning is an Artificial Intelligence (AI) subfield that imitates the works of a human brain in processing data and producing patterns for use in decision making. Deep learning is a subset of machine learning in artificial intelligence that has networks the skills of learning from data that is unlabeled or unstructured. In this work, we show that a Deep Convolutional Neural Network (CNN) does well in classifying apple type. In computer vision, CNNs have been known to be powerful visual models that yield hierarchies of features enabling accurate segmentation. They are also known to perform predictions relatively faster than other algorithms while maintaining competitive performance at the same time [5]. DEEP LEARNING Deep learning (also known as deep structured learning or hierarchical learning) is part of a broader family of machine learning methods based on learning data representations, as opposed to task-specific algorithms. Learning can be supervised, semisupervised or unsupervised [2]-[3]. In deep learning, each level learns to transform its input data into a slightly more abstract and composite representation. In an image recognition application, the raw input may be a matrix of pixels; the first representational layer may abstract the pixels and encode edges; the second layer may compose and encode arrangements of edges; the third layer may encode a nose and eyes; and the fourth layer may recognize that the image contains a face. Importantly, a deep learning process can learn which features to optimally place in which level on its own. (Of course, this does not completely obviate the need for hand-tuning; for example, varying numbers of layers and layer sizes can provide different degrees of abstraction) [2],[4]. Figure 1: Dataset Samples CONVOLUTIONAL NUERUAL NETWORK International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 3 In deep learning, a convolutional neural network (CNN, or ConvNet) is a class of deep neural networks, most commonly applied to analyzing visual imagery. CNNs use a variation of multilayer perceptron's designed to require minimal preprocessing. They are also known as shift invariant or Space Invariant Artificial Neural Networks (SIANN), based on their shared-weights architecture and translation invariance characteristics [6]. TYPES OF MACHINE LEARNING ALGORITHMS There some variations of how to define the types of Machine Learning Algorithms but commonly they can be divided into categories according to their purpose and the main categories are the following [7]:  Supervised learning Supervised learning is a learning model built to make prediction, given an unforeseen input instance. A supervised learning algorithm takes a known set of input dataset and its known responses to the data (output) to learn the regression/classification model. A learning algorithm then trains a model to generate a prediction for the response to new data or the test dataset [8]. Figure 1: Supervised Learning  Unsupervised Learning Unsupervised learning is the training of an Artificial Intelligence (AI) algorithm using information that is neither classified nor labeled and allowing the algorithm to act on that information without guidance[9-10]. An AI system may group unsorted information according to similarities and differences even though there are no categories provided. AI systems capable of unsupervised learning are often associated with generative learning models, although they may also use a retrieval-based approach (which is most often associated with supervised learning). Chatbots, self-driving cars, facial recognition programs, expert systems and robots are among the systems that may use either supervised or unsupervised learning approaches. [11-13]. International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 4 Figure 2: Unsupervised Learning STUDY OBJECTIVES 1Demonstrating the feasibility of using deep convolutional neural networks to classify Type Apple. 2Developing a model that can be used by developer to create smartphones application or web site to detect Type Apple. DATASET The dataset used, provided by Kaggle, contains a set of 8,554 images use 4,488 images for training, 1,928 images for validation and 2,138 images for testing belonging to 13 species from apple. See Fig. 3 for types apple. International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 5 Figure 3: Dataset Samples The output 13 classes as follow:  class (0): Apple Braeburn.  class (1): Apple Crimson Snow.  class (2): Apple Golden 1.  class (3): Apple Golden 2.  class (4): Apple Golden 3.  class (5): Apple Granny Smith.  class (6): Apple Pink Lady.  class (7): Apple Red 1.  class (8): Apple Red 2.  class (9): Apple Red 3.  class (10): Apple Red Delicious.  class (11): Apple Red Yellow 1.  class (12): Apple Red Yellow 2. The images were resized into 150×150 for faster computations but without compromising the quality of the data. METHODOLOGY In this section we describe the proposed solution as selected convolutional network (ConvNet) architecture and discuss associated design choices and implementation aspects. MODEL Our model takes raw images as an input, so we used Convolutional Neural Networks (CNNs) to extract features, in result the model would consist from (features extraction), which was the same for full-color approach and gray-scale approach, it consist of 4 Convolutional layers with Relu activation function, each followed by Max Pooling layer. Layer (type) Output Shape Param # conv2d_5 (Conv2D) (None, 148, 148, 32) 896 max_pooling2d_5 (MaxPooling2) (None, 74, 74, 32) 0 conv2d_6 (Conv2D) (None, 72, 72, 64) 18496 max_pooling2d_6 (MaxPooling2) (None, 36, 36, 64) 0 conv2d_7 (Conv2D) (None, 34, 34, 128) 73856 max_pooling2d_7 (MaxPooling2) (None, 17, 17, 128) 0 conv2d_8 (Conv2D) (None, 15, 15, 128) 147584 max_pooling2d_8 (MaxPooling2) (None, 7, 7, 128) 0 flatten_2 (Flatten) (None, 6272) 0 dropout_2 (Dropout) (None, 6272) 0 International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 6 dense_3 (Dense) (None, 512) 3211776 dense_4 (Dense) (None, 13) 6669 SYSTEM EVALUATION We used the original apples dataset that consists of 6,416 images after resizing the images to 150x150 pixels. We divided the data into training (70%), validation (30%). The training accuracy was 99.99% and the validation accuracy was 100%. Figure 4: Training and validation accuracy and loss CONCLUSION We proposed a solution to help people determine the type of apples more accurately. We got 100% accuracy for our best model. We built a model using deep learning convolutional neural networks and uses this model to predict the type of (previously unseen) images of apple with a network from 4 layers and a dropout of 0.2, that takes apple images with 13 different species an input. References 1. Bengio, Y.; Courville, A.; Vincent, P. (2013). "Representation Learning: A Review and New Perspectives". IEEE Transactions on Pattern Analysis and Machine Intelligence. 35 (8): 1798–1828. 2. Bengio, Yoshua; LeCun, Yann; Hinton, Geoffrey (2015). "Deep Learning". Nature. 521 (7553). 3. Werbos, P.J. (1975). Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences. 4. https://towardsdatascience.com/types-of-machine-learning-algorithms-you-should-know-953a08248861 5. https://www.sciencedirect.com/topics/computer-science/supervised-learning 6. https://whatis.techtarget.com/definition/unsupervised-learning 7. Deng, Li, and Dong Yu. "Deep learning: methods and applications." Foundations and Trends® in Signal Processing 7.3–4 (2014): 197-387. 8. Liu, Ziwei, Ping Luo, Xiaogang Wang, and Xiaoou Tang. "Deep learning face attributes in the wild." In Proceedings of the IEEE international conference on computer vision, pp. 3730-3738. 2015. 9. Bengio, Yoshua. "Deep learning of representations for unsupervised and transfer learning." In Proceedings of ICML workshop on unsupervised and transfer learning, pp. 17-36. 2012. International Journal of Academic Engineering Research (IJAER) ISSN: 2643-9085 Vol. 3 Issue 12, December – 2019, Pages: 1-7 www.ijeais.org/ijaer 7 10. Chen, Yushi, Zhouhan Lin, Xing Zhao, Gang Wang, and Yanfeng Gu. "Deep learning-based classification of hyperspectral data." IEEE Journal of Selected topics in applied earth observations and remote sensing 7, no. 6 (2014): 2094-2107. 11. Papernot, N., McDaniel, P., Jha, S., Fredrikson, M., Celik, Z. B., & Swami, A. (2016, March). The limitations of deep learning in adversarial settings. In 2016 IEEE European Symposium on Security and Privacy (EuroS&P) (pp. 372-387). IEEE. 12. Lee, Honglak, Peter Pham, Yan Largman, and Andrew Y. Ng. "Unsupervised feature learning for audio classification using convolutional deep belief networks." In Advances in neural information processing systems, pp. 1096-1104. 2009. 13. Huang, Po-Sen, Xiaodong He, Jianfeng Gao, Li Deng, Alex Acero, and Larry Heck. "Learning deep structured semantic models for web search using clickthrough data." In Proceedings of the 22nd ACM international conference on Information & Knowledge Management, pp. 2333-2338. ACM, 2013.