Skip to main content
Log in

Classification of pistachios with deep learning and assessing the effect of various datasets on accuracy

  • Original Paper
  • Published:
Journal of Food Measurement and Characterization Aims and scope Submit manuscript

Abstract

Pistachio is a healthy and delicious snack with high economic value, especially when product consists of only open pistachios. For this reason, many studies have been carried out in the literature to classify Pistachio according to whether they are open or closed. In this study, the classification process of pistachios was carried out according to whether they are open or closed using deep learning techniques. The prominent aspect of the study is that the datasets obtained with an industrial experimental set-up are used in the training of the network in order to be suitable for industrial applications and to classify it with high accuracy. In this study, AlexNet and Inception V3 structure were trained and tested with this industrial data set, the test accuracy was calculated as 96.13% and 96.54%, respectively. In order to compare the industrial data set and the desktop data set, both data sets were created. As a result of training and testing the AlexNet structure with this desktop data set, the test accuracy was calculated as 100%. When the test images from industrial dataset are fed to the network structure trained with the desktop dataset, the test accuracy was obtained as 61.75%. On the contrary, when desktop data set is fed to Alexnet structure trained with industrial data set, test accuracy is calculated as 99.84%. This clearly demonstrates how accurately the industrial dataset performs in industrial classification applications, while the desktop dataset has poor accuracy in industrial applications.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9

Similar content being viewed by others

Availability of data and materials

Relevant data is available from the corresponding author.

Code availability

Relevant code is available from the corresponding author.

