Automated Gluten Detection in Bread Images Using Convolutional Neural Networks
Abstract
:1. Introduction
- We present RGB, a novel method for detecting gluten in bread images using a deep learning model designed to support individuals with celiac disease by providing a decision-support tool, helping them make informed decisions when uncertain about whether a bread product is safe to eat;
- We curated and annotated three unique datasets of bread images from different sources, including Pinterest, Instagram, and a custom dataset containing information about the type of flour used in bread preparation. These datasets provide a valuable resource for training and evaluating machine learning models in the context of gluten detection and could serve as a foundation for further research in this field;
- We evaluated the generalization capability of the proposed method by testing the model trained on independent datasets collected from Pinterest and Instagram. This evaluation highlights the robustness of the model in adapting to different image sources and varying visual characteristics, providing insights into its applicability in real-world scenarios.
- We analyzed the performance of the proposed method across different types of flours using the custom bread dataset, which includes information about the flour type used in each bread sample. This analysis revealed variability in the detection accuracy, offering deeper insights into the model’s strengths and limitations when applied to specific flour types.
2. Related Work
2.1. Classification of Food Images Using CNNs
2.2. Identification of Celiac Disease Using Images
2.3. The Identification of Gluten Presence in Food Using Images
3. Materials and Methods
3.1. Gluten-Free and Gluten-Containing Bread
3.2. RGB Method
3.2.1. Image Collection
3.2.2. Data Labeling, Verification, and Photo Augmentation
- Rotation: rotating images up to 40 degrees randomly to simulate different viewing angles.
- Width and Height Shifts: shifting images along the x-axis and the y-axis by up to 20% to simulate an off-center positioning of the bread.
- Shear Transformation: using shear transformations of up to 20% to skew the image, allowing the model to learn from distorted shapes.
- Zoom: randomly zooming images by up to 20% to simulate a closer or further away shot of the bread.
- Horizontal Flip: flipping images horizontally to simulate different orientations.
- Pixel Fill: filling pixels exposed by transformations with the nearest pixel value using the ’nearest’ fill mode.
3.3. Model Training
- VGG19: This is a convolutional neural network (CNN) architecture developed by the Visual Geometry Group (VGG) at Oxford University in 2014 and is used in a wide range of image classification tasks [44]. The VGG architecture explores the impact of increasing the depth of convolutional networks on classification accuracy. Compared to state-of-the-art configurations, it employs a design with small 3 × 3 convolution filters, which has been shown to improve performance significantly [45]. VGG19 consists of 19 layers with learnable parameters, including 16 convolutional layers and 3 fully connected layers.
- Inception-V3: This is also a deep convolutional neural network architecture developed by Google Research as an improvement over the original Inception architecture. The Inception-V3 model is widely used for image classification. This architecture comprises several layers of convolutional and pooling operations and auxiliary classifiers at intermediate layers. It utilizes a technique known as “inception modules”, which involves parallel convolutions of different sizes followed by concatenating their output features to efficiently extract multi-scale features. As compared to VGGNets, Inception is more computationally efficient [46].
- InceptionResNetV2: This is a CNN architecture that combines the strengths of Inception networks and ResNet architectures, developed by Google Brain to enhance image classification performance [47]. InceptionResNetV2 integrates Inception modules, which use parallel convolutional layers of different kernel sizes, with residual connections, which improve gradient flow and enable efficient training of deeper networks. This architecture consists of 164 layers, incorporating batch normalization, factorized convolutions, and scaling residual connections to optimize accuracy and computational efficiency [47]. Compared to standalone Inception or ResNet models, InceptionResNetV2 achieves superior performance while maintaining lower computational complexity.
- NASNetLarge: This CNN architecture was developed by Google Brain using Neural Architecture Search (NAS), an automated machine learning (AutoML) technique that optimizes network design. NASNetLarge is designed to achieve high performance in image classification tasks while maintaining computational efficiency [48]. Unlike manually designed architectures, NASNet utilizes a reinforcement learning-based search algorithm to discover the most efficient network structure. The NASNetLarge model consists of 88 layers and employs separable convolution operations and batch normalization to reduce computational cost while maintaining high accuracy [49].
- ResNet50V2: This is a CNN architecture introduced as an improved version of ResNet50, developed by Microsoft Research as part of the Residual Network (ResNet) family [50]. ResNet architectures address the vanishing gradient problem by incorporating residual connections (skip connections), which enable deeper networks to train more effectively. ResNet50V2 consists of 50 layers, including convolutional, batch normalization, and fully connected layers, and employs pre-activation residual units, which improve gradient flow during training and lead to better convergence compared to the original ResNet50 [51]. This architecture is widely used in image classification tasks due to its strong generalization capability and efficient training process.
- EfficientNetV2L: This is a CNN architecture developed by Google Brain as an improved version of EfficientNet, designed for better efficiency and faster training in image classification tasks [52]. EfficientNetV2L builds upon EfficientNet’s compound scaling method, which optimally balances depth, width, and resolution to enhance accuracy while minimizing computational cost. Compared to its predecessor, EfficientNetV2 introduces fused MBConv layers, which reduce memory usage and improve training speed. EfficientNetV2L (Large variant) consists of approximately 120 million parameters and is optimized for high-performance classification tasks while maintaining efficiency [52].
3.4. Evaluation
4. Results
4.1. Pinterest Bread Dataset
4.2. Instagram Bread Dataset
4.3. Custom Bread Dataset
5. Discussion
Limitations
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
CNN | Convolutional Neural Network |
RGB | Recognition of Gluten in Bread |
References
- Fasano, A.; Catassi, C. Celiac disease. N. Engl. J. Med. 2012, 367, 2419–2426. [Google Scholar] [CrossRef] [PubMed]
- Biesiekierski, J.R. What is gluten? J. Gastroenterol. Hepatol. 2017, 32, 78–81. [Google Scholar] [CrossRef]
- Fasano, A.; Berti, I.; Gerarduzzi, T.; Not, T.; Colletti, R.B.; Drago, S.; Elitsur, Y.; Green, P.H.; Guandalini, S.; Hill, I.D.; et al. Prevalence of celiac disease in at-risk and not-at-risk groups in the United States: A large multicenter study. Arch. Intern. Med. 2003, 163, 286–292. [Google Scholar] [CrossRef] [PubMed]
- Wieser, H.; Ciacci, C.; Soldaini, C.; Gizzi, C.; Santonicola, A. Gastrointestinal and Hepatobiliary Manifestations Associated with Untreated Celiac Disease in Adults and Children: A Narrative Overview. J. Clin. Med. 2024, 13, 4579. [Google Scholar] [CrossRef]
- Theethira, T.G.; Dennis, M. Celiac disease and the gluten-free diet: Consequences and recommendations for improvement. Dig. Dis. 2015, 33, 175–182. [Google Scholar] [CrossRef] [PubMed]
- Kamycheva, E.; Goto, T.; Camargo, C. Celiac disease is associated with reduced bone mineral density and increased FRAX scores in the US National Health and Nutrition Examination Survey. Osteoporos. Int. 2017, 28, 781–790. [Google Scholar] [CrossRef]
- Marafini, I.; Monteleone, G.; Stolfi, C. Association between celiac disease and cancer. Int. J. Mol. Sci. 2020, 21, 4155. [Google Scholar] [CrossRef]
- Niewinski, M.M. Advances in celiac disease and gluten-free diet. J. Am. Diet. Assoc. 2008, 108, 661–672. [Google Scholar] [CrossRef] [PubMed]
- Bascuñán, K.A.; Vespa, M.C.; Araya, M. Celiac disease: Understanding the gluten-free diet. Eur. J. Nutr. 2017, 56, 449–459. [Google Scholar] [CrossRef] [PubMed]
- Dave Bloom, S. Restaurant Fined $105,000 for Anaphylactic Death of Customer. Available online: https://snacksafely.com/2021/03/restaurant-fined-105000-for-anaphylactic-death-of-customer/ (accessed on 18 March 2021).
- Keay, L. Allergy Sufferers Tell of ’Traumatic’ Experiences Ordering Food After Mistakes Led to Teenagers’ Deaths. Sky News, 17 August 2024. [Google Scholar]
- Zhang, J.; Portela, S.B.; Horrell, J.B.; Leung, A.; Weitmann, D.R.; Artiuch, J.B.; Wilson, S.M.; Cipriani, M.; Slakey, L.K.; Burt, A.M.; et al. An integrated, accurate, rapid, and economical handheld consumer gluten detector. Food Chem. 2019, 275, 446–456. [Google Scholar] [CrossRef] [PubMed]
- Marić, A.; Scherf, K.A. A portable gluten sensor for celiac disease patients may not always be reliable depending on the food and the user. Front. Nutr. 2021, 8, 712992. [Google Scholar] [CrossRef] [PubMed]
- Taylor, S.L.; Nordlee, J.A.; Jayasena, S.; Baumert, J.L. Evaluation of a handheld gluten detection device. J. Food Prot. 2018, 81, 1723–1728. [Google Scholar] [CrossRef] [PubMed]
- Wang, Y.; Gu, H.W.; Yin, X.L.; Geng, T.; Long, W.; Fu, H.; She, Y. Deep leaning in food safety and authenticity detection: An integrative review and future prospects. Trends Food Sci. Technol. 2024, 146, 104396. [Google Scholar] [CrossRef]
- Gbashi, S.; Njobeh, P.B. Enhancing Food Integrity through Artificial Intelligence and Machine Learning: A Comprehensive Review. Appl. Sci. 2024, 14, 3421. [Google Scholar] [CrossRef]
- Voulodimos, A.; Doulamis, N.; Doulamis, A.; Protopapadakis, E. Deep learning for computer vision: A brief review. Comput. Intell. Neurosci. 2018, 2018, 7068349. [Google Scholar] [CrossRef] [PubMed]
- Weiss, K.; Khoshgoftaar, T.M.; Wang, D. A survey of transfer learning. J. Big Data 2016, 3, 1–40. [Google Scholar] [CrossRef]
- Hussain, M.; Bird, J.J.; Faria, D.R. A study on CNN transfer learning for image classification. In Proceedings of the Advances in Computational Intelligence Systems: Contributions Presented at the 18th UK Workshop on Computational Intelligence, Nottingham, UK, 5–7 September 2018; Springer: Berlin/Heidelberg, Germany, 2019; pp. 191–202. [Google Scholar]
- Özsert Yiğit, G.; Özyildirim, B.M. Comparison of convolutional neural network models for food image classification. J. Inf. Telecommun. 2018, 2, 347–357. [Google Scholar] [CrossRef]
- Yadav, S.; Alpana; Chand, S. Automated food image classification using deep learning approach. In Proceedings of the 2021 7th International Conference on Advanced Computing and Communication Systems (ICACCS), Coimbatore, India, 19–20 March 2021; Volume 1, pp. 542–545. [Google Scholar]
- Razali, M.N.; Moung, E.G.; Yahya, F.; Hou, C.J.; Hanapi, R.; Mohamed, R.; Hashem, I.A.T. Indigenous food recognition model based on various convolutional neural network architectures for gastronomic tourism business analytics. Information 2021, 12, 322. [Google Scholar] [CrossRef]
- Moumane, K.; El Asri, I.; Cheniguer, T.; Elbiki, S. Food Recognition and Nutrition Estimation using MobileNetV2 CNN architecture and Transfer Learning. In Proceedings of the 2023 14th International Conference on Intelligent Systems: Theories and Applications (SITA), Casablanca, Morocco, 22–23 November 2023; pp. 1–7. [Google Scholar]
- Patel, J.; Modi, K. Indian Food Image Classification and Recognition with Transfer Learning Technique Using MobileNetV3 and Data Augmentation. Eng. Proc. 2023, 56, 197. [Google Scholar] [CrossRef]
- Boyd, L.; Nnamoko, N.; Lopes, R. Fine-Grained Food Image Recognition: A Study on Optimising Convolutional Neural Networks for Improved Performance. J. Imaging 2024, 10, 126. [Google Scholar] [CrossRef]
- Thiodorus, G.; Sari, Y.A.; Yudistira, N. Convolutional neural network with transfer learning for classification of food types in tray box images. In Proceedings of the 6th International Conference on Sustainable Information Engineering and Technology, Malang, Indonesia, 13–14 September 2021; pp. 301–308. [Google Scholar]
- Kareem, R.S.A.; Tilford, T.; Stoyanov, S. Fine-grained food image classification and recipe extraction using a customized deep neural network and NLP. Comput. Biol. Med. 2024, 175, 108528. [Google Scholar]
- Wei, J.W.; Wei, J.W.; Jackson, C.R.; Ren, B.; Suriawinata, A.A.; Hassanpour, S. Automated detection of celiac disease on duodenal biopsy slides: A deep learning approach. J. Pathol. Inform. 2019, 10, 7. [Google Scholar] [CrossRef]
- Kowsari, K.; Sali, R.; Khan, M.N.; Adorno, W.; Ali, S.A.; Moore, S.R.; Amadi, B.C.; Kelly, P.; Syed, S.; Brown, D.E. Diagnosis of celiac disease and environmental enteropathy on biopsy images using color balancing on convolutional neural networks. In Proceedings of the Future Technologies Conference (FTC) 2019: Volume 1; Springer: Berlin/Heidelberg, Germany, 2020; pp. 750–765. [Google Scholar]
- Carreras, J. Celiac Disease Deep Learning Image Classification Using Convolutional Neural Networks. J. Imaging 2024, 10, 200. [Google Scholar] [CrossRef]
- Keskin Bilgiç, E.; Zaim Gökbay, İ.; Kayar, Y. Innovative Approaches to Clinical Diagnosis: Transfer Learning in Facial Image Classification for Celiac Disease Identification. Appl. Sci. 2024, 14, 6207. [Google Scholar] [CrossRef]
- Jossa-Bastidas, O.; Sanchez, A.O.; Bravo-Lamas, L.; Garcia-Zapirain, B. IoT system for gluten prediction in flour samples using nirs technology, Deep and Machine Learning Techniques. Electronics 2023, 12, 1916. [Google Scholar] [CrossRef]
- Pradana-Lopez, S.; Perez-Calabuig, A.M.; Cancilla, J.C.; Torrecilla, J.S. Standard photographs convolutionally processed to indirectly detect gluten in chickpea flour. J. Food Compos. Anal. 2022, 110, 104547. [Google Scholar] [CrossRef]
- Pradana-López, S.; Pérez-Calabuig, A.M.; Otero, L.; Cancilla, J.C.; Torrecilla, J.S. Is my food safe?–AI-based classification of lentil flour samples with trace levels of gluten or nuts. Food Chem. 2022, 386, 132832. [Google Scholar] [CrossRef] [PubMed]
- Cappelli, A.; Oliva, N.; Cini, E. A systematic review of gluten-free dough and bread: Dough rheology, bread characteristics, and improvement strategies. Appl. Sci. 2020, 10, 6559. [Google Scholar] [CrossRef]
- Anjum, F.M.; Khan, M.R.; Din, A.; Saeed, M.; Pasha, I.; Arshad, M.U. Wheat gluten: High molecular weight glutenin subunits—structure, genetics, and relation to dough elasticity. J. Food Sci. 2007, 72, R56–R63. [Google Scholar] [CrossRef]
- Mioduszewski, Ł.; Cieplak, M. Viscoelastic properties of wheat gluten in a molecular dynamics study. PLoS Comput. Biol. 2021, 17, e1008840. [Google Scholar] [CrossRef]
- Shewry, P.R.; Halford, N.G.; Belton, P.S.; Tatham, A.S. The structure and properties of gluten: An elastic protein from wheat grain. Philos. Trans. R. Soc. London. Ser. B Biol. Sci. 2002, 357, 133–142. [Google Scholar] [CrossRef]
- Belton, P. Mini review: On the elasticity of wheat gluten. J. Cereal Sci. 1999, 29, 103–107. [Google Scholar] [CrossRef]
- Gan, Z.; Angold, R.; Williams, M.; Ellis, P.; Vaughan, J.; Galliard, T. The microstructure and gas retention of bread dough. J. Cereal Sci. 1990, 12, 15–24. [Google Scholar] [CrossRef]
- Horstmann, S.W.; Lynch, K.M.; Arendt, E.K. Starch characteristics linked to gluten-free products. Foods 2017, 6, 29. [Google Scholar] [CrossRef] [PubMed]
- Correia, P.; Fonseca, M.; Guiné, R. Gluten-free bread: A case study. J. Adv. Agric. Technol. 2017, 4, 340–344. [Google Scholar] [CrossRef]
- Shorten, C.; Khoshgoftaar, T.M. A survey on image data augmentation for deep learning. J. Big Data 2019, 6, 1–48. [Google Scholar] [CrossRef]
- Tammina, S. Transfer learning using vgg-16 with deep convolutional neural network for classifying images. Int. J. Sci. Res. Publ. (IJSRP) 2019, 9, 143–150. [Google Scholar] [CrossRef]
- Theckedath, D.; Sedamkar, R. Detecting affect states using VGG16, ResNet50 and SE-ResNet50 networks. SN Comput. Sci. 2020, 1, 79. [Google Scholar] [CrossRef]
- Xia, X.; Xu, C.; Nan, B. Inception-v3 for flower classification. In Proceedings of the 2017 2nd International Conference on Image, Vision and Computing (ICIVC), Chengdu, China, 2–4 June 2017; pp. 783–787. [Google Scholar]
- Szegedy, C.; Ioffe, S.; Vanhoucke, V.; Alemi, A. Inception-v4, inception-resnet and the impact of residual connections on learning. In Proceedings of the AAAI Conference on Artificial Intelligence, San Francisco, CA, USA, 4–7 February 2017; Volume 31. [Google Scholar]
- Zoph, B.; Vasudevan, V.; Shlens, J.; Le, Q.V. Learning transferable architectures for scalable image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–22 June 2018; pp. 8697–8710. [Google Scholar]
- Tan, M.; Le, Q. Efficientnet: Rethinking model scaling for convolutional neural networks. In Proceedings of the International Conference on Machine Learning, Long Beach, CA, USA, 9–15 June 2019; pp. 6105–6114. [Google Scholar]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Identity mappings in deep residual networks. In Proceedings of the Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, 11–14 October 2016; Proceedings, Part IV 14. Springer: Berlin/Heidelberg, Germany, 2016; pp. 630–645. [Google Scholar]
- Tan, M.; Le, Q. Efficientnetv2: Smaller models and faster training. In Proceedings of the International Conference on Machine Learning, Online, 18–24 July 2021; pp. 10096–10106. [Google Scholar]
- Aneja, N.; Aneja, S. Transfer learning using CNN for handwritten devanagari character recognition. In Proceedings of the 2019 1st International Conference on Advances in Information Technology (ICAIT), Chikmagalur, India, 25–27 July 2019; pp. 293–296. [Google Scholar]
- Bensaoud, A.; Abudawaood, N.; Kalita, J. Classifying malware images with convolutional neural network models. Int. J. Netw. Secur. 2020, 22, 1022–1031. [Google Scholar]
- Munte, S.B.K.; Rismiyati, R. Transfer learning with VGG16 and InceptionV3 for traffic sign classification. AIP Conf. Proc. 2024, 3165, 040003. [Google Scholar]
- Ren, Y.; Linter, B.R.; Linforth, R.; Foster, T.J. A comprehensive investigation of gluten free bread dough rheology, proving and baking performance and bread qualities by response surface design and principal component analysis. Food Funct. 2020, 11, 5333–5345. [Google Scholar] [CrossRef]
- Yazar, G.; Demirkesen, I. Linear and non-linear rheological properties of gluten-free dough systems probed by fundamental methods. Food Eng. Rev. 2023, 15, 56–85. [Google Scholar] [CrossRef]
Dataset | Number of Gluten-Free Bread Images | Number of Gluten-Containing Bread Images | Total |
---|---|---|---|
Pinterest bread dataset | 256 | 256 | 512 |
Instagram bread dataset | 43 | 40 | 83 |
Custom bread dataset | 108 | 107 | 217 |
Model | Accuracy | Precision | Recall | F1-Score |
---|---|---|---|---|
VGG19 | 76% | 80% | 71% | 75% |
Inception-V3 | 68% | 65% | 76% | 70% |
InceptionResNetV2 | 71% | 77% | 59% | 67% |
NASNetLarge | 53% | 52% | 71% | 60% |
ResNet50V2 | 77% | 79% | 77% | 77% |
EfficientNetV2L | 50% | 50% | 94% | 65% |
Model | Training Dataset | Records | Accuracy | Precision | Recall | F1-Score |
---|---|---|---|---|---|---|
ResNet50V2 | 410 | 77% | 79% | 77% | 77% | |
ResNet50V2 | 66 | 83% | 87% | 84% | 83% | |
ResNet50V2 | Pinterest + Instagram | 476 | 78% | 80% | 77% | 77% |
Accuracy | Precision | Recall | F1-Score |
---|---|---|---|
86% | 87% | 86% | 86% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Elyashar, A.; Paradise Vit, A.; Sebbag, G.; Khaytin, A.; Zakai, A. Automated Gluten Detection in Bread Images Using Convolutional Neural Networks. Appl. Sci. 2025, 15, 1737. https://doi.org/10.3390/app15041737
Elyashar A, Paradise Vit A, Sebbag G, Khaytin A, Zakai A. Automated Gluten Detection in Bread Images Using Convolutional Neural Networks. Applied Sciences. 2025; 15(4):1737. https://doi.org/10.3390/app15041737
Chicago/Turabian StyleElyashar, Aviad, Abigail Paradise Vit, Guy Sebbag, Alex Khaytin, and Avi Zakai. 2025. "Automated Gluten Detection in Bread Images Using Convolutional Neural Networks" Applied Sciences 15, no. 4: 1737. https://doi.org/10.3390/app15041737
APA StyleElyashar, A., Paradise Vit, A., Sebbag, G., Khaytin, A., & Zakai, A. (2025). Automated Gluten Detection in Bread Images Using Convolutional Neural Networks. Applied Sciences, 15(4), 1737. https://doi.org/10.3390/app15041737