Method and system for rapidly detecting parasites in fresh food

By constructing parasite stress feature maps and edge texture feature maps in a deep learning network, and combining feature compression and weighted fusion techniques, the problems of feature redundancy and low detection efficiency in deep learning networks are solved, enabling rapid and accurate detection of parasites in fresh food.

CN121884338AInactive Publication Date: 2026-04-17JIANGXI INST OF PARASITIC DISEASE CONTROL
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGXI INST OF PARASITIC DISEASE CONTROL
Filing Date
2026-01-12
Publication Date
2026-04-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In existing technologies, deep learning networks struggle to focus on the discriminative information specific to parasites. Redundancy exists in feature maps during propagation in intermediate layers, resulting in a large number of model parameters, making real-time detection difficult. Furthermore, multispectral image data has high dimensionality and severe information redundancy.

Method used

By acquiring multiple spectral channel images of fresh food, parasite stress feature maps and edge texture feature maps are calculated and used as initial feature inputs to a deep neural network model. In the intermediate layer, core feature groups and auxiliary feature groups are divided, and feature compression and weighted fusion are performed to generate fused feature vectors for classification.

Benefits of technology

It improves the efficiency and reliability of parasite detection, ensuring detection speed while enhancing the accuracy and reliability of parasite detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121884338A_ABST
    Figure CN121884338A_ABST
Patent Text Reader

Abstract

The invention provides a rapid detection method and system for parasites in fresh food, and the method comprises the steps: collecting a multispectral image of the fresh food, selecting near-infrared and green light channels, calculating a normalized differential value, generating a parasite stress feature map, and calculating the global variance of the feature map; edge texture features are extracted through a Laplacian operator, and the original spectrogram and the two feature maps are stacked and input into a deep network; the network intermediate layer divides the features into a core group and an auxiliary group, the core group generates a channel vector, and the auxiliary group performs discrete cosine transform compression according to global variance; splicing the compression feature and the core feature to obtain a depth feature vector; meanwhile, carrying out weighted fusion on the multispectral image by utilizing a channel vector, calculating a gradient covariance matrix and flattening the gradient covariance matrix to obtain a spectral statistical vector; and splicing the depth features and the spectral statistical vectors, outputting a detection score through a classifier, and comparing the detection score with a threshold value to obtain a detection conclusion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of rapid detection, and in particular relates to a method and system for rapid detection of parasites in fresh food. Background Technology

[0002] Existing parasite detection methods, such as visual inspection, microscopic examination, slide preparation, or digestion, are labor-intensive, inefficient, and require highly experienced personnel. Furthermore, while biochemical detection methods offer high sensitivity and specificity, they are time-consuming, costly, and typically destructive, making them unsuitable for large-scale, rapid on-site screening in production, processing, and market distribution. Therefore, a rapid, non-destructive parasite detection technology suitable for portable devices is needed.

[0003] Multispectral or hyperspectral techniques, by acquiring image information of objects in different spectral bands, can uncover subtle differences that are difficult for the human eye to discern. Combining the acquired multispectral images with deep learning models, a convolutional neural network model is constructed to extract features and perform classification. However, multispectral image data has high dimensionality and information redundancy between channels. Directly using it as input to a deep learning model results in a large number of model parameters, making real-time detection difficult. Furthermore, general-purpose deep learning networks may not be able to focus on parasite-specific stress responses and texture discrimination information during feature extraction, and may easily overlook global image characteristics. In addition, feature maps generated during network propagation in intermediate layers also contain redundancy. How to compress and utilize these features to improve model efficiency is a pressing problem that needs to be solved. Summary of the Invention

[0004] This invention proposes a rapid detection method for parasites in fresh food, addressing the problems of deep learning networks failing to focus on parasite-specific discriminative information and the redundancy of feature maps generated during network propagation in intermediate layers. The method includes: Multiple spectral channel images of the fresh food to be tested are acquired; the normalized difference value of the first near-infrared channel and the green channel is selected to generate a parasite stress feature map, and the global variance of the stress feature map is calculated; the Laplacian operator is performed on the stress feature map to obtain an edge texture feature map; the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map are stacked and used as the initial feature input to a deep neural network model; The deep neural network model performs forward propagation on the initial features, outputting a multi-channel intermediate feature map in the intermediate feature layer; the intermediate feature map is divided into a core feature group and an auxiliary feature group in the channel dimension; the average activation intensity of each channel in the core feature group is calculated to obtain a channel vector; the compression ratio is determined based on the global variance, and a two-dimensional discrete cosine transform is performed on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; the core feature group and the compressed auxiliary feature group are concatenated and propagated through subsequent layers of the network to obtain a deep feature vector; The multiple spectral channel images are weighted and fused using the channel vectors to generate a weighted fused spectrum; the gradient covariance matrix of the weighted fused spectrum is calculated, and the upper triangular elements of the matrix are flattened to obtain a spectral statistical vector; The deep feature vector and the spectral statistical vector are concatenated to generate a fused feature vector; the fused feature vector is input into a classifier, which outputs a detection score representing the probability of parasite presence; the detection score is compared with a preset judgment threshold to obtain a detection conclusion.

