A machine learning-based method and system for rapid detection of salmonella in food

CN122598171BActive Publication Date: 2026-10-09SHANDONG INST FOR FOOD & DRUG CONTROL
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611096163.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-09
Estimated Expiration
2046-07-23

AI Technical Summary

Technical Problem

[0004]本发明为解决现有图像分析检测方法存在的特征提取效率低、模型泛化能力不足和识别率不高的问题,提出一种基于机器学习的食品中沙门氏菌快速检测方法和系统,实现高效的特征提取和模型自动化检测

Benefits of technology

通过食品基质自适应预处理模块,对背景进行建模与分离,增强目标区域的对比度和细节,同时抑制背景噪声,提高沙门氏菌区域与背景区域的可分离性;采用沙门氏菌形态先验编码模块,对符合尺寸范围和外接矩形约束的候选区域进行筛选,突出沙门氏菌短杆状及方向连续等典型形态特征,提高模型对沙门氏菌典型形态的表达能力;通过多尺度候选菌体感知模块,对来自预处理特征和形态先验编码特征的信息进行联合分析,能够兼顾细粒度边缘、标准杆状形态及局部聚集区域信息,提高候选区域提取能力;采用菌体-杂质解耦判别模块,同时利用编码特征中的形态先验信息和多尺度特征中的候选区域信息,通过全局上下文建模、局部特征调制及加权解耦运算增强目标与杂质之间的差异表达,降低误检率;通过证据累积验证模块和多证据融合决策模块,能够提高检测结果的全局稳定性和最终输出精度;构建复合损失函数训练及自动标记输出,实现对食品中沙门氏菌的快速、准确、自动化检测。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122598171B_ABST
    Figure CN122598171B_ABST
Patent Text Reader

Abstract

The application provides a kind of machine learning-based rapid detection method and system of salmonella in food, it is related to computer vision field.Specifically including: collecting food microscopic image, constructs microscopic input image;Microscopic input image is input adaptive pre-processing module, obtains pre-processing feature after background separation, contrast and edge enhancement, denoising;The prior information of pre-processing feature is extracted through candidate connected domain, and is added with pre-processing feature and is encoded, then is aligned, is analyzed to obtain multi-scale feature through multi-branch convolution and enhancement function joint;Bacterial body-impurity decoupling discrimination module is constructed, the differentiation decoupling discrimination of target and impurity is realized, and discrimination feature is obtained;Evidential accumulation module is constructed to jointly statistics multi-scale feature, and the output result is threshold segmentation after being enhanced by multi-evidence fusion.The application can effectively inhibit the interference of complex food matrix background, enhance the morphological expression of salmonella, and improve the accuracy and stability of detection in complex scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, and more specifically to a rapid detection method and system for Salmonella in food based on machine learning. Background Technology

[0002] Salmonella is a common foodborne pathogen widely found in meat, egg products, dairy products, and ready-to-eat foods. It is a significant cause of food poisoning and public health emergencies. Ingestion of food contaminated with Salmonella can lead to symptoms such as diarrhea, fever, and gastroenteritis, and in severe cases, can be life-threatening. Therefore, rapid and accurate detection of Salmonella in food is crucial for food safety supervision, food production process control, and public health prevention and control. Currently, methods for detecting Salmonella in food mainly include traditional culture methods, immunological detection methods, and molecular biological detection methods. Among these, traditional culture methods, which involve culturing on selective media and identifying colonies, are considered the "gold standard" for Salmonella detection. However, this method has a long detection cycle, typically requiring 2-5 days to obtain results, which is insufficient to meet the food industry's demand for rapid detection. Immunological detection methods (such as enzyme-linked immunosorbent assay) and molecular biological methods (such as PCR) have improved detection speed to some extent, but they still suffer from problems such as complex sample pretreatment, high detection costs, and strong dependence on specialized equipment and technicians, which limit their application in large-scale food safety monitoring. In recent years, with the development of computer vision and machine learning technologies, using image information for microbial detection has gradually become an emerging research direction. For example, by acquiring images of microbial colonies or cell morphology through a microscopic imaging system, and then using machine learning algorithms to extract and classify image features, the identification and detection of target microorganisms can be achieved.

[0003] However, existing image analysis-based detection methods still have certain shortcomings in the field of food microbiology detection, such as low efficiency of image feature extraction, low accuracy of identification against complex food matrix backgrounds, and limited degree of automation, making it difficult to achieve rapid, high-precision, and stable detection of Salmonella in food. Summary of the Invention

[0004] To address the problems of low feature extraction efficiency, insufficient model generalization ability, and low recognition rate in existing image analysis and detection methods, this invention proposes a rapid detection method and system for Salmonella in food based on machine learning, achieving efficient feature extraction and automated model detection.

[0005] This invention provides a rapid detection method for Salmonella in food based on machine learning, comprising the following steps: S1. Acquire microscopic images of the food to be tested, normalize and denoise the microscopic images to obtain microscopic input images, manually mark the location of Salmonella in the microscopic images to obtain manually marked images; S2. A Gaussian mixture model is used to suppress the background and separate the matrix of the microscopic input image to obtain the foreground score. The foreground score is then subjected to local histogram equalization and edge enhancement to obtain the target enhanced image. Morphological opening is performed on the target enhanced image to filter out noise interference. A filter is used to enhance the details of the denoised image to obtain the preprocessed features. S3. A morphological prior coding module is constructed based on a candidate connected component extraction component and a coding mapping unit to obtain candidate regions from preprocessed features and jointly encode the candidate region information with the preprocessed features to obtain coded features; the candidate connected component extraction component includes two parts: normalization and adaptive threshold segmentation, which are used to extract prior information of typical Salmonella morphology; a multi-scale candidate cell perception module is constructed based on an alignment component, a multi-branch convolutional perception component, and a candidate cell enhancement function to extract candidate cell regions from preprocessed features and coded features to obtain multi-scale features; S4. By using the cell-impurity decoupling discrimination module, combined with global context modeling and local feature modulation, differential decoupling discrimination is performed on Salmonella targets and background impurities to obtain discrimination features; S5. The evidence parameters are formed by statistically analyzing the response intensity, local consistency, and global saliency of each spatial location and channel in the multi-scale features through the evidence accumulation and verification module; the preprocessed features, discriminant features, and evidence parameters are jointly fused to obtain evidence enhancement features; the evidence enhancement features are judged by threshold segmentation to obtain the output image. S6. Construct a joint loss function based on binary cross-entropy loss, region overlap loss and boundary consistency loss, backpropagate the model, update the parameters, and obtain the trained detection model. S7. An automatic labeling module is constructed through connected component analysis to extract the foreground region in the output image, resulting in visualized and structured detection results.

