Food foreign matter detection method and system based on information entropy dynamic routing and graph convolution

By using dynamic routing based on information entropy and graph convolution, the problem of high false detection rate in food foreign object detection is solved, achieving high-precision separation of foreign objects from background texture, thus improving detection accuracy and production line safety.

CN122176696APending Publication Date: 2026-06-09ZHEJIANG GONGSHANG UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG GONGSHANG UNIVERSITY
Filing Date
2026-05-11
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing technologies cannot effectively distinguish between the normal complex textures on the surface of food and the boundaries of real foreign objects, resulting in a high false detection rate for foreign objects in food.

Method used

A method based on information entropy dynamic routing and graph convolution is adopted. By combining multi-scale feature extraction, information entropy feature map generation, routing gating network diversion, graph neural network topology feature extraction and evidence decision network, high-precision separation of foreign objects and background texture is achieved.

Benefits of technology

It improves the accuracy of foreign object detection, reduces the false detection rate, enhances the ability to identify irregularly shaped foreign objects, and improves the safety and automation level of the production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176696A_ABST
    Figure CN122176696A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for detecting foreign objects in food based on dynamic routing with information entropy and graph convolution, belonging to the field of food detection technology. This invention generates a corresponding two-dimensional information entropy feature map by calculating the discrete data of a multi-scale basic feature tensor. This map is then input into a routing gating network to generate a spatial routing mask. The spatial routing mask is used to partition the multi-scale basic feature tensor into high-entropy and low-entropy feature streams, which are then subjected to topological and convolutional processing to generate first and second discriminative features. These features are then fused with the spatial routing mask to generate a full-graph fusion feature tensor, which is then input into an evidence decision network. The network outputs category judgment confidence and cognitive uncertainty, which are then compared to determine whether to generate a physical interception command and output a foreign object rejection result. This reduces the false detection rate of foreign objects in food detection and solves the problem of increased false detection rates in existing technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of food detection technology, and in particular to a method and system for detecting foreign objects in food based on information entropy dynamic routing and graph convolution. Background Technology

[0002] Currently, the mainstream technologies for automated detection of foreign objects in food mainly rely on computer vision algorithms based on deep learning frameworks. The implementation typically involves using conventional convolutional neural networks to extract features from the acquired two-dimensional images of the food, either globally or statically. The network model learns basic surface features such as the appearance, color, and contour of the target region, and then outputs classification or region segmentation results. Objectively speaking, when the detection environment is relatively ideal, and the background texture of the food being tested is relatively uniform and smooth, with a significant visual contrast between the foreign object and the food substrate, the aforementioned existing technologies can achieve relatively fast and effective foreign object identification.

[0003] For example, Chinese invention patent CN119992540B discloses a method and system for detecting foreign objects in food based on deep learning, which includes: an image acquisition module and a foreign object analysis module connected thereto; the image acquisition module is used to acquire RGB images and penetration images of food; the foreign object analysis module inputs the food image corresponding to the RGB image, the food image corresponding to the penetration image, color features and shape features into the foreign object detection model.

[0004] However, in actual industrial processing, the complex textures of food surfaces and locally charred areas exhibit extremely drastic feature gradient changes and irregular visual boundaries in two-dimensional images. Existing conventional convolutional models and static segmentation mechanisms cannot adaptively distinguish between these high-frequency boundaries resulting from the evolution of food processing and abnormal boundaries caused by actual foreign object intrusion. Due to the lack of dynamic perception of the complexity of local image information and a deep analytical mechanism for the topological structure of irregular boundaries, existing models often mechanically identify dark edges caused by local charring or normal morphological wrinkles caused by complex textures as foreign object contours, thus generating a large number of erroneous interception commands. Because they cannot separate normal complex textures from actual foreign object boundaries, there is a problem of increased false detection rate when detecting foreign objects in food. Summary of the Invention

[0005] To address the problem of increased false detection rates in food foreign object detection due to the inability to separate normal complex textures from the boundaries of real foreign objects in existing technologies, this invention provides a food foreign object detection method and system based on information entropy dynamic routing and graph convolution. The technical solution is as follows: On the one hand, a method for detecting foreign objects in food based on information entropy dynamic routing and graph convolution is provided. This method includes: acquiring image data of the food to be detected and inputting the image data into a basic feature extraction network to extract a multi-scale basic feature tensor; calculating the discreteness data of the feature distribution of the multi-scale basic feature tensor within a local spatial window and generating a two-dimensional information entropy feature map representing the local spatial complexity, wherein the spatial resolution of the two-dimensional information entropy feature map is consistent with that of the multi-scale basic feature tensor; inputting the two-dimensional information entropy feature map into a routing gating network to generate a spatial routing mask corresponding to the spatial location; partitioning the multi-scale basic feature tensor using the spatial routing mask to obtain a high-entropy feature stream and a low-entropy feature stream; and reconstructing the pixels in the high-entropy feature stream into a topological spatial graph. The system constructs data and performs topological feature extraction and differential operations on neighboring node features based on a graph neural network to generate a first discriminative feature. A low-entropy feature stream is input into a convolutional branch for smooth texture feature extraction to generate a second discriminative feature. Based on a spatial routing mask, the first and second discriminative features are fused to generate a full-image fusion feature tensor. This full-image fusion feature tensor is input into an evidence decision network to calculate and output the category determination confidence for each pixel and the cognitive uncertainty representing the model's cognitive state. The category determination confidence is compared with a first preset threshold, and the cognitive uncertainty is compared with a second preset threshold. If the category determination confidence is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, a physical interception command is generated, and the foreign object rejection result is output.

[0006] On the other hand, a food foreign object detection system based on information entropy dynamic routing and graph convolution is provided, including: a food data acquisition module for acquiring image data of the food to be detected and inputting the image data into a basic feature extraction network to extract a multi-scale basic feature tensor; a food data processing module for calculating the discreteness data of the feature distribution of the multi-scale basic feature tensor within a local spatial window and generating a two-dimensional information entropy feature map representing the local spatial complexity, wherein the spatial resolution of the two-dimensional information entropy feature map is consistent with that of the multi-scale basic feature tensor; inputting the two-dimensional information entropy feature map into a routing gating network to generate a spatial routing mask corresponding to the spatial location; partitioning the multi-scale basic feature tensor using the spatial routing mask to obtain a high-entropy feature stream and a low-entropy feature stream; and a graph convolution data fusion module for fusing the image data from the high-entropy feature stream. The data is reconstructed from the pixels into a topological spatial graph structure, and topological feature extraction and differential operation of neighboring node features are performed on it based on a graph neural network to generate the first discriminative feature. The low-entropy feature stream is input into the convolutional branch to extract smooth texture features and generate the second discriminative feature. Based on the spatial routing mask, the first and second discriminative features are fused to generate a full-image fusion feature tensor. The full-image fusion feature tensor is input into the evidence decision network to calculate and output the category determination confidence and the cognitive uncertainty representing the cognitive state of the model for each pixel. The foreign object result output module is used to compare the category determination confidence with the first preset threshold and the cognitive uncertainty with the second preset threshold. If the category determination confidence is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, a physical interception command is generated and the foreign object rejection result is output.

