Method and device for detecting types of pathogenic bacteria in meat products
By using an RGB-hyperspectral data reconstruction model and a deep learning network, combined with a feature band selection algorithm and a PLS-DA/SVM model, rapid, non-destructive, and high-precision detection of pathogenic bacteria in meat products has been achieved. This solves the problems of low efficiency and insufficient accuracy in traditional detection methods and meets the real-time quality inspection needs of food production lines.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-03-27
AI Technical Summary
Traditional methods for detecting pathogens in meat products are inefficient and cannot meet the real-time quality inspection needs of food production lines. Furthermore, immunochromatographic analysis cannot accurately distinguish pathogenic bacterial populations and has a high false positive rate.
The full-band hyperspectral data of the test sample was reconstructed using an RGB-hyperspectral data reconstruction model. Based on the RGB image and preprocessed hyperspectral data, pathogenic bacteria species were identified using a feature band selection algorithm and a pathogen classification model. Deep learning networks such as MST++ and PLS-DA/SVM models were used for classification.
It enables rapid, non-destructive, and high-precision detection of pathogenic bacteria in meat products, shortening the detection cycle from the traditional 3-7 days to within 30 minutes, and increasing the identification accuracy rate to over 92%, meeting the rapid quality inspection needs of food industry sites.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of meat product testing technology, specifically to a method and apparatus for detecting pathogenic bacteria in meat products. Background Technology
[0002] Meat, as an important source of nutrients, is highly susceptible to contamination by pathogens during slaughter, processing, storage, and transportation. The proliferation of pathogens can lead to meat spoilage and reduced edibility, potentially causing foodborne illnesses and posing a serious threat to health. Therefore, detecting the types of pathogens in meat products is crucial for ensuring food safety and quality control.
[0003] Traditional culture methods for detecting pathogenic bacteria in meat products require destructive sampling, followed by enrichment, isolation, and identification steps, with a total testing cycle of 3 to 7 days, which cannot meet the real-time quality inspection needs of food production lines. Immunochromatographic analysis, on the other hand, can only qualitatively determine the presence or absence of contamination, cannot distinguish between pathogenic species, and has a high false-positive rate.
[0004] Therefore, there is an urgent need for a rapid and accurate method for detecting pathogenic bacteria in meat products. Summary of the Invention
[0005] The purpose of this invention is to address the problem of low detection efficiency of pathogenic bacteria in meat products in the prior art by providing a method and apparatus for detecting the types of pathogenic bacteria in meat products.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0007] Firstly, a method for detecting pathogenic bacteria in meat products is provided, the method comprising: based on the RGB (Red Green) spectrum of the test sample of the target type of meat product. The system uses (blue, red, green, blue) images and a pre-trained RGB-hyperspectral data reconstruction model to reconstruct the full-band hyperspectral data of the test sample. The RGB-hyperspectral data reconstruction model includes the mapping relationship between RGB images and full-band hyperspectral data of various meat products infected with different pathogens for different durations. The reconstructed full-band hyperspectral data of the test sample is preprocessed. A feature band selection algorithm is used to determine the feature bands of the test sample based on the preprocessed full-band hyperspectral data. Feature spectra corresponding to the feature bands are extracted from the preprocessed full-band hyperspectral data. The meat product type and feature spectra of the test sample are input into a pre-trained pathogen classification model, which outputs the pathogen classification results for the test sample. The pre-trained pathogen classification model indicates the spectral characteristics of the metabolites of various meat products infected with various pathogens for different durations, as well as the spectral characteristics of the control group of various meat products not infected with pathogens for different durations. The pathogen spectral characteristics stored in the pathogen classification model are the weighted spectral characteristics corresponding to the feature bands.
[0008] Secondly, a detection device for pathogenic bacteria in meat products is provided. The device includes: a hyperspectral data reconstruction module, a preprocessing module, a characteristic band determination module, a characteristic spectrum extraction module, and a pathogen classification module. The hyperspectral data reconstruction module is used to reconstruct the full-band hyperspectral data of the test sample based on the RGB red-green-blue image of the target type of meat product and a pre-trained RGB-hyperspectral data reconstruction model. The RGB-hyperspectral data reconstruction model includes the mapping relationship between RGB images and full-band hyperspectral data of various types of meat products infected with different pathogens for different durations. The preprocessing module is used to preprocess the reconstructed full-band hyperspectral data of the test sample. The characteristic band determination module is used to... The feature band selection algorithm determines the feature bands of the sample to be tested based on preprocessed full-band hyperspectral data. The feature spectrum extraction module extracts the feature spectra corresponding to the feature bands from the preprocessed full-band hyperspectral data. The pathogen classification module inputs the meat type and feature spectrum of the sample to be tested into a pre-trained pathogen classification model and outputs the pathogen classification results of the sample. The pre-trained pathogen classification model indicates the spectral characteristics of the metabolites of various types of meat after infection with various pathogens for various durations, as well as the spectral characteristics of the control group of various types of meat after infection with pathogens for various durations. The pathogen spectral characteristics stored in the pathogen classification model are the weighted spectral characteristics corresponding to the feature bands.
[0009] Thirdly, a computer device is provided, comprising: a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement any step in the method for detecting pathogenic bacteria species in meat products as described in the first aspect above.
[0010] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, can perform any step in the method for detecting pathogenic bacteria species in meat products as described in the first aspect above.
[0011] In this embodiment of the invention, firstly, the RGB image of the sample to be tested can be directly acquired during the detection stage. Then, the RGB image is input into the RGB-hyperspectral data reconstruction model to obtain reconstructed full-band hyperspectral data. This eliminates the need to capture hyperspectral images for each detection. A feature band selection algorithm can be used to extract feature bands based on the reconstructed hyperspectral data. Based on the spectral features corresponding to the feature bands and a pre-trained pathogen classification model, pathogen species can be identified. This enables rapid, non-destructive, and high-precision detection of pathogen species in meat products. This method eliminates the need for destructive sampling, shortening the detection cycle from 3-7 days using traditional culture methods to within 30 minutes. It can recover key spectral feature information of pathogens from RGB images, avoiding the loss of key spectral feature information, and can improve the overall identification accuracy to over 92%, meeting the needs of rapid on-site quality inspection in the food industry. Attached Figure Description
[0012] Figure 1 This is an architecture diagram of a detection system for pathogenic bacteria in meat products, provided in an embodiment of the present invention.
[0013] Figure 2 This is a schematic diagram of the model training process for a method for detecting pathogenic bacteria in meat products, provided in an embodiment of the present invention.
[0014] Figure 3 This is a schematic diagram of the detection process for a method for detecting pathogenic bacteria in meat products, provided in an embodiment of the present invention.
[0015] Figure 4 This is a schematic diagram of hyperspectral data of Staphylococcus aureus collected according to an embodiment of the present invention.
[0016] Figure 5 This is a schematic diagram of Staphylococcus aureus spectral data after SNV processing, provided as an embodiment of the present invention.
[0017] Figure 6 This is a schematic diagram of Staphylococcus aureus spectral data after co-processing by SNV and MSC, provided as an embodiment of the present invention.
[0018] Figure 7 This is a schematic diagram of the spectral data of Staphylococcus aureus after feature screening, provided in an embodiment of the present invention.
[0019] Figure 8 This is a schematic diagram of the original spectral data and the reconstructed spectral data of Staphylococcus aureus provided in an embodiment of the present invention.
[0020] Figure 9 This is a hardware structure diagram of a computer device used in a method for detecting pathogenic bacteria in meat products, as provided in an embodiment of the present invention.
[0021] Figure 10 This is a schematic diagram of a detection device for pathogenic bacteria in meat products provided in an embodiment of the present invention. Detailed Implementation
[0022] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0023] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0024] It should be understood that although the terms first, second, third, etc., may be used in this invention to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of this invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0025] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0026] Figure 1 This is an architectural diagram of a detection system for pathogenic bacteria in meat products, provided as an embodiment of the present invention. Figure 1 As shown, the detection system 100 includes: a sample stage 101, a data acquisition unit 102, an RGB-hyperspectral data reconstruction model 103, a data preprocessing unit 104, a feature screening unit 105, a feature weighting unit 106, and a pathogen classification model 107.
[0027] The sample station 101 is used to place meat samples.
[0028] The data acquisition unit 102 is used to acquire full-band hyperspectral data and RGB images of samples placed on the sample stage 101. The data acquisition unit 102 includes a hyperspectral sorting instrument, an industrial camera, and ENVI (Environment for Visualizing Images). During the model training phase, the hyperspectral sorting instrument scans training samples to acquire full-band narrowband spectral data (400nm-1000nm), i.e., hyperspectral data. The industrial camera captures the red, green, and blue broadband spectral data (RGB images) of the training samples or samples to be tested. ENVI is used to select the Region of Interest (ROI) from the data scanned by the hyperspectral sorting instrument and extract the average spectrum of the ROI as the full-band hyperspectral data of the sample (also known as raw spectral data).
[0029] During the training phase, an RGB-hyperspectral data reconstruction model 103, including the MST++ (Multi-scale Transformer Plus Plus) network, is trained based on full-band hyperspectral data acquired by a hyperspectral sorter and RGB images acquired by an industrial camera. The trained RGB-hyperspectral data reconstruction model 103 reconstructs the full-band hyperspectral data of the training samples based on the RGB images of the acquired training samples. The data preprocessing unit 104 includes a Python module (a data preprocessing tool) for preprocessing the full-band hyperspectral data.
[0030] The feature selection unit 105 includes a CARS (Competitive Adaptive Reweighted Sampling) model, which is used to extract feature bands based on preprocessed full-band hyperspectral data.
[0031] The feature weighting unit 106 is used to weight the feature bands.
[0032] Based on the meat type, the characteristic spectra corresponding to the weighted characteristic bands, and the infection duration, a classification task was trained to obtain a pathogen classification model 107. The pathogen classification model 107 includes a PLS-DA (Partial Least Squares Discriminant Analysis) model and an SVM (Support Vector Machine) model. In the detection stage, the PLS-DA model is used to identify the types of pathogens based on the hyperspectral data reconstructed from the RGB image of the test sample.
[0033] This invention provides a method for detecting pathogenic bacteria in meat products, comprising a model training phase and an actual detection phase. The model training phase includes: preparing training samples, collecting hyperspectral data of the training samples, constructing an RGB-hyperspectral data reconstruction model, constructing a pathogen classification model based on the full-band hyperspectral data reconstructed by the RGB-hyperspectral data reconstruction model, verifying the model's performance, and periodically updating the model. The actual detection phase includes: collecting RGB images of the test samples, generating hyperspectral data of the test samples, determining characteristic bands based on the hyperspectral data of the test samples, and inputting the meat product category and characteristic bands of the test samples into the pathogen classification model to classify the pathogenic bacteria.
[0034] Optionally, Figure 2 This is a schematic diagram of the model training process for a method for detecting pathogenic bacteria in meat products according to an embodiment of the present invention, as shown below. Figure 2 As shown, the model training phase includes the following steps S201 to S204:
[0035] S201. Based on the hyperspectral sorting instrument, scan samples of various meat products after they have been infected with different pathogens for various durations, perform black and white correction on the scan data, and extract the average spectrum of the region of interest to obtain full-band hyperspectral data of each training sample; at the same time, acquire RGB images of samples of various meat products after they have been infected with different pathogens for various durations based on the camera.
[0036] Common pathogens include Listeria monocytogenes, Escherichia coli, Salmonella, and Staphylococcus aureus.
[0037] During the training process, at least one type of meat product can be selected to prepare training samples targeting the same type of pathogen. These training samples include inoculated samples and control samples. Inoculated samples are fresh meat products inoculated with a single type of pathogen for different time periods, while control samples are fresh meat products of the same type stored under the same conditions as the inoculated samples for different time periods.
[0038] After the training samples were prepared, they were stored in a constant temperature refrigerator and data were collected daily for a preset number of days. The collected data included visible-near infrared full-band hyperspectral data obtained by scanning the training samples with a hyperspectral sorter and RGB images obtained by an industrial camera.
[0039] It should be noted that black and white correction is performed before scanning the spectrum of the training samples to eliminate interference from light scattering. Specifically, before acquisition, a white plate with 100% reflectance is placed on the sample stage, and the full white spectrum is acquired as a reference; then the light source is turned off, and the full black spectrum is acquired (to eliminate dark current noise). Black and white correction and background removal are performed on the acquired hyperspectral data, and the average spectral data is extracted. Black and white correction is performed based on the black and white correction formula indicated by formula (1) to obtain the corrected spectral data.
[0040] Formula (1)
[0041] S202. Based on the full-band hyperspectral data and RGB images of samples of various meat products after being infected with different pathogens for various durations, an RGB-hyperspectral data reconstruction model is constructed.
[0042] Typically, RGB images only include data from the red, green, and blue color channels. Hyperspectral data can capture spatial images of objects (shape, texture) and record a continuous, detailed spectral curve for each pixel in the image.
[0043] Among them, an RGB-hyperspectral data reconstruction model can be constructed based on a multi-scale deep learning network. The specific network can be selected as needed, and the embodiments of the present invention do not impose specific limitations on this.
[0044] For example, multi-scale deep learning networks can be MST++, HAT (Hybrid Attention Transformer) networks, or MIRNet-v2 (Multi-scale Inverted Residual Network v2).
[0045] S203. Based on the RGB-hyperspectral data reconstruction model, the RGB images corresponding to samples of various meat products infected with each type of pathogen at various time periods are reconstructed to obtain full-band hyperspectral data of metabolite samples of various meat products infected with each type of pathogen at various time periods.
[0046] S204. Using a feature band selection algorithm, the feature bands corresponding to the metabolites of various meat products after infection with each type of pathogen at different durations are determined from the reconstructed full-band hyperspectral data.
[0047] It should be noted that feature band extraction can be performed using relevant technologies as needed, and this embodiment of the invention does not impose specific limitations on this.
[0048] S205, based on deep learning networks and reconstructed full-band hyperspectral data, weighted feature bands.
[0049] Specifically, after obtaining the hyperspectral data of the training samples, the band discrimination weight of each pathogen is determined, and the feature bands of the training samples corresponding to the pathogens are weighted and enhanced according to the band discrimination weight of each pathogen.
[0050] It should be noted that by weighting and enhancing the characteristic bands in the hyperspectral data, not only can the signal intensity of the pathogenic bacteria characteristic bands be significantly increased, but the interference of the meat matrix background can also be suppressed to the maximum extent, thereby improving the signal-to-noise ratio and identifiability of the target features in the reconstructed hyperspectral data.
[0051] S206. Extract the characteristic spectral data corresponding to the weighted characteristic bands from the reconstructed full-band hyperspectral data to obtain the characteristic spectrum.
[0052] For example, spectral reflectance values at each characteristic band can be extracted (or characteristic peak heights and peak-to-trough offsets can be extracted, but reflectance values alone are sufficient) to construct characteristic spectral data.
[0053] S207. Based on the meat type, the type of pathogenic bacteria infecting various meat samples, the duration of infection of each type of pathogenic bacteria in various meat samples, and the corresponding feature spectrum of each duration, a classification task is trained to obtain a pathogenic bacteria classification model.
[0054] Specifically, a modeling dataset is constructed using the reconstructed hyperspectral data of the training samples as input features and the pathogenic bacteria species labels corresponding to the reconstructed hyperspectral data as output. This modeling dataset is then used to train and optimize the pathogenic bacteria classification model, resulting in a fully trained pathogenic bacteria classification model.
[0055] Based on this scheme, during the training phase, hyperspectral data of various meats infected with various pathogens can be scanned using a hyperspectral sorting instrument, while simultaneously acquiring RGB images. Then, by establishing an RGB-hyperspectral data reconstruction model, the signal intensity of the characteristic bands of pathogens in the reconstructed hyperspectral data is weighted, and the model is trained based on the feature-weighted hyperspectral data and the initial classification model. This yields a pathogen classification model that accurately identifies various types of meat products infected with various pathogens based on hyperspectral features.
[0056] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, an RGB-hyperspectral data reconstruction model can be trained based on an MST++ (Multi-scale Transformer Plus Plus) network. Therefore, the aforementioned S202 may specifically include the following S202a to S202f:
[0057] S202a. For RGB images of various meat products after infection with different pathogens for different durations, the self-attention mechanism in the MST++ network is used to extract shallow surface features of the RGB images.
[0058] For example, shallow appearance features include: edges, textures, color gradients, etc.
[0059] S202b upgrades the shallow representation features of RGB images to deep abstract features of RGB images through the multi-layer network of the Stacked Neural Network Module (SNNM) in the MST++ network.
[0060] S202c: The spectral dimension attention mechanism in MST++ is used to determine the band association between the three wide bands (R, G, B) of each RGB image and the 256 narrow bands of the corresponding hyperspectral data based on the deep abstract features of the RGB image.
[0061] S202d, based on the decoder and band association relationship in MST++, expands the wide channel features of R, G, and B of each RGB image into 256 narrow channel features to generate initial hyperspectral data.
[0062] S202e, based on the initial hyperspectral data and the MARE (Mean Absolute Relative Error) loss function, iteratively obtains the trained RGB-hyperspectral data reconstruction model based on the multi-scale transformer network MST++ by minimizing the deviation between the initial spectral data and the original hyperspectral data.
[0063] By minimizing the loss function between the reconstructed hyperspectral data and the original spectral data of various meat samples, the network parameters are iteratively optimized to construct a hyperspectral reconstruction model. It can be understood that during the iteration process, the reconstruction accuracy of the reconstructed hyperspectral data is evaluated to select the final hyperspectral reconstruction model.
[0064] For example, RGB images of meat samples that meet the specifications are collected, and multi-scale visual features are extracted after targeted preprocessing. The full-band hyperspectral data is then reconstructed by mapping through a multi-scale deep learning network. The reconstructed data follows the same preprocessing and feature selection criteria as the original hyperspectral data, providing data support for subsequent pathogen detection and freshness assessment.
[0065] After receiving RGB images, the RGB-hyperspectral data reconstruction model first performs lightweight processing to ensure the data is computationally compliant and interference-free: the RGB images are converted to a model-compatible format, such as JPEG (Joint Photographic Experts Group) format or tensors, and then the images are cropped and scaled to a fixed size (e.g., 400×301×3) to avoid calculation errors caused by inconsistent sizes. The pixel values (0-255) of the RGB images are scaled to the range of 0-1 or -1-1 to reduce the interference of differences in illumination intensity on model training and make gradient descent more stable. Since the RGB images are real photographs, color space conversion is required (e.g., aligning the R, G, and B channels with the corresponding bands of the hyperspectral data (e.g., R→620-780nm) for initial alignment). The model then extracts core features from the three channels of the RGB image that can be mapped to the hyperspectral data using convolution and attention mechanisms. A self-attention mechanism (Transformer-like model, MST++) is used to extract shallow features such as edges, textures, and color gradients from the RGB image. These are then upgraded to deep abstract features through a multi-layer network. A spectral-wise self-attention mechanism directly captures the long-distance dependence between RGB image features and each band of the hyperspectral data, i.e., the association between R, G, and B and 256 bands. The decoder can expand the 3-channel features to 256 channels, accurately restoring the reflectance of each narrow band. The MARE loss function is used for optimization to correct spectral bias, ultimately outputting a root mean square error (RMSE) of 0.015 and a peak signal-to-noise ratio (PSNR). The model outputs high-quality hyperspectral data with a ratio (PSNR) of 36.70. Finally, the model outputs three-dimensional data consistent with the actual HSI size, with each pixel corresponding to a complete spectral curve.
[0066] Based on this scheme, a multi-scale feature extraction module captures local details and global trends in the spectrum. An attention mechanism is used to weight the relevant bands of pathogenic bacteria features, outputting reconstructed hyperspectral data. This data can be used to train a hyperspectral reconstruction model. A mapping relationship can be established between RGB images and hyperspectral data of meat products infected with pathogenic bacteria at various time points. This eliminates the need for complex and expensive hyperspectral data acquisition equipment to collect hyperspectral data from the test samples, and also eliminates the need for long-term sample preparation and testing. Furthermore, based on low-cost, easily accessible input source RGB images, the three-channel broadband spectral information can be used to quickly recover spectral features containing hundreds of narrow bands for pathogen identification.
[0067] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, the feature band selection algorithm can be selected according to actual needs. In this embodiment of the invention, the CARS algorithm is used as the feature band selection algorithm for feature screening to extract the feature bands of the samples. Specifically, the feature bands of the samples (training samples or monitoring samples) can be determined based on the CARS algorithm through the following steps.
[0068] Furthermore, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, step S204 can be specifically performed by steps S204a to S204c as follows:
[0069] S204a. For each type of pathogen, resampling technology is used on the reconstructed full-band hyperspectral data to generate multiple modeling subsets.
[0070] Specifically, using "reconstructed full-band spectral data - pathogenic bacteria species labels" as the dataset, multiple subsets were generated through Monte Carlo sampling (500 sampling times).
[0071] S204b. Construct partial least squares regression (PLSR) models for each modeling subset to determine the absolute values of regression coefficients for each wavelength and the spectral difference index of pathogens in the reconstructed full-band hyperspectral data.
[0072] The pathogenic bacteria spectral difference index is used to quantify the ability of a specific band to distinguish between different pathogenic bacteria (or pathogenic bacteria and healthy samples). In the iteration of CARS, the pathogenic bacteria spectral difference index and the absolute value of the regression coefficient are used together to screen bands.
[0073] In this context, a larger absolute value of the regression coefficient for a given band indicates a stronger association between that band and the type of pathogen; conversely, a smaller absolute value indicates a weaker association. A larger pathogenic spectral difference index for a given band indicates a greater difference between that band and other pathogenic bacteria; conversely, a smaller pathogenic spectral difference index indicates a smaller difference between that band and other pathogenic bacteria.
[0074] S204c. In each iteration, the characteristic bands of pathogenic bacteria metabolites are selected according to the absolute value of the regression coefficient and the spectral difference index of pathogenic bacteria.
[0075] Optionally, S204c above specifically includes: determining the spectral difference index of pathogenic bacteria, and selecting a band from the entire band that can distinguish the first pathogenic bacteria from other pathogenic bacteria based on the spectral difference index of pathogenic bacteria.
[0076] For example, the pathogenic spectral difference index is an indicator used to quantify the ability of a specific wavelength band to distinguish different pathogenic species. It typically combines inter-class distance and intra-class variance.
[0077] The formula for the spectral difference index is as follows (2):
[0078] Formula (2)
[0079] in, At wavelength Spectral difference index at the location; This indicates that all samples of pathogenic bacteria A are at wavelength The average reflectance at that location. This indicates that all samples of pathogenic bacteria B are at wavelength Average reflectance at; This indicates that all samples of pathogenic bacteria A are at wavelength The standard deviation of reflectance at that location. This indicates that all samples of pathogenic bacteria B are at wavelengths... The standard deviation of reflectance at that location.
[0080] If the spectral difference index between the two bacteria is higher at 630nm than at 720nm, it indicates a large difference in average reflectance between the two bacteria at this point, and that their data distributions are concentrated (small within-class variance). This suggests that the 630nm band has a very strong distinguishing ability for certain bacteria. Therefore, the feature selection algorithm will preferentially retain 630nm as a key feature band, while likely discarding the less distinguishing 720nm band.
[0081] It is understandable that if the pathogenic bacteria spectral difference index indicates the spectral difference between meat spectral data after inoculation with the first pathogenic bacteria and meat spectral data without inoculation with the first pathogenic bacteria, as well as the spectral difference between meat spectral data after inoculation with the first pathogenic bacteria and meat spectral data after inoculation with the first pathogenic bacteria, then the second pathogenic bacteria are other pathogenic bacteria of different species from the first pathogenic bacteria selected during the training phase.
[0082] It is understandable that, using the spectrum of uninoculated meat as a benchmark, after infection with different pathogens, the spectral characteristics of meat with different pathogens will differ in some bands and be similar in others. Based on the pathogen spectral difference index, characteristic wavelengths with high distinguishability among different pathogen species can be preferentially retained during the characteristic band selection process.
[0083] It is understandable that the spectrum of meat products without pathogen inoculation can be used as a reference spectrum to determine the distinguishing bands between the spectrum of meat products with the first pathogen and those without pathogen inoculation, such as bands 1, 2, and 3; and the distinguishing bands between the spectrum of meat products with the second pathogen and those without pathogen inoculation, such as bands 2, 3, and 4. If bands 2 and 3 are determined to be the distinguishing bands compared to the reference spectrum, then band 1 can be identified as the distinguishing band for the first pathogen, and band 4 can be identified as the distinguishing band for the second pathogen.
[0084] It should be noted that the spectral changes of different pathogens occur at different rates over time. For example, the spectral changes of the first pathogen begin on the fourth day after inoculation; the spectrum remains unchanged compared to the baseline spectrum for the first three days, but changes occur daily thereafter. The spectral changes of the second pathogen begin on the second day after inoculation; the spectrum remains unchanged compared to the baseline spectrum on the first day, but changes occur daily thereafter.
[0085] For example, after the iteration termination condition is met (e.g., the number of iterations equals 150 or the loss value meets the preset loss value), feature bands (40 to 50) that can reflect the characteristics of different pathogens are extracted, and the spectral data of these bands are used as the spectral data to be reconstructed for different pathogens.
[0086] Based on this scheme, competitive adaptive reweighted sampling is used during the training process to screen out the characteristic spectral bands that are most correlated with the types of pathogens, thereby providing data support for accurately distinguishing different types of pathogens in the future.
[0087] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, S205 may specifically include the following S205a:
[0088] S205a. The full-band hyperspectral data reconstructed from various meat samples and the extracted feature bands are input into a deep learning network. Through multi-window feature extraction, fusion and weight adjustment, the weighted feature bands are output.
[0089] Based on this scheme, feature bands can be extracted from the reconstructed full-band hyperspectral data to form the feature bands corresponding to pathogens in various meat samples. Then, these feature bands are weighted to obtain the signal intensity of the significantly weighted pathogen feature bands. Based on the spectrum of the signal intensity of the pathogen feature bands, it is possible to more accurately distinguish the spectral characteristics of the same type of meat infected with different pathogens, and to more accurately distinguish the spectral characteristics of different types of meat infected with the same type of pathogens, thereby improving the accuracy of the learned model in classifying pathogens.
[0090] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, the deep learning network is a window attention mechanism (Swin transformer) model; furthermore, the above-mentioned S205a can be specifically executed through the following a1 to a3:
[0091] a1: The reconstructed full-band spectral data of various meat samples were divided into multiple windows using the Swin transformer model, and the characteristic bands of each sub-band range were extracted.
[0092] a2: Using the attention mechanism in the Swing transformer model, the weights of characteristic bands within each sub-band range are adjusted based on the correlation between band and pathogenic bacteria absorption peak.
[0093] It is understandable that the attention mechanism can be used to weight the characteristic bands of pathogens.
[0094] For example, during the training of the pathogen classification model in this embodiment of the invention, the 630-670nm absorption peak band can be weighted for Listeria monocytogenes.
[0095] For example, in Listeria monocytogenes, the attention mechanism significantly increases the weight of the sub-window containing its key absorption peak of 630-670 nm, while suppressing the weight of other irrelevant bands, thereby amplifying the characteristic signal of the pathogen. This means that the weight of certain bands is increased.
[0096] a3: By fusing the spectral features of each sub-band range after weight adjustment using the Swin transformer model, the weighted feature bands of various meat samples are output.
[0097] Using a one-dimensional spectral sequence as input, the Swin transformer model automatically divides the spectrum into windows, with each window containing a continuous wavelength. The Swin transformer model learns local spectral features through its inherent window self-attention and then uses a shift window mechanism to enable information exchange between different windows, thereby automatically and dynamically fusing the features of each spectral band and adjusting the contribution of key bands based on attention weights.
[0098] For example, within a window containing wavelengths of 630nm-645nm, the self-attention mechanism calculates the correlation between the 16 wavelengths within that window. If the variation patterns of the 630nm and 635nm wavelengths are highly consistent, and they jointly play a dominant role in the feature representation of this window, the Swin transformer model assigns higher attention weights to the 630nm and 635nm bands within this window. This process is performed independently within each window, capturing local details of the spectrum. In the next layer, the starting point of the window is shifted (left or right), and adjacent bands that were previously in different windows are now included in the same new window. At this point, the Swin transformer model breaks through the limitations of fixed windows, establishing cross-window dependencies and thus capturing the global trend of the spectrum. The Swin transformer model ultimately learns a dynamic, context-aware weight for each of the selected bands. For key bands that are identified as strongly correlated with pathogen classification in multiple windows, the accumulated attention weights are very high. The Swintransformer model relies heavily on the features provided by these high-weight bands when making its final classification decision.
[0099] Based on this scheme, by using the Swin transformer model for feature band weighting, it can capture both local details and global trends of the spectrum through multi-window partitioning and attention mechanisms. This allows for the accurate preservation of pathogenic bacteria feature bands. By allocating weights, key bands related to the absorption peaks of pathogenic bacteria metabolites are given priority weight. This effectively avoids the feature loss problem caused by traditional PCA (Principal Component Analysis) interpolation or linear reconstruction methods, significantly improving the signal-to-noise ratio and feature fidelity of the reconstructed spectrum, and providing higher quality data input for subsequent classification.
[0100] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, quantitative classification training of pathogenic bacteria can be performed based on the PLS-DA model and the SVM model to obtain a pathogenic bacteria classification model based on the PLS-DA model and the SVM model. Specifically, S207 may include the following S207a to S207d:
[0101] S207a. Divide the modeling datasets corresponding to each type of pathogen infecting various meat products into training set, validation set and test set according to the proportion.
[0102] S207b: Training a pathogen classification model using a training set, PLS-DA model, and SVM model.
[0103] S207c. Optimize the model parameters of the pathogen classification model obtained by training through cross-validation using the validation set.
[0104] For example, a dataset for 5-fold cross-validation can be divided into a training set, a validation set, and a test set in a 7:1:2 ratio.
[0105] For example, based on the PLS-DA model and the SVM model, the preprocessed and feature-selected spectral data and daily spectral data are subjected to partial least squares discriminant analysis and support vector machine, and the model parameters of the pathogen classification model are optimized through 5-fold cross-validation.
[0106] S207d. Determine whether the pathogen classification model has been successfully trained based on the classification accuracy of the test set.
[0107] Specifically, the accuracy rate of pathogen identification in the test set is used as an indicator. By comparing the classification accuracy of the models, the model with higher accuracy is selected as the final pathogen classification model. Usually, the SVM (Support Vector Machine) model performs better in complex spectral data, with an accuracy rate of over 92%.
[0108] Model update:
[0109] After the pathogen classification model is trained and applied, new pathogen inoculation samples can be added at preset intervals to re-execute the above training process, optimizing the spectral reconstruction model and the pathogen classification model, thereby increasing the number of pathogen classification types in the model. Furthermore, the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention may further include S208 and S209 after S207.
[0110] S208. Collect hyperspectral data of various meat samples with newly added pathogenic bacteria.
[0111] Among the newly added pathogenic bacteria are common foodborne pathogens.
[0112] For example, if a new type of pathogen is identified, new pathogen inoculation samples can be added.
[0113] S209. Update the training sets of the spectral reconstruction model and the pathogen classification model, and re-optimize the hyperspectral reconstruction model and the pathogen classification model.
[0114] It should be noted that during the training phase (and update phase) of generating the training sets for the spectral reconstruction model and the pathogen classification model, outliers in the samples can be removed based on the Z-score method.
[0115] First, hyperspectral feature parameters of pathogenic bacteria samples in meat products are extracted to obtain a multi-dimensional feature matrix of the samples. Let the sample set for the m-th feature dimension be... , Represents the total number of samples. Indicates the first The original feature values of each sample (e.g., hyperspectral reflectance). Calculate the mean of the samples in the m-th feature dimension. and sample standard deviation , , Based on the calculation of the sample mean of the m-th feature dimension and sample standard deviation Calculate the Z-value of the m-th feature dimension for each sample. This yields the Z-values for each feature dimension of each sample. Then, the " "Principles", that is Samples outside this range will be identified as outliers and removed.
[0116] During the model update phase, stratified sampling can be used according to pathogen categories to maintain a 1:1 ratio of new to old samples, ensuring a balanced number of samples for each type of pathogen. The old samples are divided into k strata according to pathogen categories (i.e., the original total number of types is k). The number of old samples in each stratum is counted; for example, the number of old samples in the q-th stratum (i.e., the q-th type of pathogen) is... The number of new samples drawn from the newly collected samples. Each layer is sampled independently, and the proportion of samples in layer q is... The proportion of samples in each layer is consistent with that in the whole, so that the ratio of new to old samples is 1:1. All new and old samples in all layers are merged to form an updated training set, ensuring that the number of samples of various pathogens is balanced.
[0117] Based on Z-score, the deviation of samples from the data distribution is quantified by standardized scoring, and the anomaly screening of hyperspectral multidimensional features can eliminate the influence of feature dimensions.
[0118] Based on this scheme, by establishing a model update mechanism that includes Z-score outlier removal and stratified sampling, the system can continuously learn the characteristics of newly emerging pathogens, thereby continuously improving the identification coverage and comparison accuracy of diverse pathogens. Based on the updated training set, the MST++ hyperspectral reconstruction model and PLS-DA / SVM classification model are retrained to improve the identification coverage and classification accuracy of diverse pathogens, and extend the lifespan and application scope of the model.
[0119] II. Actual Testing Phase
[0120] Figure 3This is a flowchart illustrating a method for detecting pathogenic bacteria in meat products according to an embodiment of the present invention. Figure 3 As shown, the method includes the following steps S301 to S303:
[0121] S301. Based on the RGB image of the test sample of the target type meat product and the pre-trained RGB-hyperspectral data reconstruction model, reconstruct the full-band hyperspectral data of the test sample.
[0122] The RGB-hyperspectral data reconstruction model includes the mapping relationship between RGB images and full-band hyperspectral data of various meat products after they have been infected with different pathogens for different durations.
[0123] Specifically, the sample to be tested is placed on the sample stage, and RGB images of the sample to be tested are acquired according to the same parameter settings and procedures as in the training phase.
[0124] S302. Preprocess the full-band hyperspectral data of the reconstructed sample to be tested.
[0125] Optionally, preprocessing includes: Standard Normal Variate (SNV) transformation and Multiplicative Scatter Correction (MSC). SNV transformation eliminates baseline drift caused by sample surface flatness and optical path differences.
[0126] For example, the extracted average spectral data can be preprocessed to eliminate interference such as noise, baseline drift, and light scattering. For instance, a Python platform can be used for preprocessing.
[0127] The average spectral data is standardized by SNV transformation based on formula (2).
[0128] Formula (2)
[0129] in, This represents the reflectance of each effective detection band in the reconstructed hyperspectral data of the meat sample. Indicates the spectral mean. This represents the standard deviation of the spectrum.
[0130] S303. The characteristic band selection algorithm is adopted to determine the characteristic bands of the sample to be tested based on the preprocessed full-band hyperspectral data.
[0131] For example, the same CARS algorithm used in the training phase can be employed to filter feature bands in the full-band spectral data reconstructed from the test sample, thus obtaining the feature bands of the test sample. Due to the use of competitive adaptive reweighted sampling, Monte Carlo sampling can adaptively filter out the most relevant feature bands (approximately 45) from the full band (400-1000nm) to the pathogenic bacteria species. This effectively eliminates redundant information and noise in the spectral data generated by the RGB-hyperspectral data reconstruction model, reducing the data dimensionality by approximately 88%, thereby significantly reducing the computational burden of the subsequent pathogen classification model while improving the model's speed and generalization ability.
[0132] S304. Extract the characteristic spectra corresponding to the characteristic bands from the preprocessed full-band hyperspectral data.
[0133] S305. Input the meat type and characteristic spectrum of the sample to be tested into the pre-trained pathogen classification model, and output the classification result of pathogen types of the sample to be tested.
[0134] Among them, the pre-trained pathogen classification model indicates the spectral characteristics of the characteristic bands of metabolites of various meat products after infection with various pathogens for various durations, as well as the spectral characteristics of the control group of various meat products after infection with pathogens for various durations. The pathogen spectral characteristics stored in the pathogen classification model are the spectral characteristics corresponding to the weighted characteristic bands.
[0135] This invention provides a method for detecting pathogenic bacteria in meat products. First, during the detection phase, RGB images of the sample to be tested can be directly acquired. Then, the RGB images are input into an RGB-hyperspectral data reconstruction model to obtain reconstructed full-band hyperspectral data. This eliminates the need to capture hyperspectral images for each test. A feature band selection algorithm can be used to extract feature bands based on the reconstructed hyperspectral data. Based on the spectral features corresponding to these feature bands and a pre-trained pathogen classification model, pathogenic bacteria species can be identified. This method enables rapid, non-destructive, and high-precision detection of pathogenic bacteria in meat products. This method eliminates the need for destructive sampling, shortening the detection cycle from 3-7 days using traditional culture methods to within 30 minutes. It can recover key spectral feature information of pathogenic bacteria from RGB images, avoiding the loss of key spectral feature information, and improving the overall identification accuracy to over 92%, meeting the needs of rapid on-site quality inspection in the food industry.
[0136] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, S305 can specifically be S305a or S305b as described below.
[0137] S305a. If the characteristic spectrum of the sample to be tested matches the spectral characteristics of the target type of meat after being infected with the first pathogenic bacterium for a first duration, then output that the target type of meat is infected with the first pathogenic bacterium and the infection duration is the first duration.
[0138] S305b: If the characteristic spectrum of the sample to be tested does not match all the spectral features corresponding to the target type of meat in the pathogen classification model, then the output will be that the sample to be tested of the target type of meat is infected with an unknown type of pathogen.
[0139] Based on this scheme, not only can the characteristic bands of the sample under test be compared with the spectral characteristics of various meat products infected with various pathogens at different times after infection, as learned in the pathogen classification model, to determine whether there are matching spectral characteristics and thus identify the type of pathogen, but also, if the spectral characteristics of the identification model do not match any pathogens at any time, they can be compared with the spectral characteristics of the control group of meat products that are not infected with any pathogens at different times to determine whether they are infected with new pathogens, thus providing a solid guarantee for the safety quarantine of meat products.
[0140] Optionally, in the method for detecting pathogenic bacteria in meat products provided in this embodiment of the invention, after S305b, the method may further include S306:
[0141] S306. Update the pathogen classification model based on the spectral characteristics of unknown types of pathogens corresponding to the characteristic bands of the sample to be tested.
[0142] Specifically, a new type label can be created for unknown types of pathogens, and then the pathogen classification model can be updated based on the spectral characteristics and type label of the unknown types of pathogens.
[0143] Based on this scheme, in the practical application of the pathogen classification model, after identifying a new pathogen based on the hyperspectral features reconstructed from the RGB image of the sample to be tested, the reconstructed spectral features of the new pathogen are updated into the pathogen classification model. This allows for subsequent detection of whether meat products are infected with the new pathogen based on the updated pathogen classification model, thus providing more flexible identification for meat product quarantine.
[0144] Example of experimental procedure:
[0145] For example, the complete process of preparing and storing training samples is illustrated using pathogenic bacteria and quarantine-qualified fresh beef as an example.
[0146] Experiments were conducted using Staphylococcus aureus (ATCC 6538), Listeria monocytogenes (standard strain: ATCC 19115), and Escherichia coli (standard strain: ATCC 25922) as examples of pathogenic bacteria. The hyperspectral sorting instrument's spectral acquisition range was set to 400 nm to 1000 nm, the spectral sampling interval to 2 nm to 3 nm, and the vertical distance between the detector and the sample surface to a fixed 25 cm to 27 cm. The color imaging camera (industrial grade) parameters included: camera resolution of 2592 × 1944, and the camera distance to the sample surface maintained at 37 cm to 39 cm.
[0147] (1) Preparation of training samples
[0148] The pathogenic bacteria were cultured in LB (Lysogeny-Broth) medium at 37°C for 24 hours. The concentration was then calibrated using a serial dilution plate count method to prepare a 10⁻⁶ concentration. 6 CFU / mL bacterial suspension. Wherein, CFU stands for Colony-Forming Units per Milliliter.
[0149] Fresh, inspected and certified beef was selected, and surface fascia, fat, and connective tissue were removed. Stainless steel knives were sterilized with 75% ethanol and air-dried until no ethanol residue remained. The beef was cut into small pieces to ensure uniformity of meat quality. The cut beef pieces were placed in a sterile meat grinder and ground twice, cleaning the inner wall of the grinder after each grinding to avoid residue, resulting in a homogeneous meat paste. After grinding, any remaining small fascia impurities were manually removed from the meat paste to ensure the purity of the sample composition.
[0150] After pretreatment of fresh beef, samples were placed in 6 cm diameter sterile petri dishes, with 10 g of meat paste in each dish. The surface was smoothed to ensure a consistent sample thickness (approximately 0.5 cm) during spectral acquisition. Pathogenic bacteria were then obtained from the beef samples. After sterilizing and cooling the inoculation needle with the outer flame of an alcohol lamp, 100 μL of a known concentration of bacterial suspension was dipped into the needle and streaked in an "X" pattern on the homogenized meat paste surface. After each sample was inoculated, the inoculation needle was sterilized again with an alcohol lamp to avoid cross-contamination, and the inoculated sterile petri dishes were sealed. Simulating the storage environment of cold chain transportation and retail, the inoculated samples and uninoculated blank fresh beef samples were stored together in a 10°C constant temperature refrigerator at a relative humidity of 60%-70% for 0-7 days.
[0151] (2) Data collection
[0152] At a fixed time each day, black and white correction is performed first, and then hyperspectral data and RGB images of all samples are collected at 15:00 every day to ensure that the storage time of different samples is consistent with the timeliness of data collection and to eliminate the interference of time difference on spectral characteristics.
[0153] With the light source turned on, the sample petri dish was placed in the center of the sample stage. A hyperspectral sorter was used to scan the sample, acquiring visible-near-infrared spectral data. Simultaneously, an industrial-grade camera was used to capture RGB images, which served as a benchmark for subsequent comparative analysis. Each sample was scanned three times, with the sample repositioned before each scan to simulate the randomness of actual testing. After scanning, the central region of approximately 4000 pixels on the sample was selected as the ROI (Region of Interest), and the average spectrum of this region was extracted as the final visible-near-infrared spectral data for that sample on that day.
[0154] During the training phase of the hyperspectral reconstruction model, the Adam (Adaptive Moment Estimation) solver can be selected for network parameter optimization. The Adam solver parameters are set as follows: batch size of 20, first-order decay exponent of 0.900, second-order decay exponent of 0.999, initial learning rate of 0.0004, and cosine annealing for 300 iterations. Training is stopped when the training loss no longer decreases significantly.
[0155] The reconstruction quality evaluation metrics for hyperspectral reconstruction models include: MARE, RMSE, and PSNR. RMSE measures the average error between the reconstructed hyperspectral data and the acquired hyperspectral data; a smaller RMSE indicates higher reconstruction accuracy. PSNR measures the predictive power of the hyperspectral reconstruction model.
[0156] RPD = Standard deviation of acquired hyperspectral data / RMSE. When RPD > 2.5, the hyperspectral reconstruction model has excellent predictive ability; when 1.8 < RPD ≤ 2.5, the hyperspectral reconstruction model has good predictive ability; when RPD ≤ 1.8, the hyperspectral reconstruction model is unusable. For example, a model with RPD ≥ 2.5 and RMSE ≤ 0.02 can be selected as the final RGB-hyperspectral data reconstruction model.
[0157] After reconstructing the full-band hyperspectral data corresponding to the acquired RGB images using the RGB-hyperspectral data reconstruction model, the data is preprocessed according to the above-described preprocessing method to obtain the preprocessed reconstructed full-band hyperspectral data. Then, based on the preprocessed reconstructed hyperspectral data, the pathogen classification model is trained using the aforementioned training method. The evaluation metrics for the pathogen classification model include: accuracy, precision, specificity, and sensitivity.
[0158] After obtaining the trained hyperspectral reconstruction model and the trained pathogen classification model, based on the trained models and the detection steps in the above method embodiments, 160 beef samples (including 40 healthy samples, 40 samples contaminated with Listeria monocytogenes, 40 samples contaminated with Escherichia coli, and 40 samples contaminated with Staphylococcus aureus) were tested, and the pathogen classification results of the samples were output: "Listeria monocytogenes", "Escherichia coli", "Staphylococcus aureus", "unknown bacteria" or "uninfected". The following experimental data were then obtained.
[0159] (1) Hyperspectral reconstruction performance
[0160] Reconstruction accuracy metrics: Relative analysis error RPD = 2.8, coefficient of determination R² = 0.96, root mean square error RMSE = 0.018.
[0161] The reconstructed hyperspectral data showed an approximately 35% improvement in signal-to-noise ratio in the pathogenic bacteria characteristic band (630-670nm).
[0162] Compared to the acquired hyperspectral data, the reconstructed hyperspectral data exhibits a reduction in baseline drift of approximately 60%.
[0163] (2) Accuracy of pathogen classification
[0164] Overall classification accuracy: 93.5%.
[0165] Listeria monocytogenes identification accuracy: 94.2%.
[0166] Escherichia coli identification accuracy: 92.8%.
[0167] Accuracy rate for identifying healthy samples: 93.5%.
[0168] Precision ≥ 90%, recall ≥ 90%, false positive rate ≤ 3%.
[0169] (3) Comparison with traditional methods
[0170] Testing cycle: shortened from 3-7 days using traditional culture methods to within 30 minutes.
[0171] Accuracy: Improved to over 92% compared to immunochromatography (false positive rate ≥8%).
[0172] Anti-interference capability: After SG / SNV preprocessing, the stability to changes in ambient light is improved by about 40%.
[0173] It should be noted that the experimental comparisons during training were based on the acquired RGB images. RGB images can only reflect the RGB three channels of beef color, and can only identify the presence or absence of pathogenic bacteria contamination, but cannot distinguish the species. They are significantly affected by ambient light and have poor anti-interference capabilities. They cannot capture the spectral characteristics produced by pathogenic bacteria metabolism, such as the 630nm-670nm absorption peak of Listeria monocytogenes. The spectrum reconstructed by the hyperspectral reconstruction model can cover the 400nm-1000nm band.
[0174] Figure 4 This is a schematic diagram of hyperspectral data of Staphylococcus aureus collected according to an embodiment of the present invention. Figure 5 This is a schematic diagram of Staphylococcus aureus spectral data after SNV processing, provided in an embodiment of the present invention. Figure 6 This is a schematic diagram of Staphylococcus aureus spectral data after co-processing with SNV and MSC, provided as an embodiment of the present invention. Figure 4 Significant baseline drift and fluctuations were observed, with low spectral overlap between different samples in the same wavelength band. Furthermore, light scattering interference caused by uneven meat paste particle size and local thickness made it impossible to clearly distinguish pathogenic bacteria characteristics. For example... Figure 5 As shown, by eliminating optical path differences in individual samples through normalization, the overall spectral baseline becomes stable, and the consistency of spectral trends among different samples is improved, but scattering noise still exists in some bands. Figure 6 As shown, after SNV+MSC processing, the interference of physical structure inhomogeneity is further eliminated by multivariate scattering correction on the basis of SNV, and the smoothness of the spectral curve is improved.
[0175] Figure 7This diagram illustrates the spectral data of Staphylococcus aureus after feature screening, as provided in an embodiment of the present invention. The diagram shows the spectral distribution of 31 characteristic wavelengths after screening using the CARS algorithm. The core characteristic bands are concentrated in the regions of 414.1 nm, 457.8 nm, 487.2 nm, 521.6 nm, 626.15 nm, 750.4 nm, 869.3 nm, and 974.5 nm. These bands correspond to the characteristic absorption peaks of pathogenic bacterial metabolites in beef, and avoid the strong absorption interference regions of beef's own moisture and fat, ensuring that the screened features are related to the pathogenic bacteria species. Redundant bands are eliminated through weight calculation to avoid interference from irrelevant information, avoid the strong absorption bands of beef's own components, reduce the influence of the sample matrix on the detection results, and ensure that pathogenic bacteria can be stably identified in different batches of beef samples.
[0176] Figure 8 This diagram illustrates the original spectral data and reconstructed Staphylococcus aureus spectral data provided in an embodiment of the present invention. The curves of the original spectral data and the spectral data reconstructed by the MST++ algorithm are superimposed for comparison. The horizontal axis represents the characteristic wavelengths (414.1-974.5 nm), and the vertical axis represents the spectral response values. As can be seen from the figure, the curve trends of the reconstructed spectral data and the original spectral data highly overlap. The response value errors in key characteristic bands (such as 487.2 nm, 626.15 nm, and 750.4 nm) are extremely small, and there is no obvious waveform distortion. This indicates that the MST++ algorithm successfully captures both local details and global trends of the spectrum through "three-scale feature extraction (400-600 nm, 600-800 nm, 800-1000 nm) + attention mechanism." It eliminates the need for expensive hyperspectral imaging equipment to continuously acquire original spectral data; equivalent hyperspectral data can be generated simply through RGB images and a reconstruction model, reducing the investment cost and lowering the barrier to entry for detection equipment.
[0177] The above embodiments, through detailed description of specific implementation methods, fully demonstrate the technical solution and beneficial effects of the present invention, ensuring the repeatability, standardization, and high precision of the method, and are applicable to meat pathogen detection scenarios in the food industry, food safety supervision, and scientific research fields.
[0178] Corresponding to the embodiments of the aforementioned methods, the present invention also provides embodiments of the apparatus and the terminal to which it is applied.
[0179] The embodiments of the method for detecting pathogenic bacteria in meat products of the present invention can be applied to computer equipment, such as servers or terminal devices. The method embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor of the meat pathogenic bacteria detection device loading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, such as...Figure 9 The diagram shown is a hardware structure diagram of a computer device used in a method for detecting pathogenic bacteria in meat products according to an embodiment of the present invention. Except for... Figure 9 In addition to the processor 910, memory 930, network interface 920, and non-volatile memory 940 shown, the server or electronic device where the method for detecting pathogenic bacteria in meat products 931 is located in the embodiment may also include other hardware depending on the actual function of the computer device, which will not be described in detail here.
[0180] Figure 10 This is a schematic diagram of a detection device for pathogenic bacteria in meat products provided in an embodiment of the present invention, as shown below. Figure 10 As shown, the detection device 1000 for pathogenic bacteria in meat products includes: a hyperspectral data reconstruction module 1001, a preprocessing module 1002, a feature band determination module 1003, a feature spectrum extraction module 1004, and a pathogen classification module 1005; the hyperspectral data reconstruction module 1001 is used to reconstruct the full-band hyperspectral data of the test sample based on the RGB image of the test sample of the target type of meat and a pre-trained RGB-hyperspectral data reconstruction model; the RGB-hyperspectral data reconstruction model includes the mapping relationship between RGB images and full-band hyperspectral data of various types of meat products infected with different pathogens for different durations; the preprocessing module 1002 is used to preprocess the reconstructed full-band hyperspectral data of the test sample; the feature band determination module 1003... The system employs a feature band selection algorithm to determine the feature bands of the sample to be tested based on preprocessed full-band hyperspectral data; a feature spectrum extraction module 1004 is used to extract the feature spectra corresponding to the feature bands from the preprocessed full-band hyperspectral data; and a pathogen classification module 1005 is used to input the meat type and feature spectrum of the sample to be tested into a pre-trained pathogen classification model and output the pathogen classification results of the sample to be tested. The pre-trained pathogen classification model indicates the spectral characteristics of the metabolites of various types of meat after infection with various pathogens for various durations, as well as the spectral characteristics of the control group of various types of meat after infection with pathogens for various durations. The pathogen spectral characteristics stored in the pathogen classification model are the weighted spectral characteristics corresponding to the feature bands.
[0181] Optionally, the pathogen classification module 1005 is used to output that the target type of meat is infected with the first pathogen and the infection duration is the first duration if the characteristic spectrum of the sample to be tested matches the spectral characteristics of the target type of meat after being infected with the first pathogen for a first duration; if the characteristic spectrum of the sample to be tested does not match all the spectral characteristics of the target type of meat in the pathogen classification model, then the sample to be tested of the target type of meat is infected with an unknown type of pathogen.
[0182] Optionally, the detection device for pathogenic bacteria in meat products further includes: a data acquisition module and a model training module; the data acquisition module is used to perform black-and-white correction on the scanned samples of various types of meat products after they have been infected with different pathogenic bacteria for various time periods based on a hyperspectral sorting instrument, and extract the average spectrum of the region of interest to obtain full-band hyperspectral data for each sample; at the same time, it acquires RGB images of samples of various types of meat products after they have been infected with different pathogenic bacteria for various time periods based on a camera; the model training module is used to construct an RGB-hyperspectral data reconstruction model based on the full-band hyperspectral data and RGB images of samples of various types of meat products after they have been infected with different pathogenic bacteria for various time periods.
[0183] Optionally, the detection device for pathogenic bacteria in meat products further includes: a feature band weighting module; a hyperspectral data reconstruction module 1001, which is further used to reconstruct full-band hyperspectral data of metabolite samples of various types of meat products after infection with each type of pathogenic bacteria at various time periods based on the RGB images corresponding to the samples after infection with each type of pathogenic bacteria at various time periods according to the RGB image of ... according to the RGB image of the samples after infection with each type of pathogenic bacteria at various time periods according to the RGB image of the samples after infection with each type of pathogenic bacteria according to the RGB image of the samples after infection with each type of pathogenic bacteria according to the RGB image of the samples after infection with each type of pathogenic bacteria according to the RGB image of the samples after infection with each type of pathogenic bacteria according to the RGB image of the samples after infection with each type of pathogenic bacteria according The system includes: a feature band corresponding to the metabolites after long-term processing; a feature band weighting module, used to weight feature bands based on deep learning networks and reconstructed full-band hyperspectral data; a feature spectrum extraction module, used to extract the feature spectral data corresponding to the weighted feature bands from the reconstructed full-band hyperspectral data to obtain feature spectra; and a model training module, used to train a classification task based on the meat type, the type of pathogen infecting various meat samples, the duration of infection with each type of pathogen in various meat samples, and the corresponding feature spectra at each duration, to obtain a pathogen classification model.
[0184] Optionally, the characteristic band determination module is specifically used for: for each type of pathogen, using resampling technology on the reconstructed full-band hyperspectral data to generate multiple modeling subsets; constructing a partial least squares regression model for each modeling subset to determine the absolute value of the regression coefficients and the pathogenic spectral difference index for each wavelength in the reconstructed full-band hyperspectral data; and selecting the characteristic bands of pathogenic metabolites according to the absolute value of the regression coefficients and the pathogenic spectral difference index during each iteration.
[0185] Optionally, the feature band weighting module is specifically used to: input the reconstructed full-band hyperspectral data and extracted feature bands of various meat samples into a deep learning network, and output weighted feature bands through multi-window feature extraction, fusion and weight adjustment.
[0186] Optionally, the deep learning network is a Swin transformer model; the feature band weighting module is specifically used to: divide the reconstructed full-band hyperspectral data of various meat samples into multiple windows using the Swin transformer model, and extract the feature bands of each sub-band range; adjust the weights of the feature bands in each sub-band range based on the band-pathogenic bacteria absorption peak correlation using the attention mechanism in the Swin transformer model; and fuse the spectral features of each sub-band range after weight adjustment using the Swin transformer model to output the weighted feature bands of various meat samples.
[0187] Optionally, the model training module is specifically used for: extracting shallow representation features of RGB images from samples of various meat products infected with different pathogens for different durations using the self-attention mechanism in the multi-scale transformer network MST++; upgrading the shallow features of RGB images to deep abstract features of RGB images through the multi-layer network of the stacked neural network module SNNM in MST++; determining the band association between the three wide bands (R, G, B) of each RGB image and the 256 narrow bands of the corresponding hyperspectral data based on the deep abstract features of RGB images using the spectral dimension attention mechanism in MST++; expanding the wide channel features (R, G, B) of each RGB image into 256 narrow channel features based on the decoder and band association in MST++ to generate initial hyperspectral data; and iteratively obtaining the trained RGB-hyperspectral data reconstruction model based on the multi-scale transformer network MST++ by minimizing the deviation between the initial hyperspectral data and the original hyperspectral data based on the initial hyperspectral data and the MARE loss function.
[0188] In this embodiment of the invention, firstly, the RGB image of the sample to be tested can be directly acquired during the detection stage. Then, the RGB image is input into the RGB-hyperspectral data reconstruction model to obtain reconstructed full-band hyperspectral data. This eliminates the need to capture hyperspectral images for each test. A feature band selection algorithm can be used to extract feature bands based on the reconstructed hyperspectral data. Based on the spectral features corresponding to the feature bands and a pre-trained pathogen classification model, pathogen species can be identified. This enables rapid, non-destructive, and high-precision detection of pathogen species in meat products. This method eliminates the need for destructive sampling, shortening the detection cycle from 3-7 days using traditional culture methods to within 30 minutes. It can recover key spectral feature information of pathogens from RGB images, avoiding the loss of key spectral feature information, and can improve the overall identification accuracy to over 92%, meeting the needs of rapid on-site quality inspection in the food industry.
[0189] In one embodiment, a computer device is provided, comprising: a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement any step in the above method for detecting pathogenic bacteria species in meat products.
[0190] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, can perform any step of the above-described method for detecting pathogenic bacteria in meat products.
[0191] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0192] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0193] The foregoing has described specific embodiments of the invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0194] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0195] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
[0196] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for detecting pathogenic bacteria in meat products, characterized in that, The method includes: Based on the RGB red-green-blue images of the test samples of the target type of meat products and a pre-trained RGB-hyperspectral data reconstruction model, the full-band hyperspectral data of the test samples is reconstructed; the RGB-hyperspectral data reconstruction model includes the mapping relationship between RGB images and full-band hyperspectral data of various types of meat products after being infected with different pathogens for different durations; The reconstructed full-band hyperspectral data of the sample to be tested are preprocessed; A feature band selection algorithm is used to determine the feature bands of the sample to be tested based on the preprocessed full-band hyperspectral data. Extract the characteristic spectra corresponding to the characteristic bands from the preprocessed full-band hyperspectral data; The meat type and characteristic spectrum of the sample to be tested are input into a pre-trained pathogen classification model, and the pathogen classification results of the sample to be tested are output. The pre-trained pathogen classification model indicates the spectral characteristics of the metabolites of various meat products after infection with various pathogens for various durations, as well as the spectral characteristics of the control group of various meat products after infection with pathogens for various durations. The pathogen spectral characteristics stored in the pathogen classification model are the spectral characteristics corresponding to the weighted feature bands.
2. The method as described in claim 1, characterized in that, The output of the pathogen classification results of the sample to be tested includes: If the characteristic spectrum of the sample to be tested matches the spectral characteristics of the target type of meat product after being infected with the first pathogenic bacterium for a first time, then the result is output that the target type of meat product is infected with the first pathogenic bacterium and the infection time is the first time. If the characteristic spectrum of the sample to be tested does not match any of the spectral features corresponding to the target type of meat in the pathogen classification model, then the sample to be tested of the target type of meat is output as infected with an unknown type of pathogen.
3. The method as described in claim 1, characterized in that, Before reconstructing the full-band hyperspectral data of the sample to be tested, the method further includes: Based on the hyperspectral sorting instrument, samples of various meat products were scanned after being infected with different pathogens for various durations. The scanned data were corrected for black and white, and the average spectrum of the region of interest was extracted to obtain the full-band hyperspectral data of each sample. At the same time, RGB images of samples of various meat products after being infected with different pathogens for various durations were acquired using a camera. Based on the full-band hyperspectral data and RGB images of samples of various meat products after being infected with different pathogens for various durations, an RGB-hyperspectral data reconstruction model was constructed.
4. The method as described in claim 3, characterized in that, After constructing the RGB-hyperspectral data reconstruction model, the method further includes: Based on the RGB-hyperspectral data reconstruction model, the full-band hyperspectral data of the metabolite samples of various meat products after infection with each type of pathogen at various time periods are reconstructed according to the RGB images of the samples after infection with each type of pathogen at various time periods. A feature band selection algorithm was used to determine the feature bands corresponding to the metabolites of various meat products after infection with each type of pathogen at different time periods from the reconstructed full-band hyperspectral data. Weighted feature bands based on deep learning networks and reconstructed full-band hyperspectral data; From the reconstructed full-band hyperspectral data, the characteristic spectral data corresponding to the weighted characteristic bands are extracted to obtain the characteristic spectra; Based on the meat type, the type of pathogen infecting various meat samples, the duration of infection of each type of pathogen in various meat samples, and the corresponding feature spectrum of each duration, a classification task is trained to obtain a pathogen classification model.
5. The method as described in claim 4, characterized in that, The feature band selection algorithm is used to determine the corresponding feature bands from the reconstructed full-band hyperspectral data, including: For each type of pathogen, resampling technology is used on the reconstructed full-band hyperspectral data to generate multiple modeling subsets; Partial least squares regression models were constructed for each modeling subset to determine the absolute values of regression coefficients for each wavelength and the spectral difference index of pathogens in the reconstructed full-band hyperspectral data. In each iteration, characteristic bands of pathogenic bacteria metabolites are selected based on the absolute value of the regression coefficient and the spectral difference index of pathogenic bacteria.
6. The method as described in claim 3, characterized in that, The weighted characteristic bands include: The reconstructed full-band hyperspectral data and extracted feature bands of the various meat samples are input into a deep learning network. Through multi-window feature extraction, fusion and weight adjustment, a weighted feature band is output.
7. The method as described in claim 6, characterized in that, The deep learning network is a window attention mechanism Swintransformer model; the output of weighted feature bands through multi-window feature extraction, fusion, and weight adjustment includes: The reconstructed full-band hyperspectral data of various meat samples were divided into multiple windows using the Swin transformer model, and the characteristic bands of each sub-band range were extracted. By using the attention mechanism in the Swin transformer model, the weights of the characteristic bands within each sub-band range are adjusted based on the correlation between the band and the pathogenic bacteria absorption peak. The weighted feature bands of the various meat samples are output by fusing the spectral features of each sub-band range with weighted adjustments using the Swin transformer model.
8. The method as described in claim 3, characterized in that, Based on the hyperspectral data and RGB images of various meat products infected with different pathogens for different durations, an RGB-hyperspectral data reconstruction model was constructed, including: For RGB images of various meat products after infection with different pathogens for different durations, the self-attention mechanism in the MST++ multi-scale transformer network is used to extract shallow appearance features of the RGB images. The shallow features of the RGB image are upgraded to deep abstract features of the RGB image through the multi-layer network of the stacked neural network module SNNM in MST++. The spectral dimension attention mechanism in MST++ is used to determine the band association between the three wide bands (R, G, B) of each RGB image and the 256 narrow bands of the corresponding hyperspectral data based on the deep abstract features of the RGB image. Based on the relationship between the decoder and the band in MST++, the wide channel features of R, G, and B in each RGB image are expanded into 256 narrow channel features to generate initial hyperspectral data. Based on the initial hyperspectral data and the mean absolute relative error loss function, the trained RGB-hyperspectral data reconstruction model based on MST++ is obtained iteratively by minimizing the deviation between the initial hyperspectral data and the original hyperspectral data.
9. A device for detecting pathogenic bacteria in meat products, characterized in that, The detection device for pathogenic bacteria in meat products includes: a hyperspectral data reconstruction module, a preprocessing module, a characteristic band determination module, a characteristic spectrum extraction module, and a pathogenic bacteria classification module; The hyperspectral data reconstruction module is used to reconstruct the full-band hyperspectral data of the test sample based on the RGB red-green-blue image of the test sample of the target type of meat and a pre-trained RGB-hyperspectral data reconstruction model; the RGB-hyperspectral data reconstruction model includes the mapping relationship between the RGB images and full-band hyperspectral data of various types of meat after infection with different pathogens for different durations; The preprocessing module is used to preprocess the reconstructed full-band hyperspectral data of the sample to be tested. The feature band determination module is used to determine the feature bands of the sample to be tested based on the preprocessed full-band hyperspectral data using a feature band selection algorithm. The feature spectrum extraction module is used to extract the feature spectra corresponding to the feature bands from the preprocessed full-band hyperspectral data; The pathogen classification module is used to input the meat product category and characteristic spectrum of the sample to be tested into a pre-trained pathogen classification model and output the classification result of the pathogen types of the sample to be tested. The pre-trained pathogen classification model indicates the spectral characteristics of the metabolites of various meat products after infection with various pathogens for various durations, as well as the spectral characteristics of the control group of various meat products after infection with pathogens for various durations. The pathogen spectral characteristics stored in the pathogen classification model are the spectral characteristics corresponding to the weighted feature bands.
10. A computer device, characterized in that, include: A memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method for detecting pathogenic bacteria species in meat products according to any one of claims 1-8.