[0006] As a further technical solution, S3 specifically includes: The preprocessed features are normalized to obtain a normalized feature map. Then, adaptive threshold segmentation is used to obtain a set of candidate regions. The threshold value is determined as follows: In the formula, Represented by pixels The local mean of a neighborhood centered at a size of 15×15 pixels. This represents the local standard deviation of the corresponding neighborhood. The candidate region set and preprocessed features are added together along the channel dimension and input into the encoding mapping unit to obtain the encoded features; the encoding mapping unit consists of one 1×1 convolutional unit, two 3×3 convolutional units and one sigmoid activation unit connected in series. The encoded features are input into the alignment component to obtain the aligned features; the alignment component consists of a 1×1 convolutional unit, a batch normalization unit and a ReLU activation unit connected in series, which performs channel compression and scale alignment on the encoded features; The preprocessed features and aligned features are concatenated along the channel dimension to obtain the joint input features; The joint input features are input into a multi-branch convolutional sensing component to obtain spliced ​​features; the multi-branch convolutional sensing component includes parallel small-scale branches, medium-scale branches and large-scale branches, which respectively sense the fine-grained edges, standard rod-shaped morphology and local aggregation region information of Salmonella. A candidate cell enhancement function based on spatial entropy suppression and channel competition reconstruction is constructed as follows: In the formula, Representing multi-scale features, Indicates splicing features in The element at position, Indicates the competition weights of the splicing feature channels; By inputting the spliced ​​features into the candidate cell enhancement function based on spatial entropy suppression and channel competition reconstruction, multi-scale features are obtained.

[0007] As a further technical solution, S4 specifically includes: Construct a cell-impurity decoupling discrimination module, the specific expression of which is: In the formula, Indicates discriminative features in Location feature value Indicates the location of the encoded feature and the eigenvalues ​​at channel c, Indicates multi-scale features at location The eigenvalues ​​at channel c and M and N represent the width and height of the feature map, respectively. The operator ⊙ represents element-wise multiplication. This represents the learnable weight coefficient located at the m-th row and n-th column. This indicates a global context modeling operation performed on the encoded features. These are global weights learned through context. This indicates local feature modulation of multi-scale features. These are weights learned locally; The cell-impurity decoupling discrimination module significantly enhances the distinction between Salmonella targets and background impurities based on coding features and multi-scale features, thereby obtaining discrimination features.

[0008] As a further technical solution, S1 specifically includes: Microscopic images of the food to be tested were acquired using an optical microscope as the original images. The original images were first normalized, then Gaussian function was used to remove image noise, and finally the areas containing Salmonella were manually selected and the images were cropped to obtain the cropped images. The Otsu thresholding method was used to separate the Salmonella region and the background region in the cropped image to obtain the microscopic input image; Manually annotate each location of Salmonella on photographs of the same size to obtain manually annotated images.

[0009] As a further technical solution, S2 specifically includes: The Gaussian mixture model is used to segment the microscopic input image to obtain background and foreground information. Local histogram equalization is used to enhance the contrast of each image patch of foreground information, and then the Sobel operator is used to filter out the image edges to obtain the target enhanced image; The target enhanced image is subjected to morphological opening operation to remove noise points, and then a Laplacian filter is used to enhance the details of the image to obtain preprocessed features.

[0010] As a further technical solution, S5 specifically includes: Construct an evidence accumulation and verification module. When the multi-scale feature size is H×W×C, then the evidence parameters... The mathematical representation of is: In the formula, This represents the feature response value of the multi-scale feature map at position (x, y) and channel c. This represents the mean of the c-th channel across the entire space. and Let represent the first-order discrete gradients of the feature map along the horizontal and vertical axes in the c-th channel, respectively. It is the Sigmoid activation function, which compresses the final result to the interval [0,1]. The evidence parameters are obtained from the multi-scale features through the evidence accumulation and verification module; The discriminative features are averaged along the channel dimension to obtain a single-channel discriminative response map. The preprocessed features are then fused with the single-channel discriminative response map using a weighted summation method to obtain the fused input features. By combining the evidence parameters, scalar multiplication is used to enhance the fused input features, resulting in evidence-enhanced features; The evidence enhancement features are determined using a fixed threshold segmentation method, resulting in a binary output image. The formula is as follows: In the formula, Point Evidence enhancement feature value at the location, This represents a binary output image; When the pixel value is 255, it indicates that the location is identified as a Salmonella target area. When the pixel value is 0, it indicates that the location is identified as a background area or a non-target area.

[0011] As a further technical solution, S6 specifically includes: The total loss function is constructed based on binary cross-entropy loss, region overlap loss, and boundary consistency constraint loss. The detection model is updated using the Adam optimizer combined with backpropagation to obtain the trained detection model.

[0012] As a further technical solution, S7 specifically includes: The automatic labeling module uses connected component analysis to perform an 8-neighbor connected component search on the region with a pixel value of 255 in the output image to extract each independent foreground region. Then, it calculates the bounding rectangle, center coordinates, and area parameters of each independent foreground region and retains the connected components that meet the area threshold condition as valid detection targets to obtain the detection results.

[0013] This invention also provides a machine learning-based rapid detection system for Salmonella in food, comprising: Data acquisition module: used to acquire microscopic images of food, and construct microscopic input images and manually annotated images; Data augmentation module: used to enhance image details, improve the separability of Salmonella regions from background regions, and obtain preprocessed features; Feature extraction module: used to extract features from the image, highlight the morphological features of Salmonella, enhance the differential expression between Salmonella and impurities, and obtain discriminative features; Model building module: used to build the evidence accumulation and verification module and the multi-evidence fusion decision module to obtain the detection model; Model training module: used to construct the total loss function, train the detection model, update parameters, and obtain the trained detection model; Online detection module: Used to build an automatic labeling module and deploy the trained detection model to detect Salmonella in real-time acquired images and label specific areas.

[0014] The present invention also provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement a machine learning-based rapid detection method for Salmonella in food.

[0015] Beneficial effects of this invention: An adaptive preprocessing module for food matrix is ​​used to model and separate the background, enhancing the contrast and detail of the target area while suppressing background noise and improving the separability of Salmonella regions from the background. A Salmonella morphology prior encoding module is employed to screen candidate regions that meet the size range and bounding rectangle constraints, highlighting typical morphological features such as the short rod shape and continuous orientation of Salmonella, thus improving the model's ability to represent typical Salmonella morphology. A multi-scale candidate cell perception module jointly analyzes information from preprocessed features and morphology prior encoding features, taking into account both fine-grained edges and details. Standard rod-shaped morphology and local aggregation region information enhance candidate region extraction capabilities; a cell-impurity decoupling discrimination module is employed, utilizing morphological prior information from encoded features and candidate region information from multi-scale features. Through global context modeling, local feature modulation, and weighted decoupling operations, the differential expression between targets and impurities is enhanced, reducing the false detection rate; an evidence accumulation and verification module and a multi-evidence fusion decision module improve the global stability of detection results and the accuracy of the final output; a composite loss function is constructed for training and automatic labeling output, enabling rapid, accurate, and automated detection of Salmonella in food. Attached Figure Description