[0007] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: 1. The food foreign object detection method based on information entropy dynamic routing and graph convolution provided by this invention obtains multi-scale feature tensors through a basic feature extraction network and combines them with local spatial window information entropy calculation, which helps to reflect the local complexity of foreign objects on the food surface. The resolution of the two-dimensional information entropy feature map and the multi-scale feature tensor is consistent, enabling the model to more accurately locate high-complexity regions and improve the detection capability of small or hidden foreign objects. At the same time, a spatial routing mask is generated by using a routing gating network to divide the features into high-entropy and low-entropy feature streams, realizing targeted feature processing. High-entropy regions are modeled by topological graph and structured information is extracted by graph neural networks, which strengthens the morphological difference features of foreign objects, while low-entropy regions are extracted by texture smoothing through convolutional branches, which maintains the continuity of the background food texture, thereby reducing the false detection rate. This helps to solve the problem in the prior art that the inability to separate the normal complex texture from the real foreign object boundary leads to an increased false detection rate in food foreign object detection.

[0008] 2. This invention constructs a topological graph from high-entropy feature stream pixels and performs inter-node difference operations, enabling the model to capture the topological structure features and local context information of foreign objects in local space, thus improving the ability to identify irregularly shaped foreign objects. Furthermore, based on spatial routing masks, it fuses high-entropy topological features with low-entropy convolutional features to form a full-image fusion feature tensor, taking into account both the structure of foreign objects and background texture information, thereby achieving high-precision separation of foreign objects from food backgrounds.

[0009] 3. By outputting category confidence and cognitive uncertainty through the evidence decision network, the model can assess its own confidence in its judgments. At the same time, by judging through preset thresholds, physical interception can be triggered when the confidence is insufficient or the uncertainty is too high, which helps to reduce missed detections or false detections, improve the safety and automation level of the production line, and by fully combining multi-scale features, information entropy analysis, graph neural network topology features and evidence decision mechanisms, not only can higher accuracy, low false detection and strong interpretability of food foreign object detection be achieved, but also the robustness to novel foreign objects and real-time intervention capability are improved. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 A flowchart illustrating the food foreign object detection method based on information entropy dynamic routing and graph convolution provided in this application embodiment; Figure 2 This is a schematic diagram of the structure of the food foreign object detection system based on information entropy dynamic routing and graph convolution provided in the embodiments of this application. Detailed Implementation

[0012] The following provides explanations for some of the terms used in this application. It should be noted that these explanations are for the convenience of those skilled in the art and do not constitute a limitation on the scope of protection claimed in this application.

[0013] The embodiments of this application involve at least one, including one or more; where "multiple" means two or more. Furthermore, it should be understood that in the description of this specification, terms such as "first," "second," and "third" are used only for descriptive purposes and should not be construed as indicating relative importance or order. For example, "first device" and "second device" do not represent the degree of importance of the two or their order, but are merely for descriptive distinction. In the embodiments of this application, "and / or" merely describes an association relationship, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0014] The directional terms mentioned in the embodiments of this application, such as "up", "down", "left", "right", "inner", and "outer", are only for reference to the directions in the accompanying drawings. Therefore, the directional terms used are for better and clearer explanation and understanding of the embodiments of this application, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.

[0015] References to "one embodiment," "in some examples," or "some embodiments" as described in the embodiments of this application mean that one or more embodiments of this specification include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in some examples," "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0016] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0017] To facilitate understanding, the following example, illustrating the detection of metal fragments and foreign objects in a cookie baking production line, will be used throughout the text: An industrial camera captures 640×640 RGB images of cookies on the production line. The cookie surface exhibits irregular charring textures and baking wrinkles, and a metal fragment of approximately 3mm×2mm is mixed in. This metal fragment has an irregular shape and its color is somewhat similar to the charred edges of the cookie, making it highly difficult to detect. Each step will be explained using this scenario.

[0018] like Figure 1 The diagram shown is a flowchart of a food foreign object detection method based on dynamic routing and graph convolution provided in this application embodiment. The method includes the following steps: Step 1: Acquire image data of the food to be detected and input the image data into the basic feature extraction network to extract multi-scale basic feature tensors.

[0019] Image data refers to two-dimensional digital images of the food to be inspected, acquired by industrial cameras or other image acquisition equipment. Specifically, these images can be RGB images, grayscale images, or multispectral images, and are used to carry all observable visual information about the surface and interior of the food.

[0020] Among them, the multi-scale basic feature tensor refers to the three-dimensional tensor data obtained by the basic feature extraction network after extracting features from image data at multiple levels and then fusing feature maps at different spatial resolution levels. Its channel dimension contains multi-granular feature representations from low-level texture details to high-level semantic information, and it is the basic data carrier for subsequent information entropy calculation and foreign object identification.

[0021] The acquisition of image data and the extraction of multi-scale basic feature tensors are the starting points of the entire detection process. Their purpose is to transform the raw visual information of the food into a high-dimensional feature representation that can be processed by subsequent algorithms. Because the size distribution of foreign objects in food varies greatly, ranging from centimeter-sized pieces of hard plastic to millimeter-sized metal fragments, a single-resolution feature map cannot maintain sufficient perceptual accuracy for all sizes of foreign objects simultaneously. Introducing a multi-scale feature fusion mechanism enables the model to retain the boundary details of small foreign objects while also considering the overall semantic understanding of a large range of foreign objects, providing a multi-granular feature foundation for subsequent information entropy-based adaptive routing mechanisms.

[0022] Specifically, the multi-scale fundamental feature tensor is extracted, and the specific steps are as follows: First, the image data is input into a basic feature extraction network that includes a feature pyramid structure.

[0023] It should be noted that the Feature Pyramid Network (FPN) is the core architecture for achieving multi-scale feature fusion. It extracts feature maps of different depths through a bottom-up backbone network and combines them with top-down lateral connections to fuse high-level semantic features with low-level detail features, thus achieving rich semantic representation capabilities at each resolution level. Furthermore, other alternative schemes are used, including Path Aggregation Network (PANet) and Bidirectional Feature Pyramid Network (BiFPN), to adapt to different computational resource and accuracy requirements. For example, taking a 640×640 resolution cookie image as input, the basic feature extraction network can adopt an FPN structure with ResNet-50 as the backbone. After multiple convolutional downsampling steps of 2, it outputs three sets of semantically progressively increasing feature maps at resolution levels of 8, 16, and 32 (i.e., 80×80, 40×40, and 20×20), with 256, 512, and 1024 channels respectively.

[0024] Next, a downsampling feature extraction operation is performed on the image data through a basic feature extraction network to generate multiple single-scale feature maps at different resolution levels.

[0025] It's important to explain that downsampling feature extraction refers to the process by which the backbone network progressively compresses the spatial resolution of the input feature map through convolutional or pooling layers with a stride greater than 1, while simultaneously increasing the number of feature channels to enhance the receptive field and fuse a wider range of contextual information. Furthermore, single-scale feature maps at different resolution levels are complementary in their detection capabilities: high-resolution feature maps retain more spatial localization details, which is beneficial for accurately perceiving small foreign objects; low-resolution feature maps have a larger receptive field and stronger semantic abstraction capabilities, which is beneficial for capturing the overall shape of large foreign objects. For example, in the cookie image example, each spatial location of the 80×80 feature map corresponds to an 8×8 pixel area in the original image, capable of perceiving the edge of a metal fragment on the order of approximately 1 mm; while each spatial location of the 20×20 feature map corresponds to a 32×32 pixel area in the original image, making it more suitable for perceiving the overall shape of larger foreign objects.

[0026] Finally, channel stitching and dimensionality compression are performed on multiple single-scale feature maps at different resolution levels to generate a multi-scale basic feature tensor with a unified data dimension.