[0005] Furthermore, this invention also relates to a rapid detection system for parasites in fresh food, comprising the following modules: The input module is used to acquire multiple spectral channel images of the fresh food to be detected; select the first near-infrared channel and the green light channel to calculate the normalized difference value, generate a parasite stress feature map, and calculate the global variance of the stress feature map; perform Laplacian operator operation on the stress feature map to obtain an edge texture feature map; stack the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map as initial feature input to the deep neural network model; The propagation module is used to perform forward propagation of the initial features in the deep neural network model, outputting a multi-channel intermediate feature map in the intermediate feature layer; dividing the intermediate feature map into a core feature group and an auxiliary feature group in the channel dimension; calculating the average activation intensity of each channel in the core feature group to obtain a channel vector; determining the compression ratio based on the global variance; performing a two-dimensional discrete cosine transform on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; concatenating the core feature group and the compressed auxiliary feature group, and propagating through subsequent layers of the network to obtain a deep feature vector; The flattening module is used to perform weighted fusion of the multiple spectral channel images using the channel vector to generate a weighted fused spectrum; calculate the gradient covariance matrix of the weighted fused spectrum, and flatten the upper triangular elements of the matrix to obtain a spectral statistical vector; The comparison module is used to concatenate the depth feature vector with the spectral statistical vector to generate a fused feature vector; input the fused feature vector into the classifier and output a detection score representing the probability of parasite presence; compare the detection score with a preset judgment threshold to obtain a detection conclusion.

[0006] This invention provides prior information to the deep model by explicitly constructing parasite stress feature maps and edge texture feature maps at the network input, thereby enhancing the detection capability of weak parasite signals. Internally, by dividing the intermediate layer features into core and auxiliary groups and setting a compression rate based on the global variance of the stress feature map, the auxiliary feature group is compressed using discrete cosine transform, improving detection efficiency. Channel information generated within the network guides the weighted fusion of the original spectral image, extracting gradient covariance statistical features. This global statistical information complements the local semantic features extracted by the deep network. The two types of features are fused and classified, thus improving the reliability of parasite detection while maintaining detection speed. Attached Figure Description

[0007] Figure 1 A flowchart of the first embodiment; Figure 2 This is a schematic diagram of feature fusion and classification. Detailed Implementation

[0008] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0009] The term "multiple" in this application refers to two or more. Furthermore, it should be understood that the terms "first," "second," etc., used in the description of this application are used only for descriptive purposes and should not be construed as indicating or implying relative importance, nor as indicating or implying order.

[0010] In the first embodiment, the present invention proposes a rapid detection method for parasites in fresh food, such as... Figure 1 ,include: S1, acquire multiple spectral channel images of the fresh food to be detected; select the first near-infrared channel and the green light channel to calculate the normalized difference value, generate a parasite stress feature map, and calculate the global variance of the stress feature map; perform Laplacian operator operation on the stress feature map to obtain an edge texture feature map; stack the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map as initial feature input to the deep neural network model; A portable multispectral imaging device containing visible and near-infrared filters was used to vertically photograph salmon flesh samples placed in a darkroom environment. Images were acquired from four core spectral channels, including 450 nm blue light, 550 nm green light, 650 nm red light, and 850 nm near-infrared light. Dark current correction and white board reflectivity correction were performed on the acquired raw images to eliminate the effects of noise and uneven illumination, resulting in a set of spatially aligned multispectral image data with a size of 256×256 pixels.