[0016] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.

[0017] Figure 1 This is a schematic diagram of the process of the present invention; Figure 2 This is a comparison chart of the detection results of this invention and the detection results of other methods; Figure 2 (a) is the original microscopic image. Figure 2 (b) is the actual target area marked manually. Figure 2 (c)- Figure 2 (f) shows the detection results of traditional threshold segmentation, U-Net, DeepLabV3+, and the method of this invention, respectively. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] S1. Data Acquisition and Preprocessing (1) Image acquisition was performed using a Nikon EclipseTi2 optical microscope with a resolution of 0.1µm. The microscope light source was an LED white light source with a brightness of 50%. A 20x objective lens and a 50x objective lens were selected. The image acquisition resolution was set to 2048×2048 pixels and the exposure time was set to 10ms.

[0020] (2) The original image was first normalized to the range [0, 255] using the OpenCV cv2.normalize() function. Then, a 3x3 Gaussian kernel with a standard deviation of σ=1.5 was used to remove image noise using the OpenCV cv2.GaussianBlur() function. Finally, the region of interest containing Salmonella was manually selected using the OpenCV cv2.selectROI() function and cropped to a 512×512 pixel image. .

[0021] (3) Use the Otsu thresholding method to threshold the image The Salmonella region was separated from the background region. A threshold of T=128 was set, and the segmentation result was binarized to obtain the microscopic input image. The Salmonella area is white (value 255), and the background is black (value 0). (Manually annotated image) The image is a manually created binarized image with the same dimensions as the automatically generated image. Labels are manually drawn based on the actual Salmonella locations, with the label area set to white (255) and the background area to black (0). Each location of Salmonella is manually marked on the microscopic image, and the region of each Salmonella is delineated in the image to ensure accurate labeling of each Salmonella target. The accuracy should reach over 98%, with an error range of less than 5 pixels.

[0022] It should be noted that: First, Salmonella in food samples has a small morphological scale and limited contrast in microscopic images. Inconsistent acquisition conditions can lead to unstable feature distributions learned by the subsequent model. Second, the matrix composition varies significantly between different food samples. A lack of unified image acquisition and annotation standards can easily result in inconsistent training sample quality, affecting the model's generalization ability. Third, the boundaries of Salmonella targets are small. Inaccurate manual annotation can directly affect the reliability of subsequent supervised training. Using fixed microscope models, objective magnifications, exposure times, and resolutions for image acquisition ensures consistency in imaging scale, brightness distribution, and spatial resolution among training samples. Normalization, Gaussian denoising, and ROI cropping are used to reduce interference from large background areas while preserving the main bacterial structure. The combination of Otsu's thresholding method and precise manual annotation allows for the rapid generation of initial input images. On the other hand, images are manually labeled. It provides high-quality monitoring signals, thereby balancing data construction efficiency and annotation accuracy.

[0023] S2, Adaptive Pretreatment of Food Matrix The purpose of the food matrix adaptive preprocessing module is to process the microscopic input image... This module removes complex backgrounds (such as food impurities, liquid backgrounds, particles, and bubbles) from the target Salmonella while preserving its morphological characteristics. Through multi-layer processing and an adaptive strategy based on image content, it enhances the contrast and detail of the target region while suppressing background noise. The module comprises the following main components: a background suppression and matrix separation module, a target enhancement module, and a morphology preservation and detail enhancement module.

[0024] (1) The background suppression and matrix separation module first uses a Gaussian mixture model (GMM) to analyze the microscopic input image. The background is modeled to obtain background information. The model parameters are: maximum Gaussian components (MGM) of 2 (for modeling static and dynamic backgrounds), learning rate of 0.01 (for updating the background model), and a background threshold of 0.5. When the difference between the current frame and the background exceeds this value, the area is considered a foreground object, and then the background information is modeled based on the Gaussian Mixture Model (GMM). Input microscopic images Background information Subtract the two and take the absolute value to obtain the foreground score. .

[0025] (2) Prospect score The image is input into the target enhancement module to obtain the enhanced target image. The aim is to enhance the contrast of the target area for Salmonella and suppress interference from the food matrix area.

[0026] The target enhancement module uses Local Histogram Equalization (CLAHE) on the foreground score. Contrast enhancement is performed on each image patch (64×64 pixels in size), and then the Sobel operator is used to enhance the image edges. The Sobel kernel size is set to 3×3 and the Sobel gradient threshold is set to 50 to filter out obvious edges.

[0027] (3) Enhance the target image The input shape preservation and detail enhancement module obtains preprocessed features. It preserves the morphological characteristics of Salmonella, enhances its details (such as rod-shaped features), and removes background noise.

[0028] The morphology preservation and detail enhancement module removes small noise points through morphological opening operations, with the structuring element size set to 3×3 pixels to remove small impurities. Then, a Laplacian filter is used to enhance the image details, with the Laplacian kernel size set to 3×3 to extract detailed information from the image.

[0029] It should be noted that the purpose of the adaptive food matrix preprocessing module is to address the problem of complex background interference in microscopic images of food samples. Since food samples often contain oil particles, protein deposits, bubbles, droplets, fibrous debris, and irregular suspended particles, these background components may resemble Salmonella targets in terms of grayscale, texture, and local edges, easily leading to false positives or false negatives. Therefore, this invention employs a combination of background suppression and matrix separation, target enhancement, and morphology preservation and detail enhancement. First, the background is modeled and separated; then, the target region undergoes contrast enhancement and edge enhancement; finally, rod-shaped morphological details are preserved and isolated noise is removed. This design improves the separability of the Salmonella region from the background region, providing more stable preprocessed features for subsequent feature extraction and detection. .

[0030] S3, Morphological Prior Encoding Module The purpose of the Salmonella morphology prior coding module is to obtain information from preprocessed features. Prior information that can characterize the typical morphology of Salmonella is extracted and encoded into coded features that can be called by the subsequent multi-scale candidate bacterial cell sensing module. The Salmonella morphology prior coding module is used to highlight the morphological characteristics of Salmonella, such as its short rod shape, blunt ends, continuous orientation, and stable local skeleton, and to suppress the interference of flaky impurities, dot-like particles, and irregular debris in the food matrix on subsequent detection.

[0031] The Salmonella morphology prior coding module includes the following main components: candidate connected component extraction component and coding mapping unit.

[0032] (1) Preprocessing features Input the candidate connected component extraction component to obtain the candidate region set. .

[0033] The candidate connected component first processes the preprocessed features. Normalization is performed, linearly mapping pixel values ​​to the interval [0,1] to obtain a normalized feature map. Then, the normalized feature map Adaptive threshold segmentation is used, and the threshold value is determined as follows: in, Represented by pixels The local mean of a neighborhood centered at a size of 15×15 pixels. This represents the local standard deviation of the corresponding neighborhood.