[0027] The channel concatenation operation involves upsampling feature maps from different resolution levels to the same spatial resolution and then concatenating them by channel dimensions, integrating the feature representations from each level into a single tensor. Dimensionality compression typically uses a 1×1 convolution kernel to linearly project the concatenated high-channel-count feature map, compressing the channel dimensions to a preset uniform dimension to reduce subsequent computation and eliminate dimensionality inconsistencies between different feature levels. Dimensionality compression can also be achieved through techniques such as principal component analysis (PCA) dimensionality reduction or learnable adaptive weighted fusion. For example, in the cookie image example, three sets of single-scale feature maps—80×80 (256 channels), 40×40 (512 channels), and 20×20 (1024 channels)—are upsampled to 80×80 resolution and then concatenated to obtain a 1792-channel intermediate tensor. This intermediate tensor is then compressed to 256 channels using a 1×1 convolution, ultimately generating a multi-scale basic feature tensor with dimensions 80×80×256.

[0028] Through the above technical solution, this application can transform the original image data into a feature representation that combines multi-scale spatial perception capability with a unified data format, providing a more standardized data foundation for subsequent local information entropy calculation, and helping to improve the ability to detect foreign objects of different sizes.

[0029] Step 2: Calculate the discreteness data of the feature distribution of the multi-scale basic feature tensor within the local spatial window, and generate a two-dimensional information entropy feature map that characterizes the local spatial complexity. The spatial resolution of the two-dimensional information entropy feature map is consistent with that of the multi-scale basic feature tensor.

[0030] Among them, the two-dimensional information entropy feature map refers to a two-dimensional matrix generated by quantizing the local feature distribution complexity of each spatial location of the multi-scale basic feature tensor. The value of each spatial coordinate position represents the degree of dispersion of the feature distribution of the corresponding region. The larger the value, the more complex the feature distribution of the region, which is directly related to the generation of the spatial routing mask.

[0031] It should be added that the specific process for generating a two-dimensional information entropy feature map representing local spatial complexity is as follows: The first step is to traverse the multi-scale basic feature tensor and extract the local feature matrix within the local spatial window corresponding to each central spatial coordinate using a preset window dimension.

[0032] The local spatial window refers to a rectangular neighborhood region defined in space, based on the current center spatial coordinates. The preset window dimension determines the spatial context considered during information entropy calculation. It is generally preset by staff based on historical data and empirical rules. If the window is too small, the dispersion estimation will be significantly affected by noise; if the window is too large, the spatial positioning accuracy of local feature boundaries will be blurred. The local feature matrix is ​​a matrix composed of the feature vectors of each pixel within the window arranged column-wise. Its number of rows equals the number of feature channels C, and its number of columns equals the total number of pixels N within the window. Zero-padding can be used to maintain a consistent window size for the center coordinates of the boundary positions. For example, in the cookie image example, if the preset window dimension is 3×3, then for the pixel located at coordinates (40,40) on an 80×80 feature map, the 256-dimensional feature vectors of the 9 pixels in its 3×3 neighborhood are extracted to form a local feature matrix of dimension 256×9. .

[0033] The second step is to calculate the feature covariance data of the local feature matrix in the channel dimension, and calculate the matrix determinant value, using the matrix determinant value as the discreteness data.

[0034] Feature covariance data reflects the joint distribution characteristics between and within each feature channel within a local window, and is a key statistic for measuring the degree of multidimensional dispersion of feature distributions. Let the local feature matrix be... Where C is the number of feature channels and N is the number of pixels within the local window, the features of each channel are first centered to obtain the center matrix. Then calculate the feature covariance matrix: ; covariance matrix determinant This refers to the discreteness data. The determinant value represents the volume element of the covariance matrix, and its geometric meaning is the hyperellipsoidal volume occupied by the feature distribution in C-dimensional space. The larger the value, the more dispersed the feature distribution in the local region, that is, the higher the local spatial complexity. Alternative discreteness measures include the covariance matrix trace or the maximum eigenvalue, etc., with different measures focusing on computational efficiency and sensitivity to complexity. Taking the local feature matrix at coordinates (52, 38) of the metal fragment region in the cookie example as an example, let C=256, N=9, after centering, its covariance matrix is... determinant This reflects the difference between the feature distribution of the metal fragment region and the surrounding background; while the uniform texture region inside the cookie at coordinates (20,20) shows... This indicates that the feature vector distribution in this region is highly consistent and the local complexity is low.

[0035] The third step is to perform numerical normalization on the discrete data corresponding to all the central spatial coordinates, and then splice them together in the order of the original spatial coordinates to generate a two-dimensional information entropy feature map.

[0036] It should be noted that numerical normalization processes reduce the discreteness of data at each spatial location. Mapping to a unified numerical range eliminates comparison inaccuracies caused by differences in the magnitude of feature values ​​across different regions. The normalization formula is as follows: ; in and These are the minimum and maximum values ​​of the spatial dispersion data for all locations in the current image, respectively. (Normalized) Arranged in the same spatial coordinate order as the multi-scale basic feature tensor, a two-dimensional information entropy feature map of dimension H×W is generated, where H and W are the spatial height and width of the multi-scale basic feature tensor, respectively. Continuing with the cookie example, let... , After normalization, the charred edge region (d=1.60) has an E=0.85, the uniform background region (d=0.08) has an E=0.03, and the metal fragment region (d=1.78) has an E=0.95. These regions exhibit the highest complexity response in the two-dimensional information entropy feature map, and there are still distinguishable numerical differences between them and the normal charred food region (E=0.85).

[0037] Through the above technical solution, this application quantifies the complex local feature distribution of each spatial location of the multi-scale basic feature tensor into a unified and comparable numerical representation, and generates a two-dimensional information entropy feature map aligned with the spatial dimension of the feature tensor. This not only helps to provide more accurate spatial guidance signals for the adaptive feature diversion decision of the subsequent routing gating network, but also helps to achieve fine differentiation between the boundary region of foreign objects and the normal texture region of food.

[0038] The above process establishes a quantitative representation of the local feature complexity at various spatial locations in an image. The core difference between foreign objects in food and the food background lies not only in basic visual attributes such as color or brightness, but also in the differential structure of local feature distribution: the feature vectors of foreign object regions often exhibit a distribution pattern (high dispersion) that is drastically different from the surrounding food background in the channel dimension, while the feature vectors of normal textured food regions show strong distribution consistency (low dispersion). By generating a two-dimensional information entropy feature map with a spatial resolution consistent with the multi-scale basic feature tensor, the subsequent routing gating network can dynamically split feature regions with pixel precision, achieving higher-precision adaptive routing.

[0039] Step 3: Input the two-dimensional information entropy feature map into the routing gating network to generate the spatial routing mask for the corresponding spatial location.

[0040] Among them, the spatial routing mask refers to the probability matrix generated by the routing gating network based on the two-dimensional information entropy feature map, which has the same spatial resolution as the multi-scale basic feature tensor. Its value range is within a preset data range (usually [0, 1]), and it is used to softly partition the feature attribution of each spatial location of the feature tensor, driving the separation of high-entropy feature streams and low-entropy feature streams.

[0041] Step four: Partition the multi-scale basic feature tensor using a spatial routing mask to obtain high-entropy feature streams and low-entropy feature streams.

[0042] Among them, the high-entropy feature flow refers to the set of feature data with high local information complexity extracted from the multi-scale basic feature tensor according to the spatial routing mask; the low-entropy feature flow refers to the set of remaining feature data with low information complexity in the multi-scale basic feature tensor. Together, they cover the feature information of all spatial locations in the entire graph.