[0011] The first near-infrared channel image at 850 nm is denoted as NIR, and the green channel image at 550 nm is denoted as G. The two images are processed pixel by pixel using the formula NDSI=(NIR-G) / (NIR+G) to generate a single-channel parasite stress feature map. In this map, the parasite-infected area exhibits a different gray value from the surrounding normal tissue due to changes in tissue structure and water content. The variance of all pixel values ​​in this stress feature map is calculated to obtain a scalar value as the global variance, which is used to represent the overall texture complexity of the image and the degree of abnormal areas.

[0012] In one embodiment, a 3×3 Laplacian convolution kernel, such as a kernel with a center element of 8 and surrounding elements of -1, is used to perform a two-dimensional convolution operation on the parasite stress feature map generated above. This second-order differential operation enhances the high-frequency details in the image, highlights the outline and edges of the parasite body or the tissue lesions caused by the parasite, and generates a single-channel edge texture feature map.

[0013] The original four spectral channel images, the single-channel parasite stress feature map, and the single-channel edge texture feature map are stitched together in the channel dimension to form an input feature tensor with six channels and a spatial size of 256×256. This tensor serves as the unified input to the deep neural network model.

[0014] In an optional embodiment, the step of selecting the first near-infrared channel and the green light channel to calculate the normalized difference value and generate a parasite stress feature map includes: The image of the first near-infrared channel is denoted as... The image of the green channel is denoted as For each pixel (i,j) in the image, the normalized difference ND(i,j) is calculated using the following formula: in To prevent smoothing terms with a denominator of zero, the ND values ​​of all pixels constitute the parasite stress feature map.

[0015] Two spectral images are acquired: one acquired in the first near-infrared band and the other in the green light band. Assume that at a certain pixel location in the image, for example, at coordinates (100, 50), the pixel intensity value of the first near-infrared channel is 180, while the pixel intensity value of the green light channel is 60. These values ​​represent the reflectivity of that point to different wavelengths of light.

[0016] For the pixel (100, 50), the normalized difference formula is applied for calculation. The normalized difference value is approximately 0.5. This process is repeated for each pixel in the image, generating a normalized difference value for each point. The new image composed of the normalized difference values ​​of all pixels is the parasite stress feature map; the numerical changes in the map highlight tissue abnormalities caused by the parasite.

[0017] S2, the deep neural network model performs forward propagation on the initial features, outputting a multi-channel intermediate feature map in the intermediate feature layer; the intermediate feature map is divided into a core feature group and an auxiliary feature group in the channel dimension; the average activation intensity of each channel in the core feature group is calculated to obtain a channel vector; the compression ratio is determined based on the global variance, and a two-dimensional discrete cosine transform is performed on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; the core feature group and the compressed auxiliary feature group are concatenated and propagated through subsequent layers of the network to obtain a deep feature vector; The lightweight MobileNetV2 network is used as the backbone of the deep neural network model. The initial feature tensor of six channels is input into the network. After several initial convolutional layers and inverted residual blocks, a multi-channel intermediate feature map with 64 channels and a spatial size of 32×32 is obtained at the output of the third inverted residual block of the network.

[0018] The intermediate feature map of the 64 channels is divided into two parts along the channel dimension. The feature maps of the first 32 channels are defined as the core feature group, and the feature maps of the last 32 channels are defined as the auxiliary feature group.

[0019] For each channel in the core feature group, i.e. each 32×32 feature map, a global average pooling operation is performed to calculate the average value of the activation values ​​of all pixels in that channel, thereby compressing each two-dimensional feature map into a scalar value, resulting in a one-dimensional vector consisting of 32 elements, i.e., a channel vector, where each element represents the overall importance of the corresponding core channel.

[0020] The previously calculated global variance V is converted into a compression ratio R using a linear mapping function R = 1 - α × V, where α is a preset scaling factor. A two-dimensional discrete cosine transform is performed on each 32 × 32 feature map in the auxiliary feature group to transform the feature map from the spatial domain to the frequency domain. According to the compression ratio R, only the low-frequency coefficients in the upper left corner of the transformed coefficient matrix are retained. For example, if R is 0.75, the 8 × 8 coefficient block in the upper left corner is retained, and all other high-frequency coefficients are set to zero. A two-dimensional inverse discrete cosine transform is performed on the processed coefficient matrix to obtain the compressed feature map in the spatial domain. This process is completed for all channels of the auxiliary feature group to obtain the compressed auxiliary feature group.

