Bread food detection system and method
Through an improved convolutional neural network framework and feature pyramid structure, combined with a weighted smooth L1 loss function, the problem of identifying appearance quality, internal structure and ingredient distribution in the bread food inspection system was solved, and higher-precision bread quality inspection was achieved.
Patent Information
- Application Number
- CN202510789596.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-26
AI Technical Summary
Existing bread food image detection systems have difficulty in accurately identifying the appearance quality, internal structure and ingredient distribution of bread, and positioning problems are difficult, resulting in inaccurate and objective detection results.
An improved convolutional neural network framework, including a feature extraction module and a feature pyramid structure, combined with a weighted smooth L1 loss function, is used to identify the appearance quality, internal structure and ingredient distribution of bread, and image quality is improved through image denoising and enhancement processing.
It significantly improves the recognition accuracy and positioning accuracy of bread quality inspection, can better identify subtle defects and anomalies, and enhances the practicality and objectivity of inspection.
Smart Images

Figure CN120707495A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of bread food detection, and in particular to a bread food detection system and method. Background Art
[0002] Quality control is crucial in the bread production process. Traditional bread quality testing methods rely primarily on manual visual inspection and empirical judgment. This approach is not only inefficient but also subject to significant human influence, making it difficult to guarantee the objectivity and accuracy of test results. With the rapid development of computer technology and image processing, automated testing methods based on image processing are gradually being applied to bread quality testing.
[0003] However, existing bread food image detection systems often have some problems. First, the appearance quality, internal structure and ingredient distribution of bread are key indicators for evaluating its quality, but these indicators are often complex and diverse, making it difficult to accurately identify them through simple image processing algorithms. Secondly, although traditional convolutional neural networks can extract image features to a certain extent, their feature extraction capabilities are limited when dealing with objects such as bread with delicate textures and complex ingredient distribution, making it difficult to capture key quality characteristics. In addition, the positioning problem in bread quality recognition is also a difficult point. How to accurately identify and locate areas with appearance defects, internal structural abnormalities and substandard ingredients is of great significance to improving detection accuracy and efficiency. Summary of the Invention
[0004] The object of the present invention is to provide a bread food detection system and method to solve the problems raised in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for detecting bread food, the method comprising:
[0006] Step 1: Use an image acquisition device to obtain image data of the bread food to be tested;
[0007] Step 2: Preprocess the collected bread food image data, including image denoising and image enhancement;
[0008] Step 3: Build a bread quality recognition model using an improved convolutional neural network framework. The model is used to identify the appearance quality, internal structure, and component distribution of bread in the image. The model includes a feature extraction module. The implementation steps of the feature extraction module include:
[0009] Step 3.1: Use the initial convolutional layer to perform preliminary feature extraction on the bread food image;
[0010] Step 3.2: The preliminary features are fed into a feature deepening path consisting of multiple depthwise separable convolutional layers to capture the fine texture and compositional characteristics of the bread.
[0011] Step 3.3: In the feature deepening path, a feature pyramid structure is used to fuse features at different levels.
[0012] Step 3.4: Concatenate the preliminary features with the deepened features and perform feature integration through the fully connected layer;
[0013] Step 4: Input the bread food image preprocessed in step 2 into the trained bread quality recognition model to identify the bread quality and obtain the bread quality information, including appearance defects, internal structural abnormalities, and areas where the ingredients do not meet the standards.
[0014] Preferably, the bread quality recognition model optimizes the loss function in the original convolutional neural network according to the bread characteristics, specifically including: using weighted smooth L1 loss to replace the original L2 loss as the positioning loss, and the algorithm is:
[0015]
[0016] Here, x is the difference between the predicted value and the true value, and the weighting coefficient is adjusted according to the importance of different quality characteristics of bread.
[0017] Preferably, the image denoising method uses Gaussian filtering to eliminate noise in the image, replacing the value of each pixel in the image with the weighted average of the pixel values in its neighborhood. The calculation formula is:
[0018]
[0019] Where G(x,y) is the value of the Gaussian function at the two-dimensional coordinate (x,y) of the image, x and y are coordinates in two-dimensional space, σ is the standard deviation of the Gaussian distribution, e is the base of the natural logarithm, and π is the circumference of a circle.
[0020] Preferably, the steps of performing image enhancement on the bread food image include:
[0021] Step I: Use the Sobel detection operator to perform convolution on the image and calculate the gradient intensity and direction of each pixel;
[0022] Step II: traverse each pixel in the image and compare its gradient strength with the gradient strength of the adjacent pixels in its gradient direction. If the current pixel is not a local maximum, set its gradient strength to zero, thereby eliminating non-contour pixels and reducing identification artifacts.
[0023] Step III: Set two thresholds: a high threshold and a low threshold. Pixels with gradient intensities higher than the high threshold are considered strong contour points, and pixels with gradient intensities lower than the low threshold are considered non-contour points. For pixels with gradient intensities between the two thresholds, if they are connected to strong contour points, they are considered weak contour points and retained; otherwise, they are considered non-contour points and removed.
[0024] Preferably, the steps of constructing the bread quality recognition model include:
[0025] S1: Collect bread image data with various appearance qualities, internal structures, and ingredient distributions as training and validation sets;
[0026] S2: Using an improved convolutional neural network framework, we designed a model structure consisting of an input layer, multiple convolutional layers, a pooling layer, a feature extraction module, a fully connected layer, and an output layer. The feature extraction module consists of depthwise separable convolutional layers, a feature pyramid structure, and a feature fusion mechanism to extract the bread's fine texture, compositional features, and global contextual information.
[0027] S3: Improve the loss function in the original convolutional neural network and use weighted smooth L1 loss as the positioning loss. At the same time, introduce cross entropy loss as the classification loss.
[0028] S4: Use the preprocessed training set data to iteratively train the constructed model, and slightly optimize the model parameters through the back propagation algorithm and the gradient descent algorithm until the performance of the model on the validation set reaches the preset standard. The formula for updating the model parameters of the gradient descent algorithm is:
[0029]
[0030] Among them, θ represents the model parameters, including all weights and biases that the model needs to learn; ω represents the learning rate, which is used to control the step size of parameter update; represents the gradient of the loss function J(θ) with respect to the parameter θ, It is a vector pointing to the direction where the loss function grows fastest; := represents the assignment operation, that is, updating the value of the parameter θ.
[0031] Preferably, after each iteration of model training, the trained model is evaluated on the validation set, including calculating the model's accuracy, recall rate, and F1 score indicators.
[0032] Preferably, the output layer of the bread quality recognition model is composed of multiple neurons, each neuron corresponds to the predicted output of a bread quality category or quality feature; for classification tasks, including the type of appearance defects, the type of internal structural abnormalities, or the category of non-standard ingredients, each neuron outputs the predicted probability of the category; for regression tasks, including the location coordinates of the defective area and the degree to which the ingredients do not meet the standards, each neuron outputs the corresponding continuous value.
[0033] Preferably, the output layer selects a corresponding activation function according to the task type, including: for classification tasks, using the softmax activation function to convert the original score of the output layer into a probability distribution; for regression tasks, using the ReLU activation function to directly output the predicted value.
[0034] Preferably, the output layer is connected to the feature extraction module through a fully connected layer, and the fully connected layer is responsible for mapping the extracted features to each neuron in the output layer; according to the number of features and the number of neurons in the output layer, the weight matrix and bias vector of the fully connected layer are set, and the mapping of features is achieved through matrix multiplication and addition operations.
[0035] Preferably, a bread food detection system comprises:
[0036] Image acquisition module: used to obtain image data of bread food to be tested;
[0037] Image preprocessing module: connected to the image acquisition module, used to preprocess the collected bread food image data, including image denoising and image enhancement;
[0038] Model building module: An improved convolutional neural network framework is used to build a bread quality recognition model. The model includes a feature extraction module, which is implemented through the following steps: using an initial convolutional layer to perform preliminary feature extraction; inputting the preliminary features into a feature deepening path composed of multiple depthwise separable convolutional layers; in the feature deepening path, a feature pyramid structure is used to fuse features from different levels; the preliminary features are concatenated with the deepened features and integrated through a fully connected layer; in addition, this module also optimizes the loss function in the original convolutional neural network for bread characteristics, specifically replacing the original L2 loss with a weighted smoothed L1 loss as the localization loss;
[0039] Quality Identification Module: This module is connected to the Bread Quality Identification Model Construction Module and is used to input pre-processed bread food images into the trained bread quality identification model to identify bread quality and obtain bread quality information, including appearance defects, internal structural abnormalities, and areas where ingredients do not meet standards.
[0040] Result output module: connected to the quality identification module, used to display or store the identified bread quality information.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] The improved convolutional neural network framework adopted by the present invention, especially its feature extraction module, performs preliminary feature extraction through the initial convolution layer, and then combines the feature deepening path composed of multiple depth-separable convolution layers to deeply capture the delicate texture and complex composition characteristics of bread. This design significantly enhances the model's ability to extract bread quality features and improves recognition accuracy. The application of the feature pyramid structure enables the system to fuse features at different levels, thereby more comprehensively reflecting the appearance quality, internal structure and ingredient distribution of bread. The fusion of multi-level features helps the model to more accurately identify quality problems of bread, especially those subtle defects and anomalies.
[0043] This paper optimizes the loss function in the existing convolutional neural network for bread characteristics, using a weighted smoothed L1 loss as the localization loss. This optimized loss function makes the model more accurate in locating bread quality issues, accurately identifying and labeling areas with cosmetic defects, internal structural anomalies, and substandard ingredients, further improving detection accuracy and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a step diagram of a bread food detection method according to the present invention;
[0045] Figure 2 Flowchart for building a bread quality recognition model;
[0046] Figure 3 This is the processing flow chart of image enhancement. DETAILED DESCRIPTION
[0047] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0048] See also Figure 1-3 The present invention provides a technical solution: a bread food detection method, the method comprising the following steps:
[0049] Step 1: Use an image acquisition device, such as a high-definition camera or professional scanner, to acquire image data of the bread product to be inspected. During the acquisition process, ensure that the image acquisition device is stable and adjust the shooting angle and lighting conditions to obtain clear, undistorted images of the bread.
[0050] Step 2: Preprocess the collected bread image data, including image denoising and image enhancement. Image denoising aims to reduce noise interference in the image and improve image quality. Image enhancement is used to enhance image features such as contrast and brightness, making the bread's delicate texture and composition more prominent.
[0051] Step 3: Build a bread quality recognition model using an improved convolutional neural network framework. The model includes a feature extraction module to extract key features from bread images.
[0052] The implementation steps of the feature extraction module are as follows:
[0053] Step 3.1: Use the initial convolutional layer to perform preliminary feature extraction on the bread food image. The initial convolutional layer contains multiple convolution kernels, which extract basic features in the image, such as edges and corners, through convolution operations.
[0054] Step 3.2: Feed the preliminary features into a feature deepening pipeline consisting of multiple depthwise separable convolutional layers. Depthwise separable convolutional layers more effectively capture the subtle texture and compositional features of an image while reducing computational effort. By stacking multiple depthwise separable convolutional layers, higher-level features are gradually extracted.
[0055] Step 3.3: In the feature deepening process, a feature pyramid structure is used to fuse features from different levels. This structure integrates feature information at different scales, enhancing the model's ability to recognize multi-scale objects. This fusion and transfer of features is achieved through operations such as upsampling, downsampling, and lateral concatenation.
[0056] Step 3.4: Concatenate the preliminary features with the refined features and integrate them through a fully connected layer. This concatenation operation combines the preliminary and refined features to form a more comprehensive feature representation. The fully connected layer is responsible for mapping the concatenated features to the output space, providing the foundation for subsequent quality identification.
[0057] Step 4: Input the preprocessed bread image into the trained bread quality recognition model to identify the bread's quality. Based on the input image data, the model outputs bread quality information, including appearance defects, internal structural abnormalities, and areas with substandard ingredients. This information can be visualized on a display or stored in a data file for subsequent analysis.
[0058] The present invention will be further described below in conjunction with Examples 1 to 3:
[0059] Example 1:
[0060] The weighted smooth L1 loss is used to replace the original L2 loss as the positioning loss. This implementation will be described in detail below with reference to specific examples.
[0061] The smoothed L1 loss function combines the advantages of both L1 and L2 losses. When the error is small, it uses the L2 loss, which results in smaller gradients and promotes stable model convergence. When the error is large, it uses the L1 loss, which reduces sensitivity to outliers and enhances model robustness. For bread quality identification tasks, especially for locating the boundaries of defective areas, the smoothed L1 loss is better able to handle boundary uncertainty and ambiguity.
[0062] In specific implementation, the weighted smooth L1 loss function is defined as follows:
[0063]
[0064] Among them, x i is the coordinate of the bread defect area boundary predicted by the model, y is the coordinate of the true boundary, N is the number of boundary points, and w i It is a weighting coefficient set according to different quality characteristics of bread (such as the severity of appearance defects, the importance of internal structural abnormalities, etc.). Smooth L1() is a smooth L1 loss function, which is defined as follows:
[0065]
[0066] Weighting coefficient w i The setting of is the key, and it needs to be adjusted according to the specific application scenario and the importance of the bread quality characteristics. For example, for appearance defects that seriously affect the safety of bread consumption (such as mildew, foreign matter, etc.), a higher weighting coefficient can be set to ensure the model's sensitivity to these defects and recognition accuracy; for characteristics that have less impact on quality (such as slight color unevenness), a lower weighting coefficient can be set to avoid the model's excessive attention to these characteristics. In the specific implementation, first set an initial set of weighting coefficients based on the importance and frequency of occurrence of bread quality characteristics. Then, through cross-validation experiments on the training set, continuously adjust the value of the weighting coefficient, and observe the performance of the model on the validation set until a set of weighting coefficients that optimizes the model performance is found.
[0067] Example 2:
[0068] To remove noise from the bread image and improve its clarity, a Gaussian filter was used to smooth the image. Gaussian filtering is a linear smoothing filter that replaces the value of each pixel in the image with the weighted average of the pixel values in its neighborhood, achieving the desired denoising effect.
[0069] In specific implementation, the calculation formula of Gaussian filtering is as follows:
[0070]
[0071] Where G(x,y) is the Gaussian function value at the two-dimensional coordinate (x,y) in the image, x and y are the coordinates in two-dimensional space, σ is the standard deviation of the Gaussian distribution, which determines the width of the Gaussian function, that is, the smoothness of the filter. e is the base of the natural logarithm, and π is the ratio of the circumference of a circle to its circumference.
[0072] In practical applications, we first select an appropriate σ value based on the image's noise level and the desired smoothing effect. Then, for each pixel in the image, we take a (2k+1)×(2k+1) neighborhood (where k is a positive integer) centered around it. We calculate the sum of the products of all pixel values within this neighborhood and the Gaussian function values, then divide this sum by the sum of the Gaussian function values to obtain the new value for that pixel. By traversing all pixels in the image, we can obtain the denoised image.
[0073] For example, for a noisy image of bread, a Gaussian filter with σ = 1 was selected for denoising. This effectively suppressed the noise in the image, making the bread's outline and texture clearer, providing a better foundation for subsequent image enhancement and quality recognition.
[0074] In order to further enhance the features of bread food images and highlight the outline and details of bread, the following steps are used for image enhancement:
[0075] Step I: Use the Sobel operator to convolve the image and calculate the gradient strength and direction for each pixel. The Sobel operator is a discrete differential operator that can detect edges in an image. By calculating the horizontal and vertical gradients, the gradient strength and direction for each pixel can be obtained.
[0076] Step II: Traverse each pixel in the image and compare its gradient strength with the gradient strengths of its neighboring pixels in the gradient direction. If the current pixel is not a local maximum, that is, its gradient strength is less than the gradient strengths of its neighboring pixels in the gradient direction, then its gradient strength is set to zero. The purpose of this step is to eliminate non-contour pixels, reduce marking artifacts, and make the image contour clearer.
[0077] Step III: Set two thresholds: a high threshold and a low threshold. Pixels with gradient strengths above the high threshold are considered strong contour points, while pixels below the low threshold are considered non-contour points. For pixels with gradient strengths between the two thresholds, if they are connected to a strong contour point, they are considered weak contour points and retained; otherwise, they are considered non-contour points and removed. The purpose of this step is to further refine the image contour, retaining important feature information while removing unnecessary details and noise.
[0078] Example 3:
[0079] The steps to build a bread quality recognition model include:
[0080] S1: Collect bread image data containing various appearance qualities (such as surface cracks, uneven color, and mold), internal structure (such as pore distribution and softness), and composition distribution (such as ingredient ratio and additive usage). This data should cover bread samples from different varieties, production processes, and storage conditions to ensure the generalization ability of the model. The collected image data is randomly divided into a training set and a validation set. The training set is used for model training, and the validation set is used for model evaluation and optimization.
[0081] S2: Using an improved convolutional neural network framework, we designed a model structure with the following layers:
[0082] Input layer: accepts pre-processed bread image data, such as resizing and normalization.
[0083] Multiple convolutional layers: Use convolution operations to extract local features of the image, and each layer may be followed by a ReLU activation function and a batch normalization operation.
[0084] Pooling layer: reduces the size of the feature map, reduces the amount of computation, and retains important features.
[0085] Feature extraction module:
[0086] Depthwise separable convolution layer: By decomposing standard convolution into depthwise convolution and point-wise convolution, the number of parameters and computation are reduced while maintaining feature extraction capabilities.
[0087] Feature pyramid structure: It fuses feature maps of different scales to capture multi-scale bread features and enhance the model's ability to understand fine textures and global context information.
[0088] Feature fusion mechanism: features from different layers are concatenated or weighted summed to integrate feature information at different levels.
[0089] Fully connected layer: maps the feature vector output by the feature extraction module to the output layer.
[0090] Output layer: Design the corresponding neuron structure according to the task type (classification or regression).
[0091] S3: Loss function improvement:
[0092] Positioning loss: A weighted smooth L1 loss function is used to fine-tune the boundaries of the bread defect areas predicted by the model to improve positioning accuracy. The weighting coefficient is set based on the severity and importance of the defect.
[0093] Classification loss: The cross-entropy loss function is introduced for multi-category classification tasks, such as the identification of appearance defect types and internal structural anomaly types, to optimize the model's ability to distinguish between different categories.
[0094] S4: Use the preprocessed training data to iteratively train the constructed model. During training, optimize the model parameters using a backpropagation algorithm and a gradient descent strategy (such as the Adam optimizer). After each iteration, evaluate the model on the validation set, calculating metrics such as accuracy, recall, and F1 score to monitor model performance and prevent overfitting.
[0095] Output layer design and activation function selection:
[0096] Classification task: The output layer consists of neurons equal to the number of bread quality categories, with each neuron corresponding to the predicted probability of a category. A softmax activation function is used to convert the raw scores into a probability distribution, facilitating multi-category classification.
[0097] Regression task: The output layer consists of neurons equal to the number of regression targets, such as the location coordinates of the defect area, the degree to which the component does not meet the standard, etc. It uses the ReLU activation function to directly output the predicted value, which is suitable for the prediction of continuous values.
[0098] Fully Connected Layers and Feature Mapping: The fully connected layer is responsible for mapping the high-dimensional feature vectors output by the feature extraction module to each neuron in the output layer. The weight matrix and bias vector of the fully connected layer are set based on the number of features and the number of neurons in the output layer. Through matrix multiplication and addition operations, the feature-to-output mapping is achieved, completing the model's final prediction task.
[0099] The present invention also includes a bread food detection system, the system comprising:
[0100] Image acquisition module: used to obtain image data of bread food to be tested;
[0101] Image preprocessing module: connected to the image acquisition module, used to preprocess the collected bread food image data, including image denoising and image enhancement;
[0102] Model building module: An improved convolutional neural network framework is used to build a bread quality recognition model. The model includes a feature extraction module, which is implemented through the following steps: using an initial convolutional layer to perform preliminary feature extraction; inputting the preliminary features into a feature deepening path composed of multiple depthwise separable convolutional layers; in the feature deepening path, a feature pyramid structure is used to fuse features from different levels; the preliminary features are concatenated with the deepened features and integrated through a fully connected layer; in addition, this module also optimizes the loss function in the original convolutional neural network for bread characteristics, specifically replacing the original L2 loss with a weighted smoothed L1 loss as the localization loss;
[0103] Quality Identification Module: This module is connected to the Bread Quality Identification Model Construction Module and is used to input pre-processed bread food images into the trained bread quality identification model to identify bread quality and obtain bread quality information, including appearance defects, internal structural abnormalities, and areas where ingredients do not meet standards.
[0104] Result output module: connected to the quality identification module, used to display or store the identified bread quality information.
[0105] The implementation of the system is described in the above embodiment and will not be described in detail in the specification.
[0106] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0107] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A bread food detection method, characterized in that: The method comprises: Step 1: Use an image acquisition device to obtain image data of the bread food to be tested; Step 2: Preprocess the collected bread food image data, including image denoising and image enhancement; Step 3: Build a bread quality recognition model using an improved convolutional neural network framework. The model is used to identify the appearance quality, internal structure, and component distribution of bread in the image. The model includes a feature extraction module. The implementation steps of the feature extraction module include: Step 3.1: Use the initial convolutional layer to perform preliminary feature extraction on the bread food image; Step 3.2: The preliminary features are fed into a feature deepening path consisting of multiple depthwise separable convolutional layers to capture the fine texture and compositional characteristics of the bread. Step 3.3: In the feature deepening path, a feature pyramid structure is used to fuse features at different levels. Step 3.4: Concatenate the preliminary features with the deepened features and perform feature integration through the fully connected layer; Step 4: Input the bread food image preprocessed in step 2 into the trained bread quality recognition model to identify the bread quality and obtain the bread quality information, including appearance defects, internal structural abnormalities, and areas where the ingredients do not meet the standards.
2. A bread food detection method according to claim 1, characterized in that: The bread quality recognition model optimizes the loss function in the original convolutional neural network based on bread characteristics. Specifically, it uses a weighted smoothed L1 loss to replace the original L2 loss as the positioning loss. The algorithm is: Here, x is the difference between the predicted value and the true value, and the weighting coefficient is adjusted according to the importance of different quality characteristics of bread.
3. The bread food detection method according to claim 1, characterized in that: The image denoising method uses Gaussian filtering to eliminate noise in the image, replacing the value of each pixel in the image with the weighted average of the pixel values in its neighborhood. The calculation formula is: Where G(x,y) is the value of the Gaussian function at the two-dimensional coordinate (x,y) of the image, x and y are coordinates in two-dimensional space, σ is the standard deviation of the Gaussian distribution, e is the base of the natural logarithm, and π is the circumference of a circle.
4. A bread food detection method according to claim 1, characterized in that: The steps to implement image enhancement for bread food images include: Step I: Use the Sobel detection operator to perform convolution on the image and calculate the gradient intensity and direction of each pixel; Step II: traverse each pixel in the image and compare its gradient strength with the gradient strength of the adjacent pixels in its gradient direction. If the current pixel is not a local maximum, set its gradient strength to zero, thereby eliminating non-contour pixels and reducing identification artifacts. Step III: Set two thresholds: a high threshold and a low threshold. Pixels with gradient intensities higher than the high threshold are considered strong contour points, and pixels with gradient intensities lower than the low threshold are considered non-contour points. For pixels with gradient intensities between the two thresholds, if they are connected to strong contour points, they are considered weak contour points and retained; otherwise, they are considered non-contour points and removed.
5. A bread food detection method according to claim 1, characterized in that: The steps of constructing the bread quality recognition model include: S1: Collect bread image data with various appearance qualities, internal structures, and ingredient distributions as training and validation sets; S2: Using an improved convolutional neural network framework, we designed a model structure consisting of an input layer, multiple convolutional layers, a pooling layer, a feature extraction module, a fully connected layer, and an output layer. The feature extraction module consists of depthwise separable convolutional layers, a feature pyramid structure, and a feature fusion mechanism to extract the bread's fine texture, compositional features, and global contextual information. S3: Improve the loss function in the original convolutional neural network and use weighted smooth L1 loss as the positioning loss. At the same time, introduce cross entropy loss as the classification loss. S4: Use the preprocessed training set data to iteratively train the constructed model, and slightly optimize the model parameters through the back propagation algorithm and the gradient descent algorithm until the performance of the model on the validation set reaches the preset standard. The formula for updating the model parameters of the gradient descent algorithm is: Among them, θ represents the model parameters, including all weights and biases that the model needs to learn; ω represents the learning rate, which is used to control the step size of parameter update; represents the gradient of the loss function J(θ) with respect to the parameter θ, It is a vector pointing to the direction where the loss function grows fastest; := represents the assignment operation, that is, updating the value of the parameter θ.
6. A bread food detection method according to claim 5, characterized in that: After each iteration of model training, the trained model is evaluated on the validation set, including calculating the model's accuracy, recall, and F1 score indicators.
7. A bread food detection method according to claim 5, characterized in that: The output layer of the bread quality recognition model consists of multiple neurons, each of which corresponds to a predicted output for a bread quality category or quality feature. For classification tasks, including the type of appearance defect, the type of internal structural abnormality, or the category of non-standard ingredients, each neuron outputs the predicted probability of that category. For regression tasks, including the location coordinates of the defect area and the degree to which the ingredients do not meet the standards, each neuron outputs a corresponding continuous value.
8. A bread food detection method according to claim 7, characterized in that: The output layer selects the corresponding activation function according to the task type, including: for classification tasks, using the softmax activation function to convert the original score of the output layer into a probability distribution; for regression tasks, using the ReLU activation function to directly output the predicted value.
9. A bread food detection method according to claim 8, characterized in that: The output layer is connected to the feature extraction module through a fully connected layer, which is responsible for mapping the extracted features to each neuron in the output layer. According to the number of features and the number of neurons in the output layer, the weight matrix and bias vector of the fully connected layer are set, and the feature mapping is achieved through matrix multiplication and addition operations.
10. A bread food detection system, characterized in that: The system comprises: Image acquisition module: used to obtain image data of bread food to be tested; Image preprocessing module: connected to the image acquisition module, used to preprocess the collected bread food image data, including image denoising and image enhancement; Model building module: An improved convolutional neural network framework is used to build a bread quality recognition model. The model includes a feature extraction module, which is implemented through the following steps: using an initial convolutional layer to perform preliminary feature extraction; inputting the preliminary features into a feature deepening path composed of multiple depthwise separable convolutional layers; in the feature deepening path, a feature pyramid structure is used to fuse features from different levels; the preliminary features are concatenated with the deepened features and integrated through a fully connected layer; in addition, this module also optimizes the loss function in the original convolutional neural network for bread characteristics, specifically replacing the original L2 loss with a weighted smoothed L1 loss as the localization loss; Quality Identification Module: This module is connected to the Bread Quality Identification Model Construction Module and is used to input pre-processed bread food images into the trained bread quality identification model to identify bread quality and obtain bread quality information, including appearance defects, internal structural abnormalities, and areas where ingredients do not meet standards. Result output module: connected to the quality identification module, used to display or store the identified bread quality information.
Citation Information
Patent Citations
Cake egg tart quality detection method based on visual algorithm
CN116958066A
Image recognition system and method based on big data technology
CN119693801A
Intelligent traditional Chinese medicinal material variety identification system based on photovoltaic agricultural medicine-light complementation
CN119863790A
Cover beam support deformation detection method and system
CN119888452A
Food nutrition detection model, method and equipment
CN120107955A