[0043] Preferably, the multi-scale basic feature tensor is partitioned using a spatial routing mask to obtain a high-entropy feature stream and a low-entropy feature stream. The specific process is as follows: Based on the routing gating network, feature mapping transformation is performed on the two-dimensional information entropy feature map and a nonlinear activation function is applied to output a probability matrix whose numerical range is within a preset data range. The probability matrix is ​​then used as a spatial routing mask.

[0044] Specifically, the routing gating network transforms the feature mapping of the two-dimensional information entropy feature map by mapping the single-channel information entropy input to an intermediate feature representation through a learnable convolutional layer, and then compressing it to a single-channel output; the non-linear activation function can be the Sigmoid function. The mapping results are reduced to the [0,1] interval, and the probability that each spatial location belongs to the high-entropy feature flow is output, i.e., the spatial routing mask. The routing gating network can adopt a lightweight design (such as 1×1 convolution followed by a sigmoid activation function) to reduce additional computational overhead. Its learnable parameters are optimized based on the supervision signal of the foreign object detection task during end-to-end training. For example, in the cookie example, the routing gating network generates routing probability values ​​for 80×80 spatial locations of the two-dimensional information entropy feature map. The spatial routing mask value corresponding to the metal fragment region is 0.92, that of the charred edge region of the cookie is 0.78, and that of the uniform background region is 0.12, thus reflecting the feature routing tendency of different regions through numerical differences.

[0045] The system extracts the spatial coordinates of targets whose values ​​in the spatial routing mask exceed a third preset threshold. This third preset threshold is a key parameter controlling the boundary between high-entropy and low-entropy feature flows. Its value determines the proportion of spatial locations included in the high-entropy feature flow, and it is a pre-set value. Setting the threshold too high can lead to some real foreign object areas being incorrectly classified into the low-entropy flow, reducing the foreign object identification capability; setting it too low will include a large number of normal texture areas in the high-entropy flow, increasing the computational burden on the graph neural network and introducing irrelevant background noise. The third preset threshold is determined by analyzing the combined performance of detection accuracy and computational cost under different thresholds on a validation set, selecting the value that optimizes detection accuracy or overall score as the final setting. For example, in the cookie example, if the third preset threshold is set to 0.5, then the set of coordinates with mask values ​​greater than 0.5 is extracted from 80×80=6400 spatial locations, including approximately 1800 coordinates of metal fragment areas and charred edge areas, accounting for 28% of the total image area.

[0046] Based on the target spatial coordinates, feature data corresponding to the location is extracted from the multi-scale basic feature tensor, and the set is used to generate a high-entropy feature stream.

[0047] Specifically, a high-entropy feature stream is an unstructured collection of feature data, consisting of feature vectors extracted from a multi-scale basic feature tensor according to the target spatial coordinates. Each element corresponds to a spatial location with high local information complexity and its 256-dimensional feature vector. This unstructured form allows subsequent graph neural networks to break free from fixed grid constraints and model features with free topological relationships as a set of nodes. For example, in the cookie example, from the 80×80×256 tensor of the multi-scale basic feature tensor, corresponding feature vectors are extracted according to 1800 target coordinates, generating a high-entropy feature stream with a shape of 1800×256.

[0048] The remaining feature data in the multi-scale basic feature tensor, excluding the high-entropy feature flow, are aggregated to generate a low-entropy feature flow.

[0049] It should be noted that the low-entropy feature flow contains feature data corresponding to spatially located positions where local features are relatively uniformly and continuously distributed in the original multi-scale basic feature tensor, mainly representing the features of the normal background texture region of food. Since the features in the low-entropy region maintain spatial continuity, the low-entropy feature flow can preserve the spatial grid structure of the original feature tensor (i.e., the tensor form of H×W×C), allowing subsequent convolutional branches to efficiently extract local receptive field features. For example, in the cookie example, the feature data corresponding to the 4600 positions (excluding the 1800 high-entropy positions) in the multi-scale basic feature tensor are preserved in the original spatial coordinate system, generating an 80×80×256 low-entropy feature flow tensor with the high-entropy coordinate positions set to zero.

[0050] Through the above technical solution, this application realizes adaptive feature splitting based on information complexity, which enables spatial locations with different feature distribution attributes to be processed differently, providing targeted data inputs for subsequent extraction of foreign object structure features and background texture features.

[0051] Step 5: Reconstruct the pixels in the high-entropy feature stream into a topological spatial graph structure data, and perform topological feature extraction and differential operation on the graph based on the graph neural network to generate the first discriminative feature.

[0052] Graph neural network processing of high-entropy feature flow primarily captures the irregular abrupt changes in the local topological space of foreign object boundary regions through graph structure modeling, thereby effectively distinguishing the complex texture of the food body from the real foreign object boundary. Conventional convolutional operations are limited by a fixed rectangular receptive field, making it difficult to perform effective topological correlation analysis on unstructured and irregularly distributed foreign object boundary regions. In contrast, graph neural networks explicitly model the semantic similarity and spatial proximity relationships between high-entropy pixels, enabling the model to perceive the topological differences between different parts within the foreign object region and between the foreign object and the surrounding background, thus generating a first discriminative feature with discriminative power.

[0053] The specific process of reconstructing pixels in the high-entropy feature stream into topological spatial graph structure data is as follows: First, extract the feature vectors corresponding to all pixel data in the high-entropy feature stream, and define each feature vector as node data in the topological spatial graph structure data.

[0054] Specifically, node data is the basic building block of the topological graph structure data. Each node corresponds to a spatial location with high local information complexity in the high-entropy feature stream, and its 256-dimensional feature vector carries the semantic information of that location. By using the feature vectors of each pixel in the high-entropy feature stream as graph nodes, rather than relying on fixed grid neighborhood relationships, the graph structure can flexibly reflect the true semantic relationships of high-entropy pixels in the feature space. For example, in the cookie example, the 1800 pixels in the high-entropy feature stream are defined as 1800 graph nodes, each carrying its corresponding 256-dimensional feature vector.

[0055] Next, the feature cosine similarity data between any two node data is calculated. If the feature cosine similarity data is greater than the fourth preset threshold, and the Euclidean distance between the two node data in the original physical image space is less than the fifth preset threshold, then a connection edge data is established between the two node data.

[0056] It should be explained that feature cosine similarity data quantifies the degree of consistency between the feature vectors of two nodes in terms of direction, and its calculation formula is as follows: ; in and These are the 256-dimensional feature vectors of nodes i and j, respectively. The L2 norm of a vector. This represents the vector dot product. When... When the feature cosine similarity between nodes i and j is greater than the fourth preset threshold and the Euclidean distance between the two nodes in the original image space is less than the fifth preset threshold, a connection edge is established between node i and node j. The fourth preset threshold controls the semantic similarity condition of the connection and can be set between 0.7 and 0.9; the fifth preset threshold controls the spatial proximity condition of the connection to prevent nodes that are far apart in space from forming a connection without physical meaning due to coincidental feature similarity. Its value can be determined according to the image resolution and the typical size of the foreign object. For example, in the cookie example, the fourth preset threshold is set to 0.8 and the fifth preset threshold is set to 15 pixels. Let the feature cosine similarity between node P (coordinates 52, 38) in the metal fragment region and its neighboring node Q (coordinates 53, 39) be 0.85 and the Euclidean distance be... If a node P meets both conditions, a PQ connection edge is established; however, the feature cosine similarity between node P and node G (coordinates 20, 20) in the uniform background region of the cookie is 0.45, which does not meet the fourth preset threshold, so a PG connection edge is not established.