[0021] The unprocessed 32-channel core feature set and the compressed 32-channel auxiliary feature set are concatenated along the channel dimension to form a new 64-channel feature map. This concatenated feature map is then input into subsequent layers of the MobileNetV2 network for further feature extraction until the global average pooling layer at the end of the network, which outputs a 1280-dimensional depth feature vector.

[0022] In an optional embodiment, dividing the intermediate feature map into a core feature group and an auxiliary feature group along the channel dimension includes: For the C channels of the intermediate feature map, calculate the arithmetic mean of all activation values ​​in each channel to obtain C average activation intensity values; sort the C channels from high to low according to the average activation intensity values; select the top 30% of the sorted channels as the core feature group and the remaining 70% of the channels as the auxiliary feature group.

[0023] Specifically, suppose the intermediate feature map generated by the deep learning model contains 200 channels, each of which is a two-dimensional activation value matrix. For example, for the first channel, all activation values ​​in the channel matrix are summed and divided by the total number of activation values ​​to obtain an average value, such as 1.25. The same operation is performed on the remaining 199 channels, resulting in a list containing 200 elements, each element representing the average activation intensity of the corresponding channel.

[0024] The channels at the top of the list have high average activation intensity, indicating that activating them during feature extraction may contain crucial information. Following a pre-defined ratio, the first 30% (the first 60 channels) are designated as the core feature group. The remaining 70%, from channels 61 to 200, are designated as the auxiliary feature group.

[0025] In an optional embodiment, the step of determining the compression ratio based on the global variance, performing a two-dimensional discrete cosine transform on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain the compressed auxiliary feature group includes: Compression ratio calculated using the S-shaped function : in For global variance, The preset variance mean, The scaling factor is used; a two-dimensional discrete cosine transform is performed on each M×N channel map in the auxiliary feature group; the top left corner of the transformed coefficient matrix is ​​retained. The low-frequency coefficients are set to zero, and the remaining high-frequency coefficients are set to zero. A two-dimensional discrete cosine inverse transform is performed on the modified coefficient matrix to obtain the compressed feature map of the channel.

[0026] Assuming the global variance calculated from the core feature set is 0.8, the preset mean variance is 0.6, and the scaling factor is 5, the values ​​are substituted into the sigmoid function to calculate the value of k. The value of k reflects the complexity of the current features; the larger the variance, the higher the value of k, and the lower the compression. For example, the calculated value of k is 0.7.

[0027] Taking a 32×32 channel map as an example, a two-dimensional discrete cosine transform is performed on the channel map to obtain a coefficient matrix of the same size, where the energy is mainly concentrated in the low-frequency part in the upper left corner. Based on the calculated compression ratio of 0.7, the size of the coefficient region to be retained is determined to be 22 rows and 22 columns. The low-frequency coefficients in the 22×22 region in the upper left corner of the coefficient matrix are retained, and all high-frequency coefficients outside this region are set to zero. Performing a two-dimensional inverse discrete cosine transform on the modified coefficient matrix yields a compressed channel map with reduced information content but retaining the main features.

[0028] S3, use the channel vector to perform weighted fusion of the multiple spectral channel images to generate a weighted fused spectrum; calculate the gradient covariance matrix of the weighted fused spectrum, and flatten the upper triangular elements of the matrix to obtain the spectral statistical vector; The 32-dimensional channel vector is passed through a fully connected layer to map the vector dimension to 4, which is equal to the number of original spectral channels. Then, it is normalized by a Softmax function to obtain the weight coefficients of the four channels. The four weight coefficients are multiplied pixel by pixel by the original four spectral channel images. The four weighted images are then added together to fuse them into a single-channel weighted fused spectrum.

[0029] The first-order gradient maps of the weighted fused spectrum in the horizontal and vertical directions were calculated using the Sobel operator. and Take the horizontal gradient values ​​of all pixels as one set and the vertical gradient values ​​as another set. Calculate the covariance of these two sets, as well as their respective variances, to form a 2×2 gradient covariance matrix. Then, take the three upper triangular elements of this matrix... variance variance and The covariances are arranged in a fixed order to form a 3-dimensional spectral statistical vector.

[0030] In an optional embodiment, the step of weighted fusion of the multiple spectral channel images using the channel vectors to generate a weighted fused spectrum includes: The channel vectors are subjected to Softmax normalization to obtain the fusion weights corresponding to the multiple spectral channel images. Let the multiple spectral channel images be ,in If the channel index is used, then the weighted fused spectrum is obtained. The value at pixel (i,j) is calculated using the following formula: .