References

  1. S.L. Tey, R. Brown, A. Gray, A. Chisholm, C. Delahunty, Nuts improve diet quality compared to other energy-dense snacks while maintaining body weight. J. Nutr. Metab. 2011, 1–11 (2011). https://doi.org/10.1155/2011/357350

    Article  Google Scholar 

  2. E. Aşkan, Economic analysis and marketing margin of pistachios in turkey. Bull. Natl. Res. Centre 43(1), 1–7 (2019). https://doi.org/10.1186/s42269-019-0216-5

    Article  Google Scholar 

  3. Y.E. Ertürk, M.K. Geçer, E. Gülsoy, S. Yalçin, Antepfıstığı üretimi ve pazarlaması. Iğdır Üniversitesi Fen Bilimleri Enstitüsü Dergisi 5(2), 43–62 (2015)

    Google Scholar 

  4. K. Bellitürk, M. Kuzucu, M.F. Baran, A. Çelik, Kuru koşullarda gübrelemenin verim ve kaliteye etkileri (2019). https://doi.org/10.33462/jotaf.534476

  5. FAOSTAT. https://www.fao.org/faostat/en/ Accessed 27 Oct 2021

  6. ITC. https://www.trademap.org/ Accessed 27 Oct 2021

  7. T.C. Pearson, M.A. Doster, T.J. Michailides, Automated detection of pistachio defects by machine vision. Appl. Eng. Agric. 17(5), 729 (2001). https://doi.org/10.13031/2013.6905

    Article  Google Scholar 

  8. A.E. Cetin, T.C. Pearson, A.H. Tewfik, Classification of closed-and open-shell pistachio nuts using voice-recognition technology. Trans. ASAE 47(2), 659–664 (2004). https://doi.org/10.13031/2013.16029

    Article  Google Scholar 

  9. A. Mahmoudi, M. Omid, A. Aghagolzadeh, A.M. Borgayee, Grading of iranian’s export pistachio nuts based on artificial neural networks. Int. J. Agric. Biol. 8(3), 371–376 (2006)

    Google Scholar 

  10. M. Omid, A. Mahmoudi, M.H. Omid, An intelligent system for sorting pistachio nut varieties. Expert Syst. Appl. 36(9), 11528–11535 (2009). https://doi.org/10.1016/j.eswa.2009.03.040

    Article  Google Scholar 

  11. M. Omid, Design of an expert system for sorting pistachio nuts through decision tree and fuzzy logic classifier. Expert Syst. Appl. 38(4), 4339–4347 (2011). https://doi.org/10.1016/j.eswa.2010.09.103

    Article  Google Scholar 

  12. M. Farhadi, Y. Abbaspour-Gilandeh, A. Mahmoudi, J.M. Maja, An integrated system of artificial intelligence and signal processing techniques for the sorting and grading of nuts. Appl. Sci. 10(9), 3315 (2020). https://doi.org/10.3390/app10093315

    Article  CAS  Google Scholar 

  13. M.A. Ghazanfari, Machine vision classification of pistachio nuts using pattern recognition and neural networks. Doctoral dissertation, University of Saskatchewan (1996)

  14. M. Yaqoob, S. Sharma, P. Aggarwal, Imaging techniques in agro-industry and their applications, a review. J. Food Meas. Charact. 15(3), 2329–2343 (2021). https://doi.org/10.1007/s11694-021-00809-w

    Article  Google Scholar 

  15. A. Ghazanfari, J. Irudayaraj, A. Kusalik, M. Romaniuk, Machine vision grading of pistachio nuts using fourier descriptors. J. Agric. Eng. Res. 68(3), 247–252 (1997). https://doi.org/10.1006/jaer.1997.0205

    Article  Google Scholar 

  16. K. Sabanci, M. Koklu, M.F. Unlersen, Classification of Siirt and long type pistachios (Pstacia vera L.) by artificial neural networks. Int. J. Intell. Syst. Appl. Eng. 3(2), 86 (2015). https://doi.org/10.18201/ijisae.74573

    Article  Google Scholar 

  17. R.P. Haff, T. Pearson, Spectral band selection for optical sorting of pistachio nut defects. Trans. ASABE 49(4), 1105–1113 (2006). https://doi.org/10.13031/2013.21716

    Article  Google Scholar 

  18. H. Nouri-Ahmadabadi, M. Omid, S.S. Mohtasebi, M.S. Firouz, Design, development and evaluation of an online grading system for peeled pistachios equipped with machine vision technology and support vector machine. Inf. Process. Agric. 4(4), 333–341 (2017). https://doi.org/10.1016/j.inpa.2017.06.002

    Article  Google Scholar 

  19. J. Ghezelbash, A.M. Borghaee, S. Minaei, S. Fazli, M. Moradi, Design and implementation of a low cost computer vision system for sorting of closed-shell pistachio nuts. Afr. J. Agric. Res. 8(49), 6479–6484 (2013)

    Google Scholar 

  20. M. Esteki, P. Ahmadi, Y.V. Heyden, J. Simal-Gandara, Fatty acids-based quality index to differentiate worldwide commercial pistachio cultivars. Molecules 24(1), 58 (2018). https://doi.org/10.3390/molecules24010058

    Article  CAS  PubMed Central  Google Scholar 

  21. A. Onay, E. Tilkat, Y. Ersalı, E.A. Tilkat, V. Süzerer, Antepfıstığının (Pistacia vera L.) morfolojik ve biyolojik özellikleri ile verimini etkileyen faktörler. Batman Univ. J. Life Sci. 2(1), 116–131 (2012)

    Google Scholar 

  22. M. Kottek, J. Grieser, C. Beck, B. Rudolf, F. Rubel, World map of the köppen-geiger climate classification updated 15(3), 259–263 (2006). https://doi.org/10.1127/0941-2948/2006/0130

  23. Global Historical Weather and Climate Data|Weather and Climate. https://tcktcktck.org/ Accessed 27 Oct 2021

  24. TÜİK Kurumsal. https://data.tuik.gov.tr/Bulten/Index?p=Crop-Production-2020-33737 Accessed 28 Oct 2021

  25. M.A. Yavuz, H. Yıldırım, A. Onay, Dünya antepfıstığı üretiminde son on yılın değerlendirilmesi. Batman Univ. J. Life Sci. 62(2/2), 22–31 (2016)

    Google Scholar 

  26. E.C. Tetila, B.B. Machado, G. Astolfi, N.A. de Souza Belete, W.P. Amorim, A.R. Roel, H. Pistori, Detection and classification of soybean pests using deep learning with UAV images. Comput. Electron. Agric. 179, 105836 (2020). https://doi.org/10.1016/j.compag.2020.105836

    Article  Google Scholar 

  27. Z. Unal, Smart farming becomes even smarter with deep learning—a bibliographical analysis. IEEE Access 8, 105587–105609 (2020). https://doi.org/10.1109/access.2020.3000175

    Article  Google Scholar 

  28. A.S.M.M. Hasan, F. Sohel, D. Diepeveen, H. Laga, M.G.K. Jones, A survey of deep learning techniques for weed detection from images. Comput. Electron. Agric. 184, 106067 (2021). https://doi.org/10.1016/j.compag.2021.106067

    Article  Google Scholar 

  29. J. Dyson, A. Mancini, E. Frontoni, P. Zingaretti, Deep learning for soil and crop segmentation from remotely sensed data. Remote Sens. 11(16), 1859 (2019). https://doi.org/10.3390/rs11161859

    Article  Google Scholar 

  30. P. Nevavuori, N. Narra, T. Lipping, Crop yield prediction with deep convolutional neural networks. Comput. Electron. Agric. 163, 104859 (2019). https://doi.org/10.1016/j.compag.2019.104859

    Article  Google Scholar 

  31. A. Fuentes, S. Yoon, S. Kim, D. Park, A robust deep-learning-based detector for real-time tomato plant diseases and pests recognition. Sensors 17(9), 2022 (2017). https://doi.org/10.3390/s17092022

    Article  PubMed Central  Google Scholar 

  32. H. Lin, G. Zhou, A. Chen, J. Li, M. Li, W. Zhang, Y. Hu, W.T. Yu, Em-ernet for image-based banana disease recognition. J. Food Meas. Charact. 15(5), 4696–4710 (2021). https://doi.org/10.1007/s11694-021-01043-0

    Article  Google Scholar 

  33. S. Coulibaly, B. Kamsu-Foguem, D. Kamissoko, D. Traore, Deep neural networks with transfer learning in millet crop images. Comput. Ind. 108, 115–120 (2019). https://doi.org/10.1016/j.compind.2019.02.003

    Article  Google Scholar 

  34. X. Song, G. Zhang, F. Liu, D. Li, Y. Zhao, J. Yang, Modeling spatio-temporal distribution of soil moisture by deep learning-based cellular automata model. J. Arid Land 8(5), 734–748 (2016). https://doi.org/10.1007/s40333-016-0049-0

    Article  Google Scholar 

  35. M.S. Sirsat, E. Cernadas, M. Fernández-Delgado, S. Barro, Automatic prediction of village-wise soil fertility for several nutrients in india using a wide range of regression methods. Comput. Electron. Agric. 154, 120–133 (2018). https://doi.org/10.1016/j.compag.2018.08.003

    Article  Google Scholar 

  36. J. Kvam, J. Kongsro, In vivo prediction of intramuscular fat using ultrasound and deep learning. Comput. Electron. Agric. 142, 521–523 (2017). https://doi.org/10.1016/j.compag.2017.11.020

    Article  Google Scholar 

  37. S. Yukun, H. Pengju, W. Yujie, C. Ziqi, L. Yang, D. Baisheng, L. Runze, Z. Yonggen, Automatic monitoring system for individual dairy cows based on a deep learning framework that provides identification via body parts and estimation of body condition score. J. Dairy Sci. 102(11), 10140–10151 (2019). https://doi.org/10.3168/jds.2018-16164

    Article  CAS  PubMed  Google Scholar 

  38. Y. Zhang, J. Cai, D. Xiao, Z. Li, B. Xiong, Real-time sow behavior detection based on deep learning. Comput. Electron. Agric. 163, 104884 (2019). https://doi.org/10.1016/j.compag.2019.104884

    Article  Google Scholar 

  39. B. Veeramani, J.W. Raymond, P. Chanda, DeepSort: deep convolutional networks for sorting haploid maize seeds. BMC Bioinform. 19(S9), 104884 (2018). https://doi.org/10.1186/s12859-018-2267-2

    Article  CAS  Google Scholar 

  40. X. Meng, Y. Yuan, G. Teng, T. Liu, Deep learning for fine-grained classification of jujube fruit in the natural environment. J. Food Meas. Charact. 15(5), 4150–4165 (2021). https://doi.org/10.1007/s11694-021-00990-y

    Article  Google Scholar 

  41. J.F. Knoll, V. Czymmek, S. Poczihoski, T. Holtorf, S. Hussmann, Improving efficiency of organic farming by using a deep learning classification approach. Comput. Electron. Agric. 153, 347–356 (2018). https://doi.org/10.1016/j.compag.2018.08.032

    Article  Google Scholar 

  42. J. Zhang, L. Dai, F. Cheng, Corn seed variety classification based on hyperspectral reflectance imaging and deep neural network. J. Food Meas. Charact. 15(1), 484–494 (2020). https://doi.org/10.1007/s11694-020-00646-3

    Article  Google Scholar 

  43. W. Ding, G. Taylor, Automatic moth detection from trap images for pest management. Comput. Electron. Agric. 123, 17–28 (2016). https://doi.org/10.1016/j.compag.2016.02.003

    Article  Google Scholar 

  44. T. Kounalakis, G.A. Triantafyllidis, L. Nalpantidis, Deep learning-based visual recognition of rumex for robotic precision farming. Comput. Electron. Agric. 165, 104973 (2019). https://doi.org/10.1016/j.compag.2019.104973

    Article  Google Scholar 

  45. V. Partel, S.C. Kakarla, Y. Ampatzidis, Development and evaluation of a low-cost and smart technology for precision weed management utilizing artificial intelligence. Comput. Electron. Agric. 157, 339–350 (2019). https://doi.org/10.1016/j.compag.2018.12.048

    Article  Google Scholar 

  46. P. Christiansen, L. Nielsen, K. Steen, R. Jørgensen, H. Karstoft, DeepAnomaly: combining background subtraction and deep learning for detecting obstacles and anomalies in an agricultural field. Sensors 16(11), 1904 (2016). https://doi.org/10.3390/s16111904

    Article  PubMed Central  Google Scholar 

  47. D. Rong, L. Xie, Y. Ying, Computer vision detection of foreign objects in walnuts using deep learning. Comput. Electron. Agric. 162, 1001–1010 (2019). https://doi.org/10.1016/j.compag.2019.05.019

    Article  Google Scholar 

  48. F. Kurtulmuş, Identification of sunflower seeds with deep convolutional neural networks. J. Food Meas. Charact. 15(2), 1024–1033 (2020). https://doi.org/10.1007/s11694-020-00707-7

    Article  Google Scholar 

  49. Y. Ampatzidis, V. Partel, B. Meyering, U. Albrecht, Citrus rootstock evaluation utilizing UAV-based remote sensing and artificial intelligence. Comput. Electron. Agric. 164, 104900 (2019). https://doi.org/10.1016/j.compag.2019.104900

    Article  Google Scholar 

  50. J. Ni, J. Gao, J. Li, H. Yang, Z. Hao, Z. Han, E-AlexNet: quality evaluation of strawberry based on machine learning. J. Food Meas. Charact. 15(5), 4530–4541 (2021). https://doi.org/10.1007/s11694-021-01010-9

    Article  Google Scholar 

  51. M.N. Örnek, H. Kahramanlı, Developing a deep neural network model for predicting carrots volume. J. Food Meas. Charact. 15(4), 3471–3479 (2021). https://doi.org/10.1007/s11694-021-00923-9

    Article  Google Scholar 

  52. B. Cho, K. Koyama, S. Koseki, Determination of ‘hass’ avocado ripeness during storage by a smartphone camera using artificial neural network and support vector regression. J. Food Meas. Charact. 15(2), 2021–2030 (2021). https://doi.org/10.1007/s11694-020-00793-7

    Article  Google Scholar 

  53. M.L. Smith, L.N. Smith, M.F. Hansen, The quiet revolution in machine vision—a state-of-the-art survey paper, including historical review, perspectives, and future directions. Comput. Ind. 130, 103472 (2021). https://doi.org/10.1016/j.compind.2021.103472

    Article  Google Scholar 

  54. A. Krizhevsky, I. Sutskever, G.E. Hinton, ImageNet classification with deep convolutional neural networks. Adv. Neural Inf. Process. Syst. 60(6), 84–90 (2017). https://doi.org/10.1145/3065386

    Article  Google Scholar 

  55. J. Dean, D. Patterson, C. Young, A new golden age in computer architecture: empowering the machine-learning revolution. IEEE Micro 38(2), 21–29 (2018). https://doi.org/10.1109/mm.2018.112130030

    Article  Google Scholar 

  56. K. Simonyan, A. Zisserman, Very deep convolutional networks for large-scale image recognition. in 3rd International Conference on Learning Representations, ed. Y. Bengio, Y. LeCun, ICLR 2015, San Diego, CA, USA, May 7–9, 2015. http://arxiv.org/abs/1409.1556

  57. K. He, X. Zhang, S. Ren, J. Sun, Identity mappings in deep residual networks, (Springer, 2016), pp. 630–645. https://doi.org/10.1007/978-3-319-46493-0_38

  58. C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, Z. Wojna, Rethinking the inception architecture for computer vision. IEEE (2016). https://doi.org/10.1109/cvpr.2016.308

    Article  Google Scholar 

  59. F. Chollet, Xception: deep learning with depthwise separable convolutions. IEEE (2017). https://doi.org/10.1109/cvpr.2017.195

    Article  Google Scholar 

  60. H.K. Suh, J. Ijsselmuiden, J.W. Hofstee, E.J. van Henten, Transfer learning for the classification of sugar beet and volunteer potato under field conditions. Biosyst. Eng. 174, 50–65 (2018). https://doi.org/10.1016/j.biosystemseng.2018.06.017

    Article  Google Scholar 

  61. M. Dyrmann, H. Karstoft, H.S. Midtiby, Plant species classification using deep convolutional neural network. Biosyst. Eng. 151, 72–80 (2016). https://doi.org/10.1016/j.biosystemseng.2016.08.024

    Article  Google Scholar 

  62. K. Islam, R. Raj, Real-time (vision-based) road sign recognition using an artificial neural network. Sensors 17(4), 853 (2017). https://doi.org/10.3390/s17040853

    Article  PubMed Central  Google Scholar 

  63. J. Yang, P. Huang, F. Dai, Y. Sun, L. Wang, H. Bi, Application of deep learning in wood classification. IEEE (2019). https://doi.org/10.1109/csei47661.2019.8938960

    Article  Google Scholar 

  64. L. Isamail, N.L. Maskuri, N.J. Isip, S.F. Lokman, M.H. Abu Bakar, Deep neural network modeling for metallic component defects using the finite element model, (Springer, 2019), pp. 259–270. https://doi.org/10.1007/978-3-030-28505-0_23

  65. N. Silaparasetty, The tensorflow machine learning library. in Machine Learning Concepts with Python and the Jupyter Notebook Environment, pp. 149–171. Apress, (2020). https://doi.org/10.1007/978-1-4842-5967-2_8

  66. A. Loddo, M. Loddo, C.D. Ruberto, A novel deep learning based approach for seed image classification and retrieval. Comput. Electron. Agric. 187, 106269 (2021). https://doi.org/10.1016/j.compag.2021.106269

    Article  Google Scholar 

  67. A. Nasiri, A. Taheri-Garavand, Y.-D. Zhang, Image-based deep learning automated sorting of date fruit. Postharvest Biol. Technol. 153, 133–141 (2019). https://doi.org/10.1016/j.postharvbio.2019.04.003

    Article  Google Scholar 

  68. Y. Zhang, L. Li, M. Ripperger, J. Nicho, M. Veeraraghavan, A. Fumagalli, Gilbreth: a conveyor-belt based pick-and-sort industrial robotics application. in 2018 Second IEEE International Conference on Robotic Computing (IRC), pp. 17–24 (2018). https://doi.org/10.1109/IRC.2018.00012

  69. R. Pourdarbani, H.R. Ghassemzadeh, H. Seyedarabi, F.Z. Nahandi, M.M. Vahed, Study on an automatic sorting system for date fruits. J. Saudi Soc. Agric. Sci. 14(1), 83–90 (2015)

    Google Scholar 

  70. P. Chen, M. Gao, J. Huang, Y. Yang, Y. Zeng, High-speed color sorting algorithm based on fpga implementation. in 2018 IEEE 27th International Symposium on Industrial Electronics (ISIE), pp. 235–239 (2018). https://doi.org/10.1109/ISIE.2018.8433831