[0057] Finally, based on the established node data and connection edge data, the generated adjacency matrix data and degree matrix data are denoted as topological spatial graph structure data. The adjacency matrix data is used to represent the node connection mapping relationship, and the degree matrix data is used to represent the total number of node connections.

[0058] It also needs to be explained that the adjacency matrix data It is a square matrix describing the connection relationships between nodes in a graph structure, where Let be the total number of nodes in the high-entropy feature flow. If there is a connecting edge between node i and node j, then... ,otherwise Degree matrix data It is a diagonal matrix, and its diagonal elements The adjacency matrix represents the connectivity of node i (i.e., the total number of nodes directly connected to node i). The adjacency matrix and degree matrix together constitute the topological graph structure data, which is the core input for subsequent graph Laplacian matrix calculations. For example, in the cookie example, the adjacency matrix A, consisting of 1800 nodes, has a dimension of 1800×1800, and the degree matrix D is a diagonal matrix of 1800×1800. Nodes in the densely packed metal fragment regions have higher degree values ​​(e.g., a degree value of 12) due to their interconnectivity, while nodes in the sparsely populated areas of the coking edge have relatively lower degree values ​​(e.g., a degree value of 4).

[0059] Furthermore, the first discriminative feature is generated, specifically as follows: Based on the adjacency matrix data and degree matrix data, a normalized graph Laplacian matrix is ​​generated through normalization operations.

[0060] The normalized graph Laplacian matrix is ​​a core operator in graph signal processing and graph convolution operations. It normalizes the degree of the original graph Laplacian matrix, eliminating inconsistencies in feature aggregation scales caused by differences in connectivity between nodes, thus ensuring stable numerical properties for graph convolution operations. The formula for calculating the normalized graph Laplacian matrix is: ; Where I is the identity matrix, D is the degree matrix, and A is the adjacency matrix. The inverse square root of the degree matrix, i.e., the diagonal elements are The diagonal matrix. Taking the edge between node P (degree 6) and node Q (degree 8) in the cookie example as an example, the normalized Laplacian matrix elements are: Compared to the unnormalized value of -1, this compresses the influence weight of height nodes.

[0061] The normalized graph Laplacian matrix is ​​multiplied by a preset high-frequency enhancement coefficient and combined with the identity matrix to generate a topological difference enhancement matrix.

[0062] It should be explained that the topological difference enhancement matrix is ​​the core operator used in this application to amplify the feature differences between adjacent nodes. It strengthens the signal of local topological abrupt changes in the graph structure, making the feature differences between nodes at the foreign object boundary and surrounding nodes more prominent, thereby enhancing the ability of the first discriminative feature to perceive abnormal topological changes. The formula for calculating the topological difference enhancement matrix is ​​as follows: ; in The preset high-frequency enhancement coefficient, Let I be the normalized graphical Laplacian matrix, and I be the identity matrix. High-frequency enhancement coefficients. Controlling the intensity of topological differential enhancement, The larger the value, the higher the weight of the feature difference between adjacent nodes, and the more sensitive the model is to local topological changes. If the value is too large, it may lead to instability in the characteristic values. The typical setting range is 1 to 3, and it can be optimized through foreign object detection performance on the validation set. Again, using the cookie example, let... For the edge connecting node P and node Q (with a normalized Laplace element value of approximately -0.144), the corresponding element value in the topological difference enhancement matrix is... The diagonal elements (self-join items) are This allows for the assignment of higher weights to the node's own features in subsequent matrix multiplications, while introducing differential penalties to the features of adjacent nodes to highlight local topological mutations.

[0063] The topological difference enhancement matrix, the node feature matrix composed of node data, and the learnable weight matrix of the graph neural network are multiplied together, and then the difference operation of adjacent node features is performed. A nonlinear activation function is applied to the result of the matrix multiplication operation to output the first discriminative feature used to amplify the abnormal topological mutation data.

[0064] Specifically, node feature matrix The learnable weight matrix of a graph neural network is composed of the row-order arrangement of the feature vectors of all nodes in a high-entropy feature stream. This maps the feature channel dimension C to the output dimension C'. The core calculation formula for graph convolution is: ; in It is a non-linear activation function (such as ReLU). Let H be the topological difference enhancement matrix, H be the node feature matrix, and W be the learnable weight matrix. The difference operation on the features of neighboring nodes is performed through the topological difference enhancement matrix. The off-diagonal negative term implementation: For node i, the aggregation result contains The difference between the features of node i and the features of its neighboring nodes j is multiplied by a factor of 1, thus amplifying the feature differences between node i and its neighborhood. A nonlinear activation function further performs a nonlinear transformation on the enhanced features to generate the first discriminative feature. Continuing with the cookie example, let C=256, C'=128, and the dimension of the node feature matrix H be 1800×256. The topological difference enhancement matrix... The dimension is 1800×1800, the learnable weight matrix W has a dimension of 256×128, and the matrix multiplication result has a dimension of 1800×128. After ReLU activation, it becomes the first discriminative feature. The numerical distribution of the first discriminative feature of the metal fragment region node is more significantly different from that of the food coking edge node, which reflects the amplification effect of graph convolution on the topological mutation of foreign objects.

[0065] Through the above steps, this application can leverage the topological perception capability of graph neural networks to more accurately capture the irregular boundary topological structure features of foreign object regions in high-entropy feature streams. By amplifying the feature differences between foreign object nodes and their neighbors through differential operations, it generates a first discrimination feature that is highly sensitive to abnormal topological changes, which helps to improve the ability to distinguish between irregularly shaped foreign objects and complex food textures.

[0066] Step 6: Input the low-entropy feature stream into the convolution branch to extract smooth texture features and generate the second discriminative feature.

[0067] Among them, the low-entropy feature flow corresponds to the feature data of the normal background texture region of the food, and its feature distribution has strong continuity and regularity in the spatial dimension. Convolutional branches are used to process such regions to extract low-frequency smooth texture features more efficiently, establish a stable representation of the food body background, and enable the subsequent fusion stage to more accurately distinguish the background texture region from the foreign object region identified by the first discrimination feature, avoiding misjudging the normal texture of the food as a foreign object response.

[0068] Further, a second discriminative feature is generated, and the specific steps are as follows: The low-entropy feature stream is input into a convolutional branch containing depthwise separable convolution operations. Depthwise separable convolution decomposes standard convolution into two steps: channel-wise spatial convolution and pixel-wise channel fusion convolution. This reduces computation and parameter count while maintaining feature extraction capabilities, making it suitable for more efficient inference in real-time production line inspection scenarios. For example, in the cookie example, the low-entropy feature stream (80×80×256, where high-entropy coordinates are set to zero) is input into a convolutional branch consisting of three layers of depthwise separable convolutions for processing.

[0069] By performing spatial convolution extraction on each feature channel and channel feature fusion on each pixel of the low-entropy feature stream through convolution branches, low-frequency smooth feature data is generated.

[0070] It's worth noting that the depthwise convolution extracts features independently by performing spatial convolution operations on each feature channel, capturing the local spatial texture patterns within that channel. The pointwise convolution then linearly combines the cross-channel features at each location using 1×1 convolutions, integrating the semantic information between channels to generate low-frequency smooth feature data. This low-frequency smooth feature data reflects the smooth texture distribution of low-entropy regions in the multi-channel semantic space and forms the basis for subsequent feature denoising and background representation construction. For example, in the cookie example, the feature at coordinates (20,20) of the uniform texture region in the low-entropy feature stream is extracted using a 3×3 depthwise convolution, and then fused with channel information using a 1×1 pixel-wise convolution to generate the low-frequency smooth feature vector at that location.