[0034] when When this happens, the pixel is identified as a foreground pixel, resulting in a binary candidate image. Then, for the binary candidate graph Perform 8-neighbor connected component labeling, and filter out connected components with an area less than 8 pixels or greater than 120 pixels. At the same time, filter out candidate regions whose bounding rectangle width is less than 2 pixels or greater than 8 pixels and whose length is less than 5 pixels or greater than 25 pixels. Retain connected components that meet the conditions as a candidate region set. .

[0035] (2) Set up candidate regions and preprocessing features The input coding mapping units are summed according to the channel dimension to obtain the coding features. The encoding mapping unit consists of one 1×1 convolutional unit, two 3×3 convolutional units, and one sigmoid activation unit connected in series. The 1×1 convolutional unit has 16 kernels, a stride of 1, and padding of 0. The first 3×3 convolutional unit has 16 kernels, a stride of 1, and padding of 1, and uses ReLU as the activation function. The second 3×3 convolutional unit has 8 kernels, a stride of 1, and padding of 1, and uses ReLU as the activation function. The Sigmoid activation unit constrains the output value to the interval [0,1], and the final output yields the encoded features. .

[0036] It should be noted that the purpose of the Salmonella morphological prior encoding module is to address the problem that relying solely on grayscale, texture, or local edge information is insufficient to reliably distinguish Salmonella from background debris. Since Salmonella typically exhibits relatively fixed morphological characteristics such as short rod-shaped, blunt-ended ends, continuous orientation, and stable local skeletons, this invention first filters candidate regions that meet the size range and circumscribed rectangle constraints using a candidate connected component. Then, an encoding mapping unit jointly encodes the candidate region information with preprocessed features to form encoded features with morphological prior constraints. The above design improves the model's ability to express typical Salmonella morphology and suppresses the interference of irregular food impurities on subsequent detection.

[0037] S4, Multi-scale Candidate Bacterial Cell Detection Module The purpose of the multi-scale candidate cell sensing module is to detect preprocessed features from the input. and Salmonella morphological prior coding features Candidate bacterial cell regions are extracted and their detection signals are enhanced to obtain multi-scale features. .

[0038] This module perceives Salmonella targets at different scales through multi-scale convolutional operations and improves the accuracy of candidate regions through feature fusion via multi-layer convolutional networks. The module includes the following main components: an alignment component, a multi-branch convolutional perception component, and a candidate bacterial cell enhancement function.

[0039] (1) Encoding features Input alignment components to obtain alignment features The input alignment component consists of a 1×1 convolutional unit, a batch normalization unit, and a ReLU activation unit connected in series, used to align the encoded features. Channel compression and scale alignment are performed; specific parameters are: the number of kernels in a 1×1 convolutional unit is set to 4, the stride is set to 1, and the padding is set to 0; the momentum of the batch normalized unit is set to 0.1. Set to 1×10 -5 The slope of the negative half-axis of the ReLU activation unit is set to 0.

[0040] Preprocessed features Alignment features Concatenate the data according to the channel dimension to obtain the joint input features. .

[0041] Through the alignment process described above, the encoded features can be made more readable. Better adapt preprocessing features in terms of channel number and feature scale. This avoids feature mismatch caused by direct splicing and improves the effectiveness of subsequent multi-branch perception.

[0042] (2) Combine input features Inputting a multi-branch convolutional perceptron component yields concatenated features. The multi-branch convolutional sensing component includes parallel small-scale branches, medium-scale branches, and large-scale branches, which are used to sense the fine-grained edges, standard rod-shaped morphology, and local aggregation regions of Salmonella, respectively. Wherein: The small-scale branch consists of two consecutive 3×3 convolutional units, each followed by a batch normalization unit and a ReLU activation unit. The first 3×3 convolutional unit has 16 kernels, a stride of 1, and padding of 1. The second 3×3 convolutional unit also has 16 kernels, a stride of 1, and padding of 1. The joint input features... Input small-scale branch, output small-scale features .

[0043] The mesoscale branch consists of one 5×5 convolutional unit, one batch normalization unit, and one ReLU activation unit; the 5×5 convolutional unit has 16 kernels, a stride of 1, and padding of 2; it combines the input features. Input the mesoscale branch, output the mesoscale features .

[0044] The large-scale branch consists of one 3×3 dilated convolutional unit, one batch normalization unit, and one ReLU activation unit; the 3×3 dilated convolutional unit has 16 kernels, a stride of 1, padding of 2, and a dilation rate of 2; the joint input features are... Input large-scale branch, output large-scale features .

[0045] Then small-scale features Mesoscale features and large-scale features By splicing along the channel dimension, the splicing features are obtained. .

[0046] By setting up small-scale, medium-scale, and large-scale branches in parallel, fine-grained edge information, standard rod-shaped morphology information, and local aggregation region information can be extracted respectively, thereby improving the ability to detect candidates for Salmonella targets at different scales.

[0047] (3) Splicing features Input the candidate cell enhancement function based on spatial entropy suppression and channel competition reconstruction to obtain the enhanced multi-scale features. .

[0048] First, define the splicing features. The normalized spatial response probability of the c-th channel at position (x, y): In the formula, Representing joint input features exist The splicing characteristics at the Cth channel; Define splicing features The spatial entropy of the c-th channel is: In the formula, Indicates splicing features The normalized spatial response probability of the c-th channel at position (x,y); Define splicing features The local oscillation consistency measure for the c-th channel is: In the formula, Representing joint input features exist The splicing characteristics at the Cth channel; Define splicing features The competition score for the c-th channel is: In the formula, Indicates splicing features Local oscillation consistency measure of the c-th channel; Redefining splicing features Channel competition weight: In the formula, Indicates splicing features The competition score for the c-th channel; This yields the enhanced multi-scale features. Each element: In the formula, Representing joint input features exist The splicing feature at the Cth channel. Indicates splicing features Channel competition weight; All elements according to Positional arrangement constitutes multi-scale features .

[0049] By introducing spatial entropy suppression, local oscillation consistency measurement, and channel competition reconstruction mechanisms, we can enhance candidate bacterial cell regions with concentrated responses and stable structures, while suppressing scattered background textures and random pseudo-responses, thus improving multi-scale features. The quality of the candidates.

[0050] It should be noted that the purpose of the multi-scale candidate bacterial cell sensing module is to address the problems of scale variations, weak edges, local clustering, and confusion with background textures in Salmonella microscopic images. Since single-scale convolution cannot simultaneously capture fine-grained edges, standard rod-shaped contours, and information on locally clustered regions, this invention employs a combination of alignment components, multi-branch convolution sensing components, and candidate bacterial cell enhancement functions to process information from preprocessed features. and morphological prior coding features The information is analyzed jointly. This design improves the ability to perceive candidate bacterial cell regions at different scales and enhances the response to real candidate regions, ultimately resulting in more discriminative multi-scale features. .