Download references

Acknowledgements

The authors are acknowledge and highly appreciated to Sedat Gökoğlu (Agriculture Enginner) from Gaziantep Provincial Directorate of Agriculture and Forestry Coordination Manager for his kind support, Mr. Mehmet Bostancı from Hacıbekiroğlu Food Ltd., and Haleplioğu Food Ltd. for providing pistachio samples.

Funding

No funding was received for conducting this study.

Author information

Authors and Affiliations

Authors

Contributions

All authors contributed to the study conception and design. Material preparation, data collection and analysis were performed by HA, TK and ZÜ. The first draft of the manuscript was written by HA and all authors commented on previous versions of the manuscript. All authors read and approved the final manuscript.

Corresponding author

Correspondence to Hakan Aktaş.

Ethics declarations

Conflict of interest

The authors have no competing interests to declare that are relevant to the content of this article. We warrant that the article is the Authors’ original work. We warrant that the article has not received prior publication and is not under consideration for publication elsewhere. On behalf of all Co-authors, the corresponding Author shall bear full responsibility for the submission.

Ethical approval

Not applicable

Consent to participate

Not applicable

Consent for publication

Not applicable

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Aktaş, H., Kızıldeniz, T. & Ünal, Z. Classification of pistachios with deep learning and assessing the effect of various datasets on accuracy. Food Measure 16, 1983–1996 (2022). https://doi.org/10.1007/s11694-022-01313-5

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11694-022-01313-5

Keywords

Navigation