[0071] Perform feature denoising processing on the low-frequency smooth feature data to filter out high-frequency interference signals and output the second discrimination feature.

[0072] The purpose of feature denoising is to further filter out high-frequency noise responses that may be introduced by the low-entropy feature stream during convolution, so that the second discriminative feature can more clearly represent the smooth texture characteristics of the normal food background. Feature denoising can be achieved through operations such as batch normalization or average pooling. The former suppresses high-frequency fluctuations in activation values ​​by normalizing the feature distribution, while the latter smooths high-frequency spatial perturbations by calculating local mean. For example, in the cookie example, after applying batch normalization to the low-frequency smooth feature data, the variance of the feature vector at coordinates (20,20) of the uniform background region of the cookie decreases from 0.35 to 0.08, effectively suppressing high-frequency texture interference signals. The output second discriminative feature has a dimension of 80×80×128, which more clearly represents the smooth distribution of the food background texture.

[0073] Through the aforementioned process, this application can use computationally efficient depthwise separable convolution to extract features for the smooth texture characteristics of low-entropy regions, generating a second discriminative feature that has a stable representation ability for the normal background texture of food, which complements the first discriminative feature and provides more comprehensive image information coverage for subsequent feature fusion and decision-making.

[0074] Step 7: Based on the spatial routing mask, fuse the first and second identification features to generate a full-image fusion feature tensor.

[0075] Step seven involves re-integrating the two differentiated features generated separately for the high-complexity foreign object region and the low-complexity background region using an adaptive weighted fusion method, based on the soft partitioning weights provided by the spatial routing mask, into a full-image feature representation with complete spatial dimensions. The full-image fusion feature tensor simultaneously contains the topological structure information of the foreign object boundary (from the first discriminative feature) and the smooth texture information of the food background (from the second discriminative feature), providing complete and complementary input data for the final determination of the evidence decision network.

[0076] Specifically, the process for generating the full-image fusion feature tensor is as follows: The first identification feature and the spatial routing mask are multiplied element-wise on the corresponding spatial coordinates to obtain high-entropy weighted feature data.

[0077] It should be noted that element-wise multiplication (Hadamard product) uses the first discriminative feature... With spatial routing mask By performing corresponding scalar-vector multiplications at each spatial coordinate, the primary discriminative features of high-entropy regions (mask values ​​close to 1) are fully preserved, while the primary discriminative features of low-entropy regions (mask values ​​close to 0) are correspondingly suppressed, generating high-entropy weighted feature data. Using the cookie example again, the spatial routing mask value for the metal fragment region coordinates (52, 38) is 0.92. The 128 dimensions of the first discriminative feature vector corresponding to this coordinate are multiplied by 0.92 to retain the main information; while the mask value for the uniform background region coordinates (20, 20) is 0.12, and the first discriminative feature of this coordinate is suppressed.

[0078] Obtain a one-dimensional matrix with the same dimensions as the spatial routing mask, and calculate the difference matrix between the one-dimensional matrix and the spatial routing mask.

[0079] Specifically, a one matrix The difference matrix between (all elements are 1) and the spatial routing mask M is: Its physical meaning is the probability that each spatial location belongs to a low-entropy feature flow. Through the difference operation between the all-one matrix and the mask, the complementary duality between high-entropy and low-entropy weights is achieved. In the high-entropy region, When the value is close to 0, the contribution of low-entropy features is suppressed; in the low-entropy region, The value is close to 1, indicating that the contribution of low-entropy features is fully preserved. Taking the uniform background region coordinates (20,20) in the cookie example as an example, the mask value M=0.12, and the value of the difference matrix at this coordinate is 1-0.12=0.88, indicating that the low-entropy features have sufficient weight here.

[0080] The second discriminant feature is multiplied element-wise with the difference matrix to obtain low-entropy weighted feature data; the high-entropy weighted feature data is added element-wise with the low-entropy weighted feature data to generate a full-image fusion feature tensor with complete image spatial dimensions.

[0081] Among them, low-entropy weighted feature data This represents the texture features extracted from low-entropy regions via convolutional branches, where the weights at each spatial location are complementary to the high-entropy weighted features. The final full-image fusion feature tensor is obtained by element-wise summation: ; The above formula implements a weighted sum of the first and second discriminative features at each spatial location. The weights are dynamically determined by the spatial routing mask, ensuring that each location in the entire image is dominated by the most suitable feature representation. The full-image fused feature tensor has a complete H×W spatial dimension, providing fully covered feature input for pixel-by-pixel classification in the evidence decision network. Taking the cookie example, at coordinates (52, 38) (the metal fragment region), the fused features... The first distinguishing feature is dominant; in coordinates (20, 20) (uniform background region), the fused features... The second discriminative feature dominates, generating a full-image fusion feature tensor with dimensions of 80×80×128.

[0082] The above process enables the fusion of foreign object perception features and background texture features in an adaptive weighted manner based on the soft weights provided by the spatial routing mask. This generates a full-image fusion feature tensor that takes into account both the structural information of the foreign object and the integrity of the background texture, which helps to avoid the limitations of a single feature extraction strategy in complex scenarios.

[0083] Step 8: Input the full-image fusion feature tensor into the evidence decision network, and calculate the category decision confidence of each pixel and the cognitive uncertainty representing the cognitive state of the model.

[0084] Among them, the Evidence Decision Network refers to the decision-making layer network built on the Evidential Deep Learning framework. Its core lies in interpreting the output of the neural network as hyperparameters of the Dirichlet distribution, thereby simultaneously outputting the class decision confidence of each detection category and the cognitive uncertainty reflecting the cognitive state of the model, so as to achieve a quantitative evaluation of the reliability of the model's decision.

[0085] Step eight achieves the extraction of a decision output from the full-image fusion feature tensor that combines class determination and uncertainty quantification capabilities, providing a more reliable confidence basis for the generation of the final interception command. Traditional Softmax classifiers can only output normalized class probabilities and cannot distinguish between "high-confidence positive class prediction" and "uniform low-confidence prediction." The former represents the model's clear determination of a foreign object, while the latter represents the model's insufficient understanding of the sample. Furthermore, an evidence-based decision network framework is introduced, using Dirichlet distribution parameters to simultaneously express class determination confidence and cognitive uncertainty. This allows the system to trigger a conservative interception strategy when model confidence is insufficient (high cognitive uncertainty), further reducing the probability of missed detections.

[0086] The specific process for calculating the category confidence score for each pixel and the cognitive uncertainty representing the model's cognitive state is as follows: A1 inputs the full-image fusion feature tensor into the output mapping layer of the evidence decision network and applies a non-negative activation function to obtain non-negative initial evidence feature data.

[0087] Specifically, the output mapping layer maps each spatial location of the full-image fusion feature tensor to a K-dimensional output (K being the preset number of detection categories) through a fully convolutional network. Then, a non-negative activation function (such as ReLU or Softplus) is used to constrain the output to a non-negative value, resulting in non-negative initial evidence feature data. (k=1,...,K); For example, in the cookie example, K=3 (categories are: background, normal charred texture, and metallic foreign object), for the metal fragment region coordinates (52,38), the output mapping layer outputs the initial evidence feature data after ReLU activation. , , Among them, the strength of evidence for Category 3 (metallic foreign bodies) is higher than that for the other categories.