[0051] S5, Bacterial Cell-Impurity Decoupling Module The purpose of the cell-impurity decoupling discrimination module is to determine the type of cell based on encoded features. and multi-scale features This significantly enhances the distinction between Salmonella targets and background impurities, resulting in discriminative features. This is used for further analysis and detection. Due to the coding features... It places more emphasis on morphological prior representation, while multi-scale features This invention focuses more on the response expression of candidate regions, and the two are complementary. Therefore, by combining global context modeling and local feature modulation, the target and impurities are differentially decoupled and discriminated, thereby improving the discriminative features. Target specificity.

[0052] The specific mathematical model of the cell-impurity decoupling discrimination module is as follows: In the formula, and These represent the encoded features and multi-scale features at different locations. and the eigenvalues ​​at channel c; In the formula, Indicates the encoded features The global context modeling operation is performed, and the model is designed to handle local feature dependencies at different scales. This represents the neighborhood around a pixel (x, y). These are global weights learned through context. In the formula, Represents multi-scale features Local feature modulation performed, These are weights learned locally. Represents the neighborhood of a local region; M and N represent the width and height of the feature map, respectively, and are used to sum and weight each pixel of the feature map. The operator ⊙ represents element-wise multiplication, reflecting the feature differences between the Salmonella target and the food matrix interference. In the formula, This represents the learnable weight coefficient located at the m-th row and n-th column. It is obtained through loss function optimization during model training and is used to adaptively measure the contribution of features at different positions to the discrimination result. and yes and Eigenvalues ​​of a local region =0.012 to prevent division by zero errors; To obtain discriminative features exist The elements are based on their positions, and all elements are combined according to their positions to form discriminative features. .

[0053] It should be noted that the purpose of the bacterial cell-impurity decoupling discrimination module is to solve the problem of false detection caused by the similarity of background impurities in complex food matrices to the local morphology or texture of Salmonella. Since the edges of strip-shaped fibers, particle accumulations, or droplet outlines may have similar local responses to Salmonella targets, relying solely on candidate response intensity is insufficient for effective differentiation. Therefore, this invention also utilizes encoded features. Morphological prior information and multi-scale features The candidate region information is used to enhance the difference between the target and impurities through global context modeling, local feature modulation, and weighted decoupling operations. This design enables the acquisition of more target-specific discriminative features. This reduces the false detection rate in complex backgrounds.

[0054] S6, Evidence Accumulation and Verification Module The purpose of the evidence accumulation and verification module is to verify evidence based on multi-scale features. The response intensity, local consistency, cross-channel coupling, and global significance of each spatial location and channel are used to accumulate and validate evidence for candidate bacterial cell regions, and finally, evidence parameters are output. The evidence parameters Used to characterize the overall credibility of candidate bacterial cell regions in a multi-scale feature space of an input sample. The value range of is [0,1]. The closer its value is to 1, the more the candidate region matches the multi-scale evidence distribution characteristics of the Salmonella target; the closer its value is to 0, the more likely the candidate region is background impurities or a spurious response. Through the above design, the evidence parameter It can not only reflect the local response intensity of the candidate region, but also comprehensively reflect its spatial continuity and global credibility, thus providing a stable global verification basis for subsequent fusion decisions.

[0055] Multiscale features Input evidence accumulation verification module, assuming the multi-scale features The dimensions are H×W×C, and the evidence parameters are... Calculate according to the following formula: in: In the formula, This represents the feature response value of the multi-scale feature map at position (x, y) and channel c. This represents the mean value of the c-th channel across the entire spatial range, used to characterize the overall response baseline of that channel, derived from the feature map. The average of all pixel values ​​in the c-th channel is obtained by summing up all pixel values. and Representing feature maps respectively The first-order discrete gradients along the horizontal and vertical axes of the c-th channel are used to characterize the intensity of local spatial variation. When the characteristic response within a certain region is continuous and the boundary is smooth, the absolute value of the gradient is small; when the region contains random noise or discrete impurities, the absolute value of the gradient is large. Therefore, the denominator term... Used to suppress unstable responses with large spatial abrupt changes; Sigmoid function This is used to compress the final result to the interval [0,1], thereby obtaining evidence parameters that can be directly used in subsequent decisions. .

[0056] It should be noted that the purpose of the evidence accumulation and verification module is to address the problem that relying solely on local high-response regions for detection can easily lead to unstable results due to interference from accidental textures, local reflections, and noise. Therefore, this invention addresses multi-scale features... The response intensity, local consistency, and global significance at various spatial locations and through various channels are jointly statistically analyzed to form evidence parameters. This is used to characterize the overall credibility of candidate bacterial cell regions in the current sample. Through the above design, local candidate responses can be elevated to a full-map level of evidence measurement, improving the stability and robustness of subsequent decision-making processes.

[0057] S7, Multi-Evidence Fusion Decision Module The purpose of the multi-evidence fusion decision module is to process preprocessed features. Discriminating features and evidence parameters Perform joint fusion to output the image. The multi-evidence fusion decision module utilizes preprocessing features. Original detailed information and discriminant features Target discrimination information and evidence parameters The global evidence strength is used to perform final response recalibration and threshold determination on candidate regions, thereby obtaining the output image. .

[0058] Due to preprocessing features Contains relatively rich original detailed information, distinguishing features It contains strong target discrimination information, while the evidence parameters To characterize the global candidate confidence level, this invention employs a three-factor fusion approach for final response recalibration and threshold determination of candidate regions, thereby improving the output image. The accuracy and stability of [the system / mechanism].

[0059] (1) Preprocessing features Discriminating features Spatial alignment is performed to obtain fused input features. First, discriminative features The mean value is calculated along the channel dimension to obtain the single-channel discriminant response map. The calculation formula is as follows: in, To obtain discriminative features exist The element at the specified position; Then preprocess the features Compared with single-channel discrimination response diagram The fusion is performed using a weighted summation method to obtain the fused input features. The calculation formula is as follows: in, The preprocessing feature weights are set to 0.4; To determine the feature weight, it is set to 0.6.

[0060] (2) Evidence parameters Input evidence modulation unit, fusing input features Perform global evidence enhancement to obtain evidence enhancement features. ; The evidence modulation unit uses scalar multiplication to fuse the input features. The enhancement is calculated using the following formula: Where γ is the evidence enhancement coefficient, set to 0.75, and the evidence parameter... The value range of is [0,1]. When A larger value indicates stronger evidence of Salmonella candidates in the current image, thus affecting the fusion of input features. Enhance the response; when When the value is smaller, it indicates that the evidence for Salmonella candidates in the current image is weaker, and the enhancement magnitude decreases.

[0061] (3) Enhance the features of evidence Input threshold determination unit to obtain binary output image ; The threshold determination unit uses a fixed threshold segmentation method for determination, with the threshold set at 0.55. The calculation formula is as follows: When the pixel value is 255, it indicates that the location is identified as a Salmonella target area; when the pixel value is 0, it indicates that the location is identified as a background area or a non-target area.