[0031] Specifically, suppose there are 5 original spectral channel images, and the neural network generates a vector for these 5 channels with original values ​​[1.5, 0.2, 2.8, 0.9, 1.1]. The vector is then normalized using the Softmax function. This process converts the original values ​​into a set of weights that sum to 1, for example, potentially resulting in [0.17, 0.04, 0.45, 0.12, 0.22]. The channel with the highest original value of 2.8 receives the largest weight of 0.45, indicating that this channel is important for the detection task.

[0032] Taking pixel (200, 300) in the image as an example, read the pixel values ​​of this point in the five original spectral channels, assuming they are 110, 150, 90, 130, and 120 respectively. Multiply each pixel value by the channel weight corresponding to that pixel value and then sum the results. The calculated result is the new pixel value at pixel (200, 300) in the weighted fused spectral image. This operation is repeated for all pixels in the image to generate a single-channel fused image.

[0033] In an optional embodiment, calculating the gradient covariance matrix of the weighted fused spectrum and flattening the upper triangular elements of the matrix to obtain a spectral statistical vector includes: The gradient maps of the weighted fused spectrum in the horizontal and vertical directions were calculated using the Sobel operator. and For each pixel in the image, construct a 3D vector. ; Calculate the 3D vector of all pixels of covariance matrix Extract the six elements from the diagonal and upper triangular portions of the covariance matrix. And in this order, they are flattened into one-dimensional spectral statistical vectors.

[0034] Specifically, the Sobel operator is applied to the weighted fused spectral map generated above to calculate the gradients of the spectral map in the horizontal and vertical directions, respectively, resulting in two new gradient maps. The gradient map reflects the rate of change of pixel intensity in the image, i.e., texture information. For each pixel in the image, a vector containing three values ​​is constructed: the first value is the original intensity value of the pixel in the weighted fused map, the second is the value of the pixel in the horizontal gradient map, and the third is the value of the pixel in the vertical gradient map. If the image size is 1000×1000, one million three-dimensional vectors are obtained. The 3×3 covariance matrix of the one million three-dimensional vectors is calculated. The diagonal elements of this matrix represent the variance of each of the three components, and the off-diagonal elements represent the covariance between different components, which together represent the overall statistical texture characteristics of the image. Since the covariance matrix is ​​symmetric, only six independent elements of the diagonal and upper triangular parts of the matrix need to be extracted and arranged into a one-dimensional vector, such as [C11,C12,C13,C22,C23,C33], which is the spectral statistical vector.

[0035] S4, the depth feature vector and the spectral statistical vector are concatenated to generate a fused feature vector; the fused feature vector is input into a classifier, which outputs a detection score representing the probability of parasite presence; the detection score is compared with a preset judgment threshold to obtain a detection conclusion.

[0036] The 1280-dimensional depth feature vector is concatenated with the 3-dimensional spectral statistical vector to form a 1283-dimensional fused feature vector, which contains both deep semantic information and global statistical texture information.

[0037] The 1283-dimensional fused feature vector is input into a multilayer perceptron classifier consisting of two fully connected layers. The last layer of the classifier uses the sigmoid activation function and outputs a single value between 0 and 1. This value is the detection score, which represents the probability that a parasite is present in the sample.

[0038] The output detection score is compared with a preset judgment threshold obtained by optimization on the validation set. If the score is greater than the preset judgment threshold, it is determined that there are parasites in the fresh food. If the score is less than or equal to the preset judgment threshold, it is determined that there are no parasites, thus completing the entire detection process.

[0039] In an optional embodiment, the step of inputting the fused feature vector into a classifier and outputting a detection score representing the probability of parasite presence includes: The fused feature vector is input into a multilayer perceptron classifier containing two hidden layers; the first hidden layer contains 256 neurons and the second hidden layer contains 128 neurons, both using the ReLU activation function; the output layer is a neuron using the Sigmoid activation function, which outputs a real value between 0 and 1 as a probability score of the presence of parasites.

[0040] The deep feature vector and spectral statistical vector obtained above are concatenated to obtain a longer fused feature vector, which serves as the input to the multilayer perceptron classifier. After input, this vector enters the first hidden layer containing 256 neurons. In this layer, each element of the input vector is multiplied by the neuron's weight, summed, and then a bias term is added before processing by the ReLU activation function. The ReLU function retains positive values ​​and converts negative values ​​to zero.