[0088] A2, add a preset constant to the initial evidence feature data corresponding to each category to calculate the corresponding Dirichlet distribution parameters.

[0089] It should be noted that the Dirichlet distribution is the conjugate prior distribution of the multinomial distribution, and its parameters... (k=1,...,K) controls the prior distribution shape of the probabilities of each class; a larger value indicates a higher confidence level of the model in that class. The Dirichlet distribution parameters are obtained by adding a preset constant of 1 to the initial evidence feature data: ; A preset constant of 1 corresponds to a uniform prior, ensuring that the Dirichlet distribution parameters for each category are greater than 1, thus guaranteeing a valid mathematical definition of the Dirichlet distribution. Taking the cookie example with coordinates (52, 38), the Dirichlet distribution parameters are... , , .

[0090] A3. Calculate the sum of the Dirichlet distribution parameters corresponding to all preset detection categories to obtain the total evidence strength data.

[0091] Wherein, the total evidence strength data S represents the sum of all categories of evidence accumulated by the model for the current pixel, and its calculation formula is: ; A4. Divide the Dirichlet distribution parameter corresponding to each category by the total evidence strength data to generate the category determination confidence score.

[0092] Among them, the confidence level of category determination Let be the expected probability of the corresponding class in the Dirichlet distribution, and its calculation formula is: ; A5 divides the preset number of detection categories by the total evidence strength data to generate cognitive uncertainty.

[0093] It should be added that the cognitive uncertainty u reflects the overall uncertainty of the model in determining the current pixel's attribution, and its calculation formula is as follows: ; Where K is a constant representing the number of detection categories. When S is large (the model has accumulated sufficient evidence), u approaches 0, and the model's judgment is highly reliable. When S is close to K (all kinds of evidence are weak), u approaches 1, and the model's judgment on the pixel is highly uncertain, reflecting insufficient cognition.

[0094] For example, taking the cookie example with coordinates (52, 38), K=3. Confidence level of category determination , , (Type 3 metallic foreign objects have the highest confidence level), cognitive uncertainty This indicates that the model's determination of this location has a certain degree of confidence but still has some uncertainty. For the uniform background region of the biscuit (20, 20), if the initial evidence feature data is... , , Therefore, S = 7.35. (The background class has the highest confidence level), u=3 / 7.35≈0.41, indicating that the model's determination of the background at this location is relatively reliable.

[0095] The above steps enable the evidence-based decision network framework to simultaneously output the category confidence and cognitive uncertainty of each pixel, quantifying the model's decision credibility and providing a comprehensive basis for subsequent dual-threshold interception judgments. This helps to trigger conservative interception strategies and reduce the false negative rate in boundary situations where confidence is insufficient.

[0096] Step 9: Compare the category determination confidence with the first preset threshold, and compare the cognitive uncertainty with the second preset threshold. If the category determination confidence is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, then generate a physical interception command and output the foreign object rejection result.

[0097] It should be noted that step nine is the final decision-making stage in the entire food foreign object detection process. Its purpose is to construct a dual-threshold judgment mechanism based on the dual metrics output by the evidence decision network, using a logical "OR" relationship, to simultaneously reduce both the false positive and false negative rates. The first preset threshold controls the interception sensitivity of the category determination confidence dimension: when the category determination confidence of the foreign object exceeds the first preset threshold, it indicates that the model has accumulated sufficient evidence to determine that the location is a foreign object, triggering interception. The second preset threshold controls the conservative interception of the cognitive uncertainty dimension: when the cognitive uncertainty exceeds the second preset threshold, it indicates that the model's determination of the location has a high degree of uncertainty, and for the principle of food safety protection, an interception command is also triggered.

[0098] Specifically, the first and second preset thresholds can be determined by designated personnel by plotting a precision-recall curve on the labeled dataset and selecting the threshold combination corresponding to the optimal operating point that meets the production line safety standards. Taking the cookie example, let the first preset threshold be 0.6 and the second preset threshold be 0.7. For the metal fragment region coordinates (52, 38). (If the first preset threshold condition is met), a physical interception command is triggered; for the coordinates (62, 45) of the charred edge region, if (The confidence level condition is not met) but (If the uncertainty condition is met), the conservative interception command is also triggered, and the result of foreign object rejection is output.

[0099] Secondly, if the false detection rate is too high in actual production, the first preset threshold can be appropriately increased or the second preset threshold can be decreased; if the false detection rate is too high, the opposite adjustment should be made. After the physical interception command is triggered, the system sends a rejection control signal to the production line robotic arm or valve and other actuators to remove the corresponding food from the production line and output the foreign object rejection result.

[0100] like Figure 2 The diagram shown is a structural schematic of a food foreign object detection system based on information entropy dynamic routing and graph convolution provided in an embodiment of this application, including: The food data acquisition module is used to acquire image data of the food to be detected and input the image data into the basic feature extraction network to extract multi-scale basic feature tensors.

[0101] The food data processing module is used to calculate the discreteness data of the feature distribution of the multi-scale basic feature tensor within a local spatial window, and generate a two-dimensional information entropy feature map representing the local spatial complexity. The spatial resolution of the two-dimensional information entropy feature map is consistent with that of the multi-scale basic feature tensor. The two-dimensional information entropy feature map is input into a routing gating network to generate a spatial routing mask for the corresponding spatial location. The multi-scale basic feature tensor is partitioned using the spatial routing mask to obtain a high-entropy feature stream and a low-entropy feature stream.

[0102] The graph convolutional data fusion module reconstructs pixels in the high-entropy feature stream into a topological spatial graph structure, and performs topological feature extraction and differential operation on the graph neural network to generate the first discriminative feature. The low-entropy feature stream is input into the convolutional branch to extract smooth texture features and generate the second discriminative feature. Based on the spatial routing mask, the first and second discriminative features are fused to generate a full-graph fusion feature tensor. The full-graph fusion feature tensor is input into the evidence decision network to calculate and output the category decision confidence of each pixel and the cognitive uncertainty representing the cognitive state of the model.

[0103] The foreign object result output module is used to compare the category determination confidence with the first preset threshold and the cognitive uncertainty with the second preset threshold. If the category determination confidence is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, a physical interception command is generated and the foreign object rejection result is output.

[0104] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)). Where there is no conflict, the solutions in the above embodiments can be combined.

[0105] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0109] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A food foreign matter detection method based on information entropy dynamic routing and graph convolution, characterized in that, Includes the following steps: Image data of the food to be detected is acquired and input into a basic feature extraction network to extract multi-scale basic feature tensors; Calculate the discreteness data of the feature distribution of the multi-scale basic feature tensor within the local spatial window, and generate a two-dimensional information entropy feature map characterizing the local spatial complexity. The two-dimensional information entropy feature map is input into the routing gating network to generate a spatial routing mask corresponding to the spatial location to divide the multi-scale basic feature tensor, thereby obtaining a high-entropy feature stream and a low-entropy feature stream. The pixels in the high-entropy feature stream are reconstructed into topological space graph structure data to generate the first discriminative feature, and the low-entropy feature stream is input into the convolution branch to generate the second discriminative feature; Based on the spatial routing mask, the first identification feature and the second identification feature are fused to generate a full-image fusion feature tensor, which is then input into the evidence decision network to calculate and output the category judgment confidence of each pixel and the cognitive uncertainty representing the cognitive state of the model. The confidence level of the category determination is compared with a first preset threshold, and the cognitive uncertainty is compared with a second preset threshold. If the confidence level of the category determination is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, a physical interception command is generated and the foreign object rejection result is output.