[0062] It should be noted that the purpose of the multi-evidence fusion decision module is to address the problem that a single feature map cannot simultaneously consider original details, target discrimination ability, and global credibility. Therefore, this invention preprocesses features... Original detailed information and discriminant features Target differentiation information and evidence parameters The global evidence strengths represented are jointly fused, and the final image is output through evidence modulation and thresholding. The above design enables the output to balance boundary integrity, target accuracy, and detection stability, thereby improving the final output image. The quality.

[0063] S8. Loss Function and Model Training Construct based on output image Compared with manually annotated images The loss function is calculated, and the Adam optimizer is used to iteratively update the model parameters until training is complete, resulting in the trained model. Specifically, the training samples are input into the model. In the process, the predicted image is obtained through forward propagation. Images annotated manually As supervisory signals, pixel-level binary cross-entropy loss is constructed respectively. Regional overlap loss and boundary consistency constraint loss The total loss function is obtained by weighted summation. Then, the Adam optimizer combined with the backpropagation algorithm is used to update the model parameters; the above process is repeated until the preset number of training epochs is reached or the model converges, finally obtaining the trained model. .

[0064] (1) Construct the total loss function Pixel-level binary cross-entropy loss : In the formula, This indicates the number of samples in a batch. Indicates the image height. Indicates the image width. This loss term measures the pixel-level difference between the model's output probability map and the manually labeled map. It effectively constrains the model's ability to classify foreground and background regions. This represents the predicted image obtained through forward propagation. This represents manually annotated images; Boundary consistency constraint loss : in, This is a smoothing coefficient used to prevent the denominator from being zero; its value is [value missing]. ; The region overlap loss is used to measure the degree of overlap between the model output region and the real labeled region, which can enhance the model's ability to identify small and edge regions of Salmonella.

[0065] To output the image It exhibits better morphological consistency at the cell outline boundaries, and further constructs a boundary consistency constraint loss. .

[0066] Calculate the predicted image separately Compared with manually annotated images The gradient response in the horizontal and vertical directions is specifically expressed as follows: In the formula, Represents the predicted image Gradient response in the horizontal direction, Represents the predicted image The gradient response in the vertical direction, Represents manually annotated images Gradient response in the horizontal direction, Represents manually annotated images Gradient response in the vertical direction; Then the boundary consistency constraint loss Defined as: In the formula, This indicates the number of samples in a batch. Indicates the image height. Indicates the image width; The boundary consistency constraint loss is used to improve the model's ability to recover the Salmonella rod-shaped outline, edge continuity, and local morphological details, thereby making the predicted image closer to the manually labeled result at the target boundary.

[0067] The pixel-level binary cross-entropy loss Regional overlap loss and boundary consistency constraint loss We perform a weighted summation to obtain the total loss function used for model training. : In the formula, , , These are the weighting coefficients for each loss term; their values ​​are... , , ; The total loss function simultaneously constrains the model output from three aspects: pixel classification accuracy, region overlap consistency, and edge structure consistency, thereby improving the model's detection accuracy and contour recovery ability for Salmonella target regions in food samples.

[0068] (2) Divide all training samples into multiple batches, and perform the following operations in each batch in sequence: <1> Read a batch of input images and corresponding manually annotated images; <2> The input image is fed into the model for forward propagation to obtain the predicted image. ; <3> Based on the predicted image Compared with manually annotated images Calculate the total loss function ; <4> The gradient of the loss function with respect to each parameter of the model is calculated using the backpropagation algorithm; <5> Update model parameters using the Adam optimizer; <6> After completing the training for the current batch, continue reading the next batch of samples until the current training round ends.

[0069] (3) Perform multiple rounds of training on the training set. Let the total number of training rounds be E. Then, repeat the batch iteration process in step (2) for each round of training.

[0070] During training, record the training loss value and validation set loss value for each round; stop training when any of the following conditions are met: <1> Reach the preset number of training rounds E; <2> The validation set loss no longer decreases over several consecutive rounds; <3> The model's detection accuracy on the validation set reached the preset threshold.

[0071] Specifically: the batch size is set to 16; the number of training rounds is set to 100 to 300; training is stopped when the validation set loss does not decrease for 10 consecutive rounds.

[0072] After training, the model with converged parameters is obtained. .

[0073] After completing all iterations of training, save the model corresponding to the current optimal parameters, and denote it as the trained Salmonella rapid detection model. The model It can process images of food samples to be tested and output corresponding Salmonella target detection results.

[0074] It should be noted that the purpose of the model training steps described is to address the issues of insufficient convergence, generalization ability, and boundary recovery ability of the model in complex food backgrounds. Since Salmonella bacteria are typically small targets in the overall image, occupying a small proportion of the foreground region, training with only a single loss function can easily lead to problems such as class imbalance, blurred boundaries, and insufficient learning of small targets. Therefore, this invention is based on the output image... Compared with manually annotated images Pixel-level binary cross-entropy loss, region overlap loss, and boundary consistency constraint loss are constructed separately, and the Adam optimizer is used for parameter updates. This design enables joint optimization of the model at the pixel, region, and boundary levels, thereby improving the trained model. Its detection accuracy and edge recovery capability.

[0075] S9, automatic marking module and online detection module (1) Automatic marking module Output image Although the target region has been identified, a structured detection result that can be directly used for counting, localization, and result display has not yet been formed. Therefore, this invention employs connected component analysis to analyze the output image. The foreground region is automatically extracted, and the bounding rectangle, center coordinates and area parameters of each foreground region are calculated. Then, noise points and non-target adhered regions are screened out by combining the area threshold, and the model output is automatically converted into visualized and structured detection results.

[0076] The automatic labeling module uses connected component analysis to analyze the output image. The foreground target region in the image is automatically marked. The automatic marking module first processes the output image... An 8-neighbor connected component search is performed on the region with a pixel value of 255 to extract each independent foreground region. Then, the bounding rectangle, center coordinates, and area parameters of each independent foreground region are calculated, and the connected components that meet the area threshold condition are retained as valid detection targets.

[0077] In this embodiment, the lower limit of the area threshold is set to 8 pixels, and the upper limit is set to 150 pixels. Regions with an area smaller than 8 pixels are identified as noise points and removed. Regions with an area greater than 150 pixels are identified as non-target adhered regions or background interference regions and removed. For the retained valid connected components, the connectedComponentsWithStats function in the existing mature image processing tool OpenCV is used to complete automatic labeling, and the final detection result O is output.

[0078] The purpose of the automatic labeling module is to solve the output image... Although the target region has been identified, a structured detection result that can be directly used for counting, localization, and result display has not yet been formed. Therefore, this invention employs connected component analysis to analyze the output image. The foreground region is automatically extracted, and the bounding rectangle, center coordinates, and area parameters of each foreground region are further calculated. Noise points and non-target adhered regions are then filtered out using an area threshold. This design automatically converts the model output into visualized, structured detection results, improving the automation level of the detection process and its engineering application value.