[0041] The 256 output values ​​from the first hidden layer are fed into a second hidden layer containing 128 neurons, and a similar process of weighted summation and ReLU activation is repeated. The 128 output values ​​from the second hidden layer are then passed to an output layer with only one neuron. This output neuron uses the sigmoid activation function, which maps the received input values ​​to a value between 0 and 1. The output value, for example, 0.91, is interpreted as a probability score indicating the presence of a parasite in the sample. Figure 2 .

[0042] In an optional embodiment, the step of comparing the detection score with a preset judgment threshold to obtain a detection conclusion includes: If the detection score output by the classifier is greater than the judgment threshold, it is determined that there are parasites in the fresh food to be tested; if the detection score is less than or equal to the judgment threshold, it is determined that there are no parasites in the fresh food to be tested.

[0043] Specifically, a fixed judgment threshold is preset, for example, 0.75. This value is obtained through extensive data testing during the development phase to balance detection accuracy and false negative rate. After a fresh food sample to be tested goes through the entire analysis process, the classifier outputs a detection score between 0 and 1. Assume the detection score for a salmon sample is 0.82. This score of 0.82 is compared with the preset threshold of 0.75. Because 0.82 is greater than 0.75, the salmon sample is determined to contain parasites, and a positive detection result is output. If the score for another cod sample is 0.45, since 0.45 is less than or equal to 0.75, the sample is determined to be free of parasites, and a negative detection result is output.

[0044] In a second embodiment, the present invention also proposes a rapid detection system for parasites in fresh food, comprising the following modules: The input module is used to acquire multiple spectral channel images of the fresh food to be detected; select the first near-infrared channel and the green light channel to calculate the normalized difference value, generate a parasite stress feature map, and calculate the global variance of the stress feature map; perform Laplacian operator operation on the stress feature map to obtain an edge texture feature map; stack the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map as initial feature input to the deep neural network model; The propagation module is used to perform forward propagation of the initial features in the deep neural network model, outputting a multi-channel intermediate feature map in the intermediate feature layer; dividing the intermediate feature map into a core feature group and an auxiliary feature group in the channel dimension; calculating the average activation intensity of each channel in the core feature group to obtain a channel vector; determining the compression ratio based on the global variance; performing a two-dimensional discrete cosine transform on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; concatenating the core feature group and the compressed auxiliary feature group, and propagating through subsequent layers of the network to obtain a deep feature vector; The flattening module is used to perform weighted fusion of the multiple spectral channel images using the channel vector to generate a weighted fused spectrum; calculate the gradient covariance matrix of the weighted fused spectrum, and flatten the upper triangular elements of the matrix to obtain a spectral statistical vector; The comparison module is used to concatenate the depth feature vector with the spectral statistical vector to generate a fused feature vector; input the fused feature vector into the classifier and output a detection score representing the probability of parasite presence; compare the detection score with a preset judgment threshold to obtain a detection conclusion.

[0045] In an optional embodiment, the step of selecting the first near-infrared channel and the green light channel to calculate the normalized difference value and generate a parasite stress feature map includes: The image of the first near-infrared channel is denoted as... The image of the green channel is denoted as For each pixel (i,j) in the image, the normalized difference ND(i,j) is calculated using the following formula: . in To prevent smoothing terms with a denominator of zero, the ND values ​​of all pixels constitute the parasite stress feature map.

[0046] In an optional embodiment, dividing the intermediate feature map into a core feature group and an auxiliary feature group along the channel dimension includes: For the C channels of the intermediate feature map, calculate the arithmetic mean of all activation values ​​in each channel to obtain C average activation intensity values; sort the C channels from high to low according to the average activation intensity values; select the first 30% of the sorted channels as the core feature group and the remaining 70% of the channels as the auxiliary feature group.

[0047] In an optional embodiment, the step of determining the compression ratio based on the global variance, performing a two-dimensional discrete cosine transform on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain the compressed auxiliary feature group includes: Compression ratio calculated using the S-shaped function : in For global variance, The preset variance mean, The scaling factor is used; a two-dimensional discrete cosine transform is performed on each M×N channel map in the auxiliary feature group; the top left corner of the transformed coefficient matrix is ​​retained. The low-frequency coefficients are set to zero, and the remaining high-frequency coefficients are set to zero. A two-dimensional discrete cosine inverse transform is performed on the modified coefficient matrix to obtain the compressed feature map of the channel.