2. The food foreign matter detection method based on information entropy dynamic routing and graph convolution of claim 1, wherein: The extraction of the multi-scale fundamental feature tensor involves the following specific steps: The image data is input into the basic feature extraction network that includes a feature pyramid structure; The image data is subjected to downsampling feature extraction operation through the basic feature extraction network to generate multiple single-scale feature maps at different resolution levels; Channel splicing and dimensionality compression are performed on the multiple single-scale feature maps with different resolution levels to generate the multi-scale basic feature tensor with a unified data dimension.

3. The food foreign matter detection method based on information entropy dynamic routing and graph convolution of claim 1, wherein: The specific process for generating the two-dimensional information entropy feature map representing local spatial complexity is as follows: Traverse the multi-scale basic feature tensor and extract the local feature matrix within the local spatial window corresponding to each center spatial coordinate using a preset window dimension; Calculate the feature covariance data of the local feature matrix in the channel dimension, and calculate the matrix determinant value, and use the matrix determinant value as the discreteness data; The discrete data corresponding to all the central spatial coordinates are numerically normalized, and then spliced ​​together according to the original spatial coordinate order to generate the two-dimensional information entropy feature map. The spatial resolution of the two-dimensional information entropy feature map is consistent with the multi-scale basic feature tensor.

4. The food foreign matter detection method based on information entropy dynamic routing and graph convolution of claim 1, wherein: The specific process for obtaining the high-entropy feature stream and the low-entropy feature stream is as follows: Based on the routing gating network, the two-dimensional information entropy feature map is transformed by feature mapping and a nonlinear activation function is applied to output a probability matrix whose value range is within a preset data range. The probability matrix is ​​used as the spatial routing mask. Extract the spatial coordinates of targets whose values ​​are greater than a third preset threshold from the spatial routing mask; Based on the target spatial coordinates, feature data corresponding to the location is extracted from the multi-scale basic feature tensor, and the set is used to generate the high-entropy feature stream. The remaining feature data in the multi-scale basic feature tensor, excluding the high-entropy feature flow, are collected to generate the low-entropy feature flow.

5. The food foreign object detection method based on information entropy dynamic routing and graph convolution of claim 1, wherein: The specific process of reconstructing the pixels in the high-entropy feature stream into topological spatial graph structure data is as follows: Extract the feature vectors corresponding to all pixel data in the high-entropy feature stream, and define each feature vector as node data in the topological spatial graph structure data; Calculate the feature cosine similarity data between any two node data. If the feature cosine similarity data is greater than a fourth preset threshold and the Euclidean distance between the two node data in the original physical image space is less than a fifth preset threshold, then establish connection edge data between the two node data. Based on the established node data and connection edge data, adjacency matrix data and degree matrix data are generated. The adjacency matrix data and degree matrix data are denoted as the topological space graph structure data. The adjacency matrix data is used to represent the node connection mapping relationship, and the degree matrix data is used to represent the total number of node connections.

6. The food foreign object detection method based on information entropy dynamic routing and graph convolution as described in claim 5, characterized in that: The first discriminative feature is generated in the following specific manner: Based on the adjacency matrix data and the degree matrix data, a normalized graph Laplacian matrix is ​​generated through normalization operations; The normalized graph Laplacian matrix is ​​multiplied by a preset high-frequency enhancement coefficient and combined with the identity matrix to generate a topological difference enhancement matrix. The topological difference enhancement matrix, the node feature matrix composed of the node data, and the learnable weight matrix of the pre-trained graph neural network are multiplied together, and then the difference operation of the adjacent node features is performed. A nonlinear activation function is applied to the result data of the matrix multiplication operation to output the first discriminative feature.

7. The food foreign object detection method based on information entropy dynamic routing and graph convolution as described in claim 1, characterized in that: The specific steps for generating the second discriminative feature are as follows: The low-entropy feature stream is input into the convolution branch that includes a depthwise separable convolution operation; The convolutional branch sequentially performs channel-wise spatial convolution extraction and pixel-wise channel feature fusion on the low-entropy feature stream to generate low-frequency smooth feature data. The low-frequency smooth feature data is subjected to feature noise reduction processing to filter out high-frequency interference signals, and the second discrimination feature is output.

8. The food foreign object detection method based on information entropy dynamic routing and graph convolution as described in claim 1, characterized in that: The specific process for generating the full-image fusion feature tensor is as follows: The first identification feature and the spatial routing mask are multiplied element-wise on the corresponding spatial coordinates to obtain high-entropy weighted feature data; Obtain a one-dimensional matrix with the same dimensions as the spatial routing mask, and calculate the difference matrix between the one-dimensional matrix and the spatial routing mask; The second discriminant feature is multiplied element-by-element by the difference matrix to obtain low-entropy weighted feature data; The high-entropy weighted feature data and the low-entropy weighted feature data are added element by element to generate the full-image fusion feature tensor with complete image spatial dimensions.

9. The food foreign object detection method based on information entropy dynamic routing and graph convolution as described in claim 1, characterized in that: The specific process for calculating the category confidence score for each pixel and the cognitive uncertainty representing the model's cognitive state is as follows: The full-image fusion feature tensor is input into the output mapping layer of the evidence decision network, and a non-negative activation function is applied to obtain non-negative initial evidence feature data; Add a preset constant to the initial evidence feature data corresponding to each category to calculate the corresponding Dirichlet distribution parameters; The total evidence strength data is obtained by calculating the sum of the values ​​of the Dirichlet distribution parameters corresponding to all preset detection categories. The confidence level of the category determination is generated by dividing the Dirichlet distribution parameter corresponding to each category by the total evidence strength data. The cognitive uncertainty is generated by dividing the preset number of detection categories by the total evidence strength data.

10. A food foreign object detection system based on information entropy dynamic routing and graph convolution, characterized in that: include: The food data acquisition module is used to acquire image data of the food to be detected, and input the image data into the basic feature extraction network to extract multi-scale basic feature tensors; The food data processing module is used to calculate the discreteness data of the feature distribution of the multi-scale basic feature tensor within a local spatial window, and generate a two-dimensional information entropy feature map characterizing the local spatial complexity; the two-dimensional information entropy feature map is input into a routing gating network to generate a spatial routing mask corresponding to the spatial location to divide the multi-scale basic feature tensor, thereby obtaining a high-entropy feature stream and a low-entropy feature stream. The graph convolutional data fusion module is used to reconstruct the pixels in the high-entropy feature stream into topological spatial graph structure data to generate the first discriminative feature, and input the low-entropy feature stream into the convolutional branch to generate the second discriminative feature; Based on the spatial routing mask, the first identification feature and the second identification feature are fused to generate a full-image fusion feature tensor, which is then input into the evidence decision network to calculate and output the category judgment confidence of each pixel and the cognitive uncertainty representing the cognitive state of the model. The foreign object result output module is used to compare the category determination confidence with a first preset threshold and the cognitive uncertainty with a second preset threshold. If the category determination confidence is greater than the first preset threshold or the cognitive uncertainty is greater than the second preset threshold, a physical interception command is generated and the foreign object rejection result is output.

Citation Information

Patent Citations

  • A food foreign object detection method and system based on deep learning

    CN119992540B

  • Protein structure classification detection method and device based on minimum information structure entropy

    CN116738290A

  • Food deterioration detection method and system based on image processing

    CN118397617A

  • Traditional Chinese medicine analysis and identification method and system based on clustering analysis

    CN120387104A

  • Intelligent detection method and system for abnormal mode of transient recording signal of power system

    CN121679198A