[0079] (2) Online detection module Once the model training is complete and the trained rapid Salmonella detection model is finalized, it can be deployed in the Salmonella detection system to achieve intelligent detection of Salmonella. Specifically, a microscope is used to acquire microscopic images of the food to be tested, obtaining the microscopic input image.

[0080] In the Salmonella fast detection model trained by inputting the microscopic image, the adaptive preprocessing module is first executed to remove the interference of complex background on the Salmonella target from the microscopic input image, while preserving the morphological features of Salmonella, thus obtaining the preprocessed features. Then, the preprocessed features are entered into the Salmonella morphology prior coding module to highlight the morphological features of Salmonella, such as short rod shape, blunt and rounded ends, continuous direction and local skeletal stability, and to suppress the interference of flaky impurities, dot-like particles and irregular debris in the food matrix on subsequent detection, thus obtaining the coding features. Then, the preprocessed features and encoded features are fed into the multi-scale candidate bacterial cell sensing module. The multi-scale candidate bacterial cell sensing module extracts candidate bacterial cell regions from the input preprocessed features and Salmonella morphology prior encoded features, and enhances the detection signal of the candidate regions to finally obtain multi-scale features. Then, the encoded features and multi-scale features are input into the cell-impurity decoupling discrimination module to significantly enhance the difference between Salmonella targets and background impurities, and obtain discrimination features; Multi-scale features, preprocessing features, and discriminant features are input into the Salmonella rapid detection model to obtain the output image; The output image is automatically converted into visualized, structured detection results by the automatic labeling module.

[0081] Example 2 To verify the effectiveness of the method of this invention in the rapid detection of Salmonella in food, a comparative experiment was conducted with existing common image detection methods under the same dataset, the same training set partitioning method, and the same hardware environment. The comparative methods included: methods based on traditional threshold segmentation and morphological processing, hand-crafted feature classification methods for microscopic images based on support vector machines (SVM), U-Net semantic segmentation method, Mask R-CNN instance segmentation method, and DeepLabV3+ semantic segmentation method. In this embodiment, all methods were trained and tested on the same training and test sets. Evaluation metrics included precision, recall, F1 score, IoU, Dice coefficient, and average detection time per image. Experimental results are shown in Table 1.

[0082] Table 1 Comparison of Detection Performance with Existing Technologies As shown in Table 1, compared with traditional threshold segmentation and morphological processing methods, the method of the present invention has significant improvements in Precision, Recall, F1 value, IoU and Dice coefficient.

[0083] Compared with the traditional threshold segmentation method, the F1 value of the method of the present invention increased from 75.4% to 93.7%, an improvement of 18.3 percentage points; the IoU increased from 60.8% to 88.1%, an improvement of 27.3 percentage points.

[0084] This indicates that the method of the present invention can more effectively suppress spurious responses in complex food matrix backgrounds and significantly improve the detection capability of real Salmonella target areas.

[0085] Compared to the manual feature + SVM method, the method of this invention does not rely on manually designed features. It can automatically learn more discriminative target representations through the food matrix adaptive preprocessing module, morphological prior encoding module and multi-scale candidate cell perception module. Therefore, it is significantly better than traditional machine learning methods in all aspects.

[0086] Compared to deep learning methods such as U-Net, Mask R-CNN, and DeepLabV3+, the method of this invention maintains the best performance in terms of Precision, Recall, F1 score, IoU, and Dice coefficient. This indicates that by introducing morphological prior encoding, multi-scale candidate cell enhancement, cell-impurity decoupling discrimination, and evidence accumulation verification mechanisms, this invention can better adapt to the detection scenarios of small targets, weak edges, and complex backgrounds of Salmonella in food samples.

[0087] Meanwhile, the average detection time of the method of the present invention is 39ms / image, which is significantly lower than that of Mask R-CNN and DeepLabV3+ methods, and slightly better than that of U-Net method. This shows that the present invention not only has high detection accuracy, but also has good detection speed, making it suitable for rapid detection applications.

[0088] Example 3 Figure 2 This is a comparison chart of the detection results of this invention and those of other methods. Figure 2 (a) is the original microscopic image. Figure 2 (b) is the actual target area marked manually. Figure 2 (c)- Figure 2 (f) shows the detection results of traditional threshold segmentation, U-Net, DeepLabV3+, and the method of this invention, respectively.

[0089] The pink rod-shaped structures in the original microscopic image represent the target region of Salmonella. In the results of each method, the white areas represent the detected target regions, and the red areas in the lower row represent error regions inconsistent with the manual annotation. Traditional threshold segmentation methods are prone to false detections under conditions of background texture interference and uneven staining, and also suffer from missed detections of bacteria with weak contrast and small scale. Although U-Net and DeepLabV3+ can locate most bacteria well, they still have problems with boundary loss and target adhesion in terms of rod edge recovery, separation of adjacent bacteria, and handling of local aggregation regions. In contrast, the method of this invention has the fewest error regions, and the detection results are highly consistent with the manual annotation. It performs better in terms of rod edge integrity, ability to separate aggregation regions, and preservation of weak targets, demonstrating higher segmentation accuracy and robustness.

[0090] Example 4 A computer-readable storage medium storing a computer program that can be executed by a processor to implement a machine learning-based rapid detection method for Salmonella in food.

[0091] Readable storage media include: non-volatile memory: flash memory, ROM, EPROM, EEPROM; volatile memory: random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM); disk storage media: hard disk (HDD), floppy disk; optical storage media: optical disc (CD, DVD, Blu-ray disc), etc.