[0048] In an optional embodiment, the step of weighted fusion of the multiple spectral channel images using the channel vectors to generate a weighted fused spectrum includes: The channel vectors are subjected to Softmax normalization to obtain the fusion weights corresponding to the multiple spectral channel images. Let the multiple spectral channel images be ,in If the channel index is used, then the weighted fused spectrum is obtained. The value at pixel (i,j) is calculated using the following formula: .

[0049] In an optional embodiment, the step of calculating the gradient covariance matrix of the weighted fused spectrum and flattening the upper triangular elements of the matrix to obtain a spectral statistical vector includes: The gradient maps of the weighted fused spectrum in the horizontal and vertical directions were calculated using the Sobel operator. and For each pixel in the image, construct a 3D vector. ; Calculate the 3D vector of all pixels of covariance matrix Extract the six elements from the diagonal and upper triangular portions of the covariance matrix. And in this order, they are flattened into one-dimensional spectral statistical vectors.

[0050] In an optional embodiment, the step of inputting the fused feature vector into a classifier and outputting a detection score representing the probability of parasite presence includes: The fused feature vector is input into a multilayer perceptron classifier containing two hidden layers; the first hidden layer contains 256 neurons and the second hidden layer contains 128 neurons, both using the ReLU activation function; the output layer is a neuron using the Sigmoid activation function, which outputs a real value between 0 and 1 as a probability score of the presence of parasites.

[0051] In an optional embodiment, comparing the detection score with a preset judgment threshold to obtain a detection conclusion includes: If the detection score output by the classifier is greater than the judgment threshold, it is determined that there are parasites in the fresh food to be tested; if the detection score is less than or equal to the judgment threshold, it is determined that there are no parasites in the fresh food to be tested.

[0052] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.

[0053] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0054] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A method for rapid detection of parasites in raw food products, characterized in that, Includes the following steps: Multiple spectral channel images of the fresh food to be tested are acquired; the normalized difference value of the first near-infrared channel and the green channel is selected to generate a parasite stress feature map, and the global variance of the stress feature map is calculated; the Laplacian operator is performed on the stress feature map to obtain an edge texture feature map; the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map are stacked and used as the initial feature input to a deep neural network model; The deep neural network model performs forward propagation on the initial features, outputting a multi-channel intermediate feature map in the intermediate feature layer; the intermediate feature map is divided into a core feature group and an auxiliary feature group in the channel dimension; the average activation intensity of each channel in the core feature group is calculated to obtain a channel vector; the compression ratio is determined based on the global variance, and a two-dimensional discrete cosine transform is performed on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; the core feature group and the compressed auxiliary feature group are concatenated and propagated through subsequent layers of the network to obtain a deep feature vector; The multiple spectral channel images are weighted and fused using the channel vectors to generate a weighted fused spectrum; the gradient covariance matrix of the weighted fused spectrum is calculated, and the upper triangular elements of the matrix are flattened to obtain a spectral statistical vector; The deep feature vector and the spectral statistical vector are concatenated to generate a fused feature vector; the fused feature vector is input into a classifier, which outputs a detection score representing the probability of parasite presence; the detection score is compared with a preset judgment threshold to obtain a detection conclusion.

2. The method according to claim 1, characterized in that, The step of selecting the first near-infrared channel and the green light channel to calculate the normalized difference value and generate a parasite stress characteristic map includes: The image of the first near-infrared channel is denoted as... The image of the green channel is denoted as For each pixel (i,j) in the image, the normalized difference ND(i,j) is calculated using the following formula: in To prevent smoothing terms with a denominator of zero, the ND values ​​of all pixels constitute the parasite stress feature map.

3. The method according to claim 1, characterized in that, The step of dividing the intermediate feature map into a core feature group and an auxiliary feature group along the channel dimension includes: For the C channels of the intermediate feature map, calculate the arithmetic mean of all activation values ​​in each channel to obtain C average activation intensity values; sort the C channels from high to low according to the average activation intensity values; select the top 30% of the sorted channels as the core feature group and the remaining 70% of the channels as the auxiliary feature group.

