# Automated Gluten Detection in Bread Images Using Convolutional Neural Networks
## 1 Introduction
Deep learning models, particularly convolutional neural networks (CNNs), have been successfully applied to various food safety applications, such as detecting food adulteration, monitoring quality control in food production, and identifying contaminants [17]. These technologies are now being explored for gluten detection, where they can analyze complex visual features in food images to assess the likelihood of gluten presence. By harnessing these advancements, we introduce a novel method that applies deep learning to gluten detection in bread images. This approach has the potential to significantly improve accessibility for individuals with celiac disease by allowing them to verify food safety quickly and conveniently through image-based analysis. In this study, we propose RGB(Recognition of Gluten in Bread), a novel deep learning-based method designed to support individuals with celiac disease by providing a decision-support tool for automatically detecting gluten in bread images. We collected three datasets of bread images from social media platforms, including both gluten-containing and gluten-free bread: Pinterest, Instagram, and custom bread datasets. Using the Pinterest bread dataset, we fine-tuned six pre-trained CNN models. The best-performing model was ResNet50V2, achieving 77% accuracy and recall on the testing set. To assess its generality, we then evaluated the trained ResNet50V2 model on the Instagram bread dataset. By re-training the model on images from Pinterest and Instagram, we improved the model's performance to successfully differentiate between gluten-containing and gluten-free bread images, achieving 78% accuracy and 77% recall. Later, using the custom bread dataset, which differed from the other two datasets sourced from social media and included information about the type of flour used in its preparation, we analyzed the performance of the ResNet50V2 model on each type of flour. The analysis indicates that the model achieved higher accuracy scores on gluten-free flours, demonstrating better performance detecting these types. This analysis not only highlights the model's potential for detecting gluten-free flours but also opens the door to broader applications of such methods. By refining and expanding these capabilities, this work lays the groundwork for developing practical tools to enhance the quality of life for individuals with celiac disease. This paper provides three contributions:  
* 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.