[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A rapid detection method for Salmonella in food based on machine learning, characterized in that, Includes the following steps: S1. Acquire microscopic images of the food to be tested, normalize and denoise the microscopic images to obtain microscopic input images, manually mark the location of Salmonella in the microscopic images to obtain manually marked images; S2. A Gaussian mixture model is used to suppress the background and separate the matrix of the microscopic input image to obtain the foreground score. The foreground score is then subjected to local histogram equalization and edge enhancement to obtain the target enhanced image. Morphological opening is performed on the target enhanced image to filter out noise interference. A filter is used to enhance the details of the denoised image to obtain the preprocessed features. S3. A morphological prior coding module is constructed based on a candidate connected component extraction component and a coding mapping unit to obtain candidate regions from preprocessed features and jointly encode the candidate region information with the preprocessed features to obtain coded features; the candidate connected component extraction component includes two parts: normalization and adaptive threshold segmentation, which are used to extract prior information of typical Salmonella morphology; a multi-scale candidate cell perception module is constructed based on an alignment component, a multi-branch convolutional perception component, and a candidate cell enhancement function to extract candidate cell regions from preprocessed features and coded features to obtain multi-scale features; A candidate cell enhancement function based on spatial entropy suppression and channel competition reconstruction is constructed as follows: In the formula, Representing multi-scale features, Indicates splicing features in The element at position, Indicates the competition weights of the splicing feature channels; S4. By using the cell-impurity decoupling discrimination module, combined with global context modeling and local feature modulation, differential decoupling discrimination is performed on Salmonella targets and background impurities to obtain discrimination features; S5. The evidence parameters are formed by statistically analyzing the response intensity, local consistency, and global saliency of each spatial location and channel in the multi-scale features through the evidence accumulation and verification module; the preprocessed features, discriminant features, and evidence parameters are jointly fused to obtain evidence enhancement features; the evidence enhancement features are judged by threshold segmentation to obtain the output image. S6. Construct a joint loss function based on binary cross-entropy loss, region overlap loss and boundary consistency loss, backpropagate the model, update the parameters, and obtain the trained detection model. S7. An automatic labeling module is constructed through connected component analysis to extract the foreground region in the output image, resulting in visualized and structured detection results.

2. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S3 specifically includes: S31. Normalize the preprocessed features to obtain a normalized feature map, then use adaptive threshold segmentation to obtain a candidate region set. The threshold value is determined as follows: In the formula, Represented by pixels The local mean of a neighborhood centered at a size of 15×15 pixels. This represents the local standard deviation of the corresponding neighborhood. S32. The candidate region set and preprocessed features are added together according to the channel dimension and input into the encoding mapping unit to obtain the encoding features; the encoding mapping unit consists of one 1×1 convolutional unit, two 3×3 convolutional units and one sigmoid activation unit connected in series. S33. Input the encoded features into the alignment component to obtain the aligned features; the alignment component consists of a 1×1 convolutional unit, a batch normalization unit and a ReLU activation unit connected in series, which performs channel compression and scale alignment on the encoded features; S34. Concatenate the preprocessed features and the aligned features along the channel dimension to obtain the joint input features; S35. Input the joint input features into the multi-branch convolutional sensing component to obtain spliced ​​features; the multi-branch convolutional sensing component includes parallel small-scale branches, medium-scale branches and large-scale branches, which respectively sense the fine-grained edge, standard rod-shaped morphology and local aggregation region information of Salmonella; S36. Input the spliced ​​features into the candidate cell enhancement function based on spatial entropy suppression and channel competition reconstruction to obtain multi-scale features.

3. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S4 specifically includes: Construct a cell-impurity decoupling discrimination module, the specific expression of which is: In the formula, Indicates discriminative features in Location feature value Indicates the location of the encoded feature and the eigenvalues ​​at channel c, Indicates multi-scale features at location The eigenvalues ​​at channel c and M and N represent the width and height of the feature map, respectively. The operator ⊙ represents element-wise multiplication. This represents the learnable weight coefficient located at the m-th row and n-th column. This indicates a global context modeling operation performed on the encoded features. These are global weights learned through context. This indicates local feature modulation of multi-scale features. These are weights learned locally; The cell-impurity decoupling discrimination module significantly enhances the distinction between Salmonella targets and background impurities based on coding features and multi-scale features, thereby obtaining discrimination features.

4. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S1 specifically includes: Microscopic images of the food to be tested were acquired using an optical microscope as the original images. The original images were first normalized, then Gaussian function was used to remove image noise, and finally the areas containing Salmonella were manually selected and the images were cropped to obtain the cropped images. The Otsu thresholding method was used to separate the Salmonella region and the background region in the cropped image to obtain the microscopic input image; Manually annotate each location of Salmonella on photographs of the same size to obtain manually annotated images.

5. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S2 specifically includes: The Gaussian mixture model is used to segment the microscopic input image to obtain background and foreground information. Local histogram equalization is used to enhance the contrast of each image patch of foreground information, and then the Sobel operator is used to filter out the image edges to obtain the target enhanced image; The target enhanced image is subjected to morphological opening operation to remove noise points, and then a Laplacian filter is used to enhance the details of the image to obtain preprocessed features.

6. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S5 specifically includes: S51. Construct an evidence accumulation and verification module. When the multi-scale feature size is H×W×C, then the evidence parameters... The mathematical representation of is: In the formula, This represents the feature response value of the multi-scale feature map at position (x, y) and channel c. This represents the mean of the c-th channel across the entire space. and Let represent the first-order discrete gradients of the feature map along the horizontal and vertical axes in the c-th channel, respectively. It is the Sigmoid activation function, which compresses the final result to the interval [0,1]. The evidence parameters are obtained from the multi-scale features through the evidence accumulation and verification module; S52. Calculate the mean of the discriminant features along the channel dimension to obtain a single-channel discriminant response map. Then, fuse the preprocessed features with the single-channel discriminant response map using a weighted summation method to obtain the fused input features. S53. Combining the evidence parameters, the fused input features are enhanced using scalar multiplication to obtain evidence-enhanced features; S54. Evidence enhancement features are determined using a fixed threshold segmentation method, resulting in a binary output image. The formula is as follows: In the formula, Point Evidence enhancement feature value at the location, This represents a binary output image; When the pixel value is 255, it indicates that the location is identified as a Salmonella target area. When the pixel value is 0, it indicates that the location is identified as a background area or a non-target area.

7. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S6 specifically includes: S61. A total loss function is constructed based on binary cross-entropy loss, region overlap loss, and boundary consistency constraint loss. S62. The detection model is updated using the Adam optimizer combined with backpropagation to obtain the trained detection model.

8. The rapid detection method for Salmonella in food based on machine learning according to claim 1, characterized in that, S7 specifically includes: The automatic labeling module uses connected component analysis to perform an 8-neighbor connected component search on the region with a pixel value of 255 in the output image to extract each independent foreground region. Then, it calculates the bounding rectangle, center coordinates, and area parameters of each independent foreground region and retains the connected components that meet the area threshold condition as valid detection targets to obtain the detection results.

9. A machine learning-based rapid detection system for Salmonella in food, executing the machine learning-based rapid detection method for Salmonella in food as described in any one of claims 1-8, characterized in that, include: Data acquisition module: used to acquire microscopic images of food, and construct microscopic input images and manually annotated images; Data augmentation module: used to enhance image details, improve the separability of Salmonella regions from background regions, and obtain preprocessed features; Feature extraction module: used to extract features from the image, highlight the morphological features of Salmonella, enhance the differential expression between Salmonella and impurities, and obtain discriminative features; Model building module: used to build the evidence accumulation and verification module and the multi-evidence fusion decision module to obtain the detection model; Model training module: used to construct the total loss function, train the detection model, update parameters, and obtain the trained detection model; Online detection module: Used to build an automatic labeling module and deploy the trained detection model to detect Salmonella in real-time acquired images and label specific areas.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the rapid detection method for Salmonella in food based on machine learning as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Universal bacterium detection network model construction method and device, and storage medium

    CN120164217A

  • Dynamic scale adaptive bacterium detection method and device and storage medium

    CN120673029A