4. The method according to claim 1, characterized in that, The compression ratio is determined based on the global variance, and a two-dimensional discrete cosine transform is performed on each channel of the auxiliary feature group. Some low-frequency coefficients are retained and an inverse transform is performed to obtain the compressed auxiliary feature group, including: Compression ratio calculated using the S-shaped function : in For global variance, The preset variance mean, The scaling factor is used; a two-dimensional discrete cosine transform is performed on each M×N channel map in the auxiliary feature group; the top left corner of the transformed coefficient matrix is ​​retained. The low-frequency coefficients are set to zero, and the remaining high-frequency coefficients are set to zero. A two-dimensional discrete cosine inverse transform is performed on the modified coefficient matrix to obtain the compressed feature map of the channel.

5. The method according to claim 1, characterized in that, The step of weighted fusing the multiple spectral channel images using the channel vectors to generate a weighted fused spectral map includes: The channel vectors are subjected to Softmax normalization to obtain the fusion weights corresponding to the multiple spectral channel images. Let the multiple spectral channel images be ,in If the channel index is used, then the weighted fused spectrum is obtained. The value at pixel (i,j) is calculated using the following formula: .

6. The method according to claim 1, characterized in that, The calculation of the gradient covariance matrix of the weighted fused spectrum, and the flattening of the upper triangular elements of the matrix to obtain the spectral statistical vector, includes: The gradient maps of the weighted fused spectrum in the horizontal and vertical directions were calculated using the Sobel operator. and For each pixel in the image, construct a 3D vector. ; Calculate the 3D vector of all pixels of covariance matrix Extract the six elements from the diagonal and upper triangular portions of the covariance matrix. And in this order, they are flattened into one-dimensional spectral statistical vectors.

7. The method according to claim 1, characterized in that, The step of inputting the fused feature vector into a classifier and outputting a detection score representing the probability of parasite presence includes: The fused feature vector is input into a multilayer perceptron classifier containing two hidden layers; the first hidden layer contains 256 neurons and the second hidden layer contains 128 neurons, both using the ReLU activation function; the output layer is a neuron using the Sigmoid activation function, which outputs a real value between 0 and 1 as a probability score of the presence of parasites.

8. The method according to claim 1, characterized in that, The step of comparing the detection score with a preset judgment threshold to obtain a detection conclusion includes: If the detection score output by the classifier is greater than the judgment threshold, it is determined that there are parasites in the fresh food to be tested; if the detection score is less than or equal to the judgment threshold, it is determined that there are no parasites in the fresh food to be tested.

9. A rapid detection system for parasites in fresh food, characterized in that, Includes the following modules: The input module is used to acquire multiple spectral channel images of the fresh food to be detected; select the first near-infrared channel and the green light channel to calculate the normalized difference value, generate a parasite stress feature map, and calculate the global variance of the stress feature map; perform Laplacian operator operation on the stress feature map to obtain an edge texture feature map; stack the multiple spectral channel images, the parasite stress feature map, and the edge texture feature map as initial feature input to the deep neural network model; The propagation module is used to perform forward propagation of the initial features in the deep neural network model, outputting a multi-channel intermediate feature map in the intermediate feature layer; dividing the intermediate feature map into a core feature group and an auxiliary feature group in the channel dimension; calculating the average activation intensity of each channel in the core feature group to obtain a channel vector; determining the compression ratio based on the global variance; performing a two-dimensional discrete cosine transform on each channel of the auxiliary feature group, retaining some low-frequency coefficients and performing an inverse transform to obtain a compressed auxiliary feature group; concatenating the core feature group and the compressed auxiliary feature group, and propagating through subsequent layers of the network to obtain a deep feature vector; The flattening module is used to perform weighted fusion of the multiple spectral channel images using the channel vector to generate a weighted fused spectrum; calculate the gradient covariance matrix of the weighted fused spectrum, and flatten the upper triangular elements of the matrix to obtain a spectral statistical vector; The comparison module is used to concatenate the depth feature vector with the spectral statistical vector to generate a fused feature vector; input the fused feature vector into the classifier and output a detection score representing the probability of parasite presence; compare the detection score with a preset judgment threshold to obtain a detection conclusion.

10. The system according to claim 9, characterized in that, The step of selecting the first near-infrared channel and the green light channel to calculate the normalized difference value and generate a parasite stress characteristic map includes: The image of the first near-infrared channel is denoted as... The image of the green channel is denoted as For each pixel (i,j) in the image, the normalized difference ND(i,j) is calculated using the following formula: in To prevent smoothing terms with a denominator of zero, the ND values ​​of all pixels constitute the parasite stress feature map.