Microscopic vision detection method for mixing animal-derived adulterated raw materials into fish meal
By constructing the Fishmeal-Mask2Former model, the fishmeal microscope image was pixel-level segmented to identify the adulterated areas and adulterated types, solving the problem of difficulty in accurately detecting adulterated raw materials in fishmeal in the prior art, and achieving efficient and accurate adulterated detection effects.
Patent Information
- Application Number
- CN202510264041.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-06-06
AI Technical Summary
It is difficult to accurately detect animal-derived adulterated raw materials incorporated into fish meal, especially for slightly adulterated or specially treated adulterated fish meal.
Using microscopic vision detection method, the Fishmeal-Mask2Former model was constructed, combined with pixel-level module, Transformer module and segmentation prediction module, the fishmeal microscope image was pixel-level segmented to identify adulterated areas and adulterated types.
It realizes the precise positioning and identification of adulterated raw materials in fish meal, improves the accuracy and efficiency of detection, can more detailedly analyze the microstructure of fish meal, and provides intuitive, accurate and efficient microscopic visual automation recognition methods.
Smart Images

Figure CN120107958A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of feed raw material evaluation, and more particularly to a microscopic visual detection method for adulterating fish meal with animal-derived adulterated raw materials. Background Art
[0002] As a high-quality protein feed raw material, fish meal is rich in essential amino acids, minerals, vitamins and other nutrients. It is widely used in aquaculture, livestock and poultry farming and other fields. It has high protein content and balanced amino acid composition. It can significantly improve the growth performance and immunity of animals. It is an indispensable and important part of the feed industry.
[0003] However, with the continuous growth of market demand for fish meal and the continuous rise in prices, some unscrupulous merchants have been adding animal-derived adulterated raw materials into fish meal in order to make huge profits. Common adulterated raw materials include meat and bone meal, feather meal, leather meal, etc. These adulteration behaviors not only reduce the quality and nutritional value of fish meal, but also may cause potential harm to animal health, such as slow growth and decreased immunity of animals, thereby affecting the economic benefits and food safety of the entire breeding industry. Therefore, it is very important to fully explore the characteristic information in fish meal microscopic images to realize the automated detection of fish meal adulteration.
[0004] At present, the methods for detecting fish meal adulteration mainly include sensory detection, chemical analysis and microscopic detection, all of which have the following limitations:
[0005] Sensory testing method: mainly relies on the experience of the testers to judge whether there is adulteration by observing the appearance characteristics of fish meal such as color, smell, texture, etc. This method is simple and easy to use, but it is highly subjective and requires high experience of the testers. It can only detect some obvious adulteration. It is often difficult to accurately judge slightly adulterated or adulterated fish meal that has been specially treated;
[0006] Chemical analysis method: Adulteration is detected by analyzing the chemical composition of fish meal, such as protein content, amino acid composition, ash content and other indicators. Although the chemical analysis method can provide relatively accurate test results, the detection process is complicated and requires professional instruments and technicians. The detection cycle is long and the cost is high, which is not suitable for large-scale rapid detection.
[0007] Microscope inspection: Observe the microstructure of fish meal under a microscope and identify the characteristics of cells and tissues to determine whether there is adulteration. This method is intuitive and accurate, but it requires high professional knowledge and skills of the inspectors. The test results are easily affected by subjective factors, especially for some animal-derived adulterated raw materials with similar morphology, which are difficult to distinguish accurately.
[0008] In view of the above situation, the present invention provides a microscopic visual detection method for adulterating fish meal with animal-derived raw materials. Summary of the invention
[0009] In order to overcome the above-mentioned defects of the prior art, the present invention provides a microscopic visual detection method for adulterated raw materials of animal origin in fish meal, so as to solve the problems raised in the above-mentioned background technology.
[0010] To achieve the above object, the present invention provides the following technical solution: a microscopic visual detection method for adulterating fish meal with animal-derived raw materials, which specifically comprises the following steps:
[0011] S1. Dataset construction: Fishmeal adulteration identification microscopic image dataset was constructed using MySQL database, including multi-dimensional attribute data of sample source, component composition, pre-processing method, image metadata, and microscopic image acquisition parameters. DSpace was used to select server local storage.
[0012] The dataset is randomly divided into a training set and a test set in a ratio of 7:3, and the training set is subjected to image enhancement processing such as mirroring, random rotation, random scaling, random cropping, and random photometric transformation.
[0013] S2. Sample pretreatment and image acquisition: formulate sample pretreatment screening process and image acquisition conditions, construct fish meal microscopic image datasets of 40-mesh sieve oversize and 60-mesh sieve oversize in the range of 30× to 50×, and subdivide non-fish animal-derived adulteration characteristics into five types of abnormal muscle, bone, skin, blood and hair through morphological analysis;
[0014] S3, model construction and training, build the Fishmeal-Mask2Former model of the improved Masked-attention Mask Transformer (Mask2Former) architecture. The model specifically includes a pixel-level module, a Transformer module, and a segmentation prediction module.
[0015] The pixel-level module adopts the MaskFomer mask classification architecture, the pixel decoder uses a lightweight pixel decoder based on the feature pyramid network FPN, and the backbone network uses ResNet50 to obtain the basic structure and features of the image through convolution operations;
[0016] The Transformer module uses a standard encoder to process the input features extracted by the backbone network, and expands the self-attention mechanism to a multi-head attention mechanism to capture different feature relationships. It uses an integrated masked attention mechanism (MaskedAttention) and multi-scale feature fusion technology to improve the Transformer decoder, and improves the model's detail expression by limiting the cross-attention range. It introduces learnable scale-level embedding, which allows the model to dynamically adjust the feature scale according to the resolution of different feature maps, automatically learn and optimize feature representation during training.
[0017] Introducing the Masked Attention operator, the l-th layer decoder receives the query feature Q 1 =f Q (X l-1 )∈R N×C and the mask matrix Performs modulated attention computation. Using the mask matrix Limiting attention to local features centered on the predicted fragment allows the model to focus on accurate contour extraction and pixel-level segmentation within the proposed region; query feature X 0 It is zero-initialized before being fed into the Transformer decoder and associated with a learnable position embedding. l-1 is the attention mask expression at feature location (x, y), which is output by the binary mask predictions of the first (l-1) Transformer decoder layers (threshold is 0.5), adjusted to be consistent with K l The same resolution. Since the query features passed to the first layer of self-attention are irrelevant to the image and have no signal from the image, Directly from X before the query feature is fed into the Transformer decoder 0 The binary mask prediction is obtained at . The modulated attention matrix is calculated as:
[0018]
[0019] The output of the decoder is connected to a multilayer perceptron (MLP), which finally outputs a convolutional layer for generating the probability distribution of each pixel category, expressed as:
[0020] P(x)=softmax(W f MLP(F)
[0021] Where P(x) is the probability distribution of the category of pixel x;
[0022] W f ——The weight of MLP;
[0023] F — features output from the Transformer decoder;
[0024] The segmentation prediction module adopts the two-stage architecture of Mask RCNN, introduces the ROI Align module to achieve pixel-accurate alignment processing for semantic segmentation, and uses mask classification loss and pixel-by-pixel binary mask loss for supervised training. The overall loss function L total The mixed weighted calculation formula is:
[0025] L total =α·L cls +β·L mask =α·λ cls L cls +β·(λ BCE L BCE +λ Dice L Dice )
[0026] Among them, L mask is the mask loss, which is used to measure the overlap between the predicted mask segmentation and the true label, L cls is the classification loss, which is used to measure the difference between the predicted category probability distribution and the true category distribution. α is the classification loss weight parameter, which is set to 0.6. β is the binary mask loss weight parameter, which is set to 0.4. λ is the adjustable weight parameter for different loss items. BCE =5.0,λ Dice =5.0,λ cls Set to 2.0 or 0.1 depending on whether the prediction matches the true label;
[0027] Binary cross entropy loss L BCE The calculation formula is: Among them, P is the prediction result matrix, T is the label matrix, and M is the number of feature map channels;
[0028] Dice loss L Dice The calculation formula is:
[0029] S4. Model application and result presentation: The trained model is deployed on the edge, and a visual recognition system for the microscopic features of adulterated fish meal with high visual distinction is designed to automatically display abnormal areas in the microscopic images of fish meal to be inspected and to identify the types of suspected adulterants.
[0030] Preferably, in step S1, when performing image enhancement processing on the training set, the angle range of random rotation is set to [-90°, 90°], the ratio range of random scaling is set to [0.8, 1.2], and the ratio range of random cropping is set to [0.7, 1].
[0031] Preferably, in step S2, the sample pretreatment screening process includes performing 40-mesh and 60-mesh screening operations on the fish meal sample in sequence, removing the undersize material, and retaining the oversize material for subsequent image acquisition to ensure that the particle size range of the collected samples is consistent, thereby improving the consistency and comparability of image features.
[0032] Preferably, in step S2, the image acquisition conditions include using a microscope with high resolution and good stability, setting the parameters of light source intensity of 50%, exposure time of 100ms, and focal length as constant values, to ensure that all collected microscopic images are consistent in brightness, clarity, etc., to facilitate subsequent model training and feature analysis.
[0033] Preferably, in step S3, the pixel decoder in the pixel-level module generates high-resolution per-pixel embeddings by gradually upsampling low-resolution features, providing a basis for subsequent feature fusion and prediction.
[0034] Preferably, in step S3, in the Transformer module, multiple information subspaces are processed in parallel through a multi-head attention mechanism to enhance the model's ability to capture different types of feature relationships, thereby generating high-resolution features and processing object queries to achieve more accurate mask and category predictions.
[0035] Preferably, in step S3, in the segmentation prediction module, an MLP is used to receive the output from the Transformer module, and the class prediction probability (N class predictions) and the corresponding mask embedding vector (N mask embeddings) of each pixel are generated in parallel;
[0036] The mask embedding vector is dot-producted with the pixel-by-pixel features (Per-pixel embeddings) output by the pixel decoder using a cross-attention layer, and a preliminary binary mask prediction (N mask predictions) is generated after a sigmoid activation function. The final segmentation mask is determined by the dot product result of the category prediction probability and the binary mask prediction, and the category label and segmentation mask prediction confidence of each pixel are output through threshold selection.
[0037] Preferably, in step S4, the visual identification system has the functions of image zooming in, zooming out, full-screen viewing, mask viewing and hiding, image information analysis, result saving, and generation of adulteration detection report, so as to facilitate users to observe and analyze the detection results from multiple angles and effectively manage the detection data.
[0038] The present invention also provides a fish meal adulteration non-destructive discrimination system integrating microscopic inspection method and image segmentation technology, which applies the above-mentioned microscopic visual inspection method, includes a data set construction module, a feature classification module, a model training module, a model deployment and result display module, and each module works together to realize the non-destructive discrimination of fish meal adulteration;
[0039] The data set construction module has the functions of data collection, organization, storage and division, providing rich and representative data for model training;
[0040] The feature classification module accurately classifies the complex and difficult to distinguish non-fish animal-derived adulteration features in fish meal based on morphological analysis methods, providing clear feature categories for model recognition;
[0041] The model training module uses a loss function and a training method to optimize the Fishmeal-Mask2Former model to improve the recognition accuracy and generalization ability of the model;
[0042] The model deployment and result display module deploys the trained model on the edge and intuitively displays the detection results through a visual recognition system, making it convenient for users to quickly obtain adulteration information on fish meal.
[0043] Preferably, the system also includes a data update module. When new fish meal samples or adulteration situations occur, the new sample data can be added to the data set construction module to update and expand the data set, and the training set and test set can be re-divided and the model can be retrained to enable the system to adapt to the ever-changing fish meal adulteration situation and continue to maintain a high detection accuracy.
[0044] Technical effects and advantages of the present invention:
[0045] 1. The present invention is based on microscopic image segmentation technology. The fishmeal microscopic image is segmented at the pixel level through the Fishmeal-Mask2Former model, the adulterated area and the type of adulteration are directly identified, and the results are presented in the form of a visual image. The microstructure of fishmeal can be analyzed more carefully, and the adulteration characteristics can be accurately located and identified. At the same time, the systematic construction of data sets and the development of a visual identification system are also involved. The technical means are more comprehensive and cutting-edge, and the test results are easier to understand and apply. Moreover, due to the high precision of the model and the ability to capture complex features, different types and degrees of adulteration can be more accurately identified, providing more powerful technical support for fishmeal quality detection.
[0046] 2. The present invention constructs a microscopic image dataset of adulterated fishmeal with a 40-mesh sieve and a 60-mesh sieve in the range of 30× to 50×, and formulates a sample pretreatment screening process and image acquisition conditions, which provides richer and more representative data for model training and helps to improve the generalization ability and accuracy of the model.
[0047] 3. The Fishmeal-Mask2Former microscopic image segmentation model proposed in the present invention integrates ResNet50, multi-head attention mechanism and multi-scale feature processing mechanism, which can effectively capture the appearance morphology, organizational structure, fiber texture, color characteristics and other subtle characteristics of fishmeal and abnormal adulterated substances under the microscope. The good feature fusion ability and the ability to capture complex features can more accurately identify multi-target abnormal adulteration features, making the model more accurate in identifying adulterated areas and judging adulteration types;
[0048] 4. The present invention designs a visual identification system for the microscopic features of adulterated fish meal with high visual distinction, which can automatically display abnormal areas in the microscopic image of the fish meal to be tested and qualitatively identify the type of suspected adulterants without manual comparison and identification. This provides an intuitive, accurate and efficient microscopic visual automated identification method for fish meal quality detection, greatly improving detection efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is the overall flow chart of the present invention.
[0050] Figure 2 It is a flow chart of S1-S3 of the present invention.
[0051] Figure 3 It is the overall framework and algorithm flow of the model of the present invention.
[0052] Figure 4 This is a structural diagram of the encoder and improved decoder in the Transformer module of the present invention.
[0053] Figure 5 It is a fish meal detection state diagram of the present invention.
[0054] Figure 6 It is a visual diagram of the fish meal adulteration detection results of the present invention. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] Embodiment 1,
[0057] The embodiment of the present invention provides a microscopic visual detection method for adulterating fish meal with animal-derived adulterated raw materials, which specifically comprises the following steps:
[0058] S1. Dataset construction: Fishmeal fishmeal adulteration identification microscopic image dataset was constructed using MySQL database, including multi-dimensional attribute data of sample source, component composition, pre-processing method, image metadata, and microscopic image acquisition parameters. DSpace was used to select local storage on the server. The dataset was randomly divided into training set and test set in a ratio of 7:3, and the training set was subjected to image enhancement processing such as mirroring, random rotation, random scaling, random cropping, and random photometric transformation.
[0059] When performing image enhancement processing on the training set, the angle range of random rotation is set to [-90°, 90°], the ratio range of random scaling is set to [0.8, 1.2], and the ratio range of random cropping is set to [0.7, 1];
[0060] Specifically, this step improves the performance of the fishmeal adulteration identification model by constructing a high-quality data set. The Fishmeal fishmeal adulteration identification microscopic image data set containing multidimensional attribute data is constructed and stored using the MySQL database and DSpace server. The data set is divided into a training set and a test set at a ratio of 7:3. The training set is subjected to a variety of image enhancement processing, with random rotation angles in [-90°, 90°], scaling ratios in [0.8, 1.2], and cropping ratios in [0.7, 1] to expand data diversity, simulate the differences in actual fishmeal microscopic images, improve the generalization ability and robustness of the model, enable the model to better adapt to fishmeal microscopic images under different conditions, enhance detection accuracy in complex scenarios, reduce the risk of overfitting, and lay a solid foundation for subsequent model training and accurate identification of fishmeal adulteration.
[0061] S2. Sample pretreatment and image acquisition: formulate sample pretreatment screening process and image acquisition conditions, construct fish meal microscopic image datasets of 40-mesh sieve oversize and 60-mesh sieve oversize in the range of 30× to 50×, and subdivide adulteration characteristics into five types of abnormal muscle, bone, skin, blood and hair through morphological analysis;
[0062] The sample pre-treatment screening process includes sieving the fish meal samples with 40 mesh and 60 mesh in sequence, removing the undersize materials and retaining the oversize materials for subsequent image acquisition to ensure that the particle size range of the collected samples is consistent and improve the consistency and comparability of the image features.
[0063] Image acquisition conditions include using a high-resolution, stable microscope, setting the light source intensity to 50%, exposure time to 100ms, and focal length to constant values, ensuring that all collected microscopic images are consistent in terms of brightness and clarity, which is convenient for subsequent model training and feature analysis;
[0064] Specifically, the purpose of this step is to provide high-quality and consistent fish meal microscopic image data for subsequent model training and adulteration feature analysis. By constructing a high-quality fish meal microscopic image dataset of 40-mesh sieve oversize and 60-mesh sieve oversize in the range of 30× to 50×, and subdividing the adulteration features through morphological analysis, a solid data foundation is laid for the model to accurately identify animal-derived adulterated raw materials in fish meal, effectively improving the accuracy and reliability of model training, and thereby improving the detection accuracy of fish meal adulteration.
[0065] S3, model construction and training, build the Fishmeal-Mask2Former model of the improved Masked-attention Mask Transformer (Mask2Former) architecture. The model specifically includes a pixel-level module, a Transformer module, and a segmentation prediction module.
[0066] The pixel-level module adopts the MaskFomer mask classification architecture, and the pixel decoder uses a lightweight pixel decoder based on the feature pyramid network FPN. The backbone network uses ResNet50, which obtains the basic structure and features of the image through convolution operations. The pixel decoder in the pixel-level module generates high-resolution per-pixel embeddings by gradually upsampling low-resolution features, providing a basis for subsequent feature fusion and prediction.
[0067] The Transformer module uses a standard encoder to process the input features extracted by the backbone network, and expands the self-attention mechanism to a multi-head attention mechanism to capture different feature relationships. It uses an integrated masked attention mechanism (MaskedAttention) and multi-scale feature fusion technology to improve the Transformer decoder, and improves the model's detail expression by limiting the cross-attention range. It introduces learnable scale-level embedding, which allows the model to dynamically adjust the feature scale according to the resolution of different feature maps, automatically learn and optimize feature representation during training.
[0068] Introducing the Masked Attention operator, the l-th layer decoder receives the query feature Q 1 =f Q (X l-1 )∈R N×C and the mask matrix Performs modulated attention computation. Using the mask matrix Limiting attention to local features centered on the predicted segment allows the model to focus on accurate contour extraction and pixel-level segmentation within the proposed region. 0 It is zero-initialized before being fed into the Transformer decoder and associated with a learnable position embedding. l-1 is the attention mask expression at feature location (x, y), which is output by the binary mask predictions of the first (l-1) Transformer decoder layers (threshold is 0.5), adjusted to be consistent with K l The same resolution. Since the query features passed to the first layer of self-attention are irrelevant to the image and have no signal from the image, Directly from X before the query feature is fed into the Transformer decoder 0 The binary mask prediction is obtained at . The modulated attention matrix is calculated as:
[0069]
[0070] The output of the decoder is connected to a multilayer perceptron (MLP), which finally outputs a convolutional layer for generating the probability distribution of each pixel category, expressed as:
[0071] P(x)=softmax(W f MLP(F)
[0072] Where P(x) is the probability distribution of the category of pixel x;
[0073] W f ——The weight of MLP;
[0074] F — features output from the Transformer decoder;
[0075] The segmentation prediction module adopts the two-stage architecture of Mask RCNN, introduces the ROI Align module to achieve pixel-accurate alignment processing for semantic segmentation, and uses the mask classification loss and pixel-by-pixel binary mask loss for supervised training;
[0076] In the segmentation prediction module, an MLP is used to receive the output from the Transformer module and generate the class prediction probability (N class predictions) and the corresponding mask embedding vector (N maskembeddings) of each pixel in parallel;
[0077] The mask embedding vector is dot-producted with the pixel-by-pixel features (Per-pixel embeddings) output by the pixel decoder using the cross-attention layer, and a preliminary binary mask prediction (N mask predictions) is generated through a sigmoid activation function. The final segmentation mask is determined by the dot product result of the class prediction probability and the binary mask prediction, and the class label and segmentation mask prediction confidence of each pixel are output through threshold selection;
[0078] The overall loss function L total The mixed weighted calculation formula is:
[0079] L total =α·L cls +β·L mask =α·λ cls L cls +β·(λ BCE L BCE +λ Dice L Dice )
[0080] Among them, L mask is the mask loss, which is used to measure the overlap between the predicted mask segmentation and the true label, L cls is the classification loss, which is used to measure the difference between the predicted category probability distribution and the true category distribution. α is the classification loss weight parameter, which is set to 0.6. β is the binary mask loss weight parameter, which is set to 0.4. λ is the adjustable weight parameter for different loss items. BCE =5.0,λ Dice =5.0,λ cls Set to 2.0 or 0.1 depending on whether the prediction matches the true label;
[0081] Binary cross entropy loss LBCE The calculation formula is: Among them, P is the prediction result matrix, T is the label matrix, and M is the number of feature map channels;
[0082] Dice loss L Dice The calculation formula is:
[0083] Specifically, the purpose of this step is to build and train a high-performance fishmeal adulteration identification model to accurately detect animal-derived adulterated raw materials in fishmeal. By building an improved Fishmeal-Mask2Former model, combining the three modules of pixel level, Transformer and segmentation prediction, different architectures and mechanisms are used to extract image features, capture feature relationships and achieve accurate semantic segmentation;
[0084] The pixel-level module is used to obtain the basic structure of the image and generate pixel-by-pixel embedding, the Transformer module enhances the ability to capture feature relationships, and the segmentation prediction module completes accurate pixel alignment and mask and category prediction. Mask classification loss and pixel-by-pixel binary mask loss are used for supervised training, combined with the mixed weighted overall loss function, using binary cross entropy loss and Dice loss to effectively measure the difference between the prediction and the true label, so that the model can learn the complex features of fish meal microscopic images, realize the accurate identification of five types of adulterated tissues in fish meal, such as abnormal muscle and bone, and output the category label and segmentation mask prediction confidence of each pixel, which improves the accuracy and reliability of fish meal adulteration detection and provides strong technical support for fish meal quality detection.
[0085] S4. Model application and result display: The trained model is deployed on the edge, and a visual recognition system for the microscopic features of adulterated fish meal with high visual distinction is designed to automatically display abnormal areas in the microscopic images of fish meal to be tested and to identify the types of suspected adulterants. The visual recognition system has functions such as image zooming in and out, full-screen viewing, mask viewing and hiding, image information analysis, result saving, and generation of adulteration detection reports, which facilitates users to observe and analyze the test results from multiple angles and effectively manage the test data;
[0086] Specifically, the purpose of this step is to put the trained model into practical application, improve detection efficiency and real-time performance with the help of edge deployment, and design a visual recognition system with high visual distinction to intuitively and conveniently present the results of fish meal adulteration detection;
[0087] The system has a variety of practical functions such as image zooming in, zooming out, and full-screen viewing, which allows users to comprehensively and carefully observe the microscopic images of fish meal to be tested, automatically display abnormal areas and qualitatively identify the types of suspected adulterants, greatly improving the efficiency and accuracy of users' analysis of test results, achieving effective management of test data, and being able to quickly and accurately identify adulteration in fish meal, providing strong technical support and decision-making basis for fish meal quality testing and supervision.
[0088] Embodiment 2,
[0089] The embodiment of the present invention also provides a fish meal adulteration non-destructive discrimination system integrating microscopic inspection method and image segmentation technology, and applies the microscopic visual inspection method of embodiment 1. The system specifically includes a data set construction module, a feature classification module, a model training module, a model deployment and result display module, and each module works together to realize the non-destructive discrimination of fish meal adulteration;
[0090] The data set construction module has the functions of data collection, organization, storage and division, providing rich and representative data for model training;
[0091] The feature classification module accurately classifies adulteration features in fish meal based on morphological analysis methods, providing clear feature categories for model identification;
[0092] The model training module uses a loss function and a training method to optimize the Fishmeal-Mask2Former model to improve the recognition accuracy and generalization ability of the model;
[0093] The model deployment and result display module deploys the trained model on the edge and intuitively displays the test results through a visual recognition system, so that users can quickly obtain adulteration information of fish meal;
[0094] It also includes a data update module. When new fish meal samples or adulteration occur, the new sample data can be added to the dataset construction module to update and expand the dataset, re-divide the training set and test set, and retrain the model so that the system can adapt to the ever-changing fish meal adulteration situation and continue to maintain a high detection accuracy.
[0095] Specifically, this embodiment is used to achieve efficient, accurate and non-destructive discrimination of fish meal adulteration, and collects, organizes, stores and divides data through a data set construction module to provide rich and representative data for model training;
[0096] The feature classification module accurately classifies adulteration features based on morphological analysis, providing clear categories for model identification;
[0097] The model training module uses a specific loss function and training method to optimize the training of the Fishmeal-Mask2Former model to improve recognition accuracy and generalization ability;
[0098] The model deployment and result display module is deployed at the edge and displays the results through a visualization system, making it easier for users to obtain adulteration information;
[0099] The data update module updates the data set and retrains the model when there are new samples or adulteration. The final result is that the system can continuously adapt to changes in fish meal adulteration, maintain high detection accuracy, and provide reliable protection for fish meal quality detection.
[0100] 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 principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A microscopic visual detection method for adulteration of fish meal with animal-derived raw materials, characterized in that: The specific steps include: S1. Dataset construction: Fishmeal adulteration identification microscopic image dataset was constructed using MySQL database, including multi-dimensional attribute data of sample source, component composition, pre-processing method, image metadata, and microscopic image acquisition parameters. DSpace was used to select server local storage. The dataset is randomly divided into a training set and a test set in a ratio of 7:3, and the training set is subjected to image enhancement processing such as mirroring, random rotation, random scaling, random cropping, and random photometric transformation. S2. Sample pretreatment and image acquisition: formulate sample pretreatment screening process and image acquisition conditions, construct fish meal microscopic image datasets of 40-mesh sieve oversize and 60-mesh sieve oversize in the range of 30× to 50×, and subdivide non-fish animal-derived adulteration characteristics into five types of abnormal muscle, bone, skin, blood and hair through morphological analysis; S3, model construction and training, build the Fishmeal-Mask2Former model of the improved Masked-attention Mask Transformer (Mask2Former) architecture. The model specifically includes a pixel-level module, a Transformer module, and a segmentation prediction module. The pixel-level module adopts the MaskFomer mask classification architecture, the pixel decoder uses a lightweight pixel decoder based on the feature pyramid network FPN, and the backbone network uses ResNet50 to obtain the basic structure and features of the image through convolution operations; The Transformer module uses a standard encoder to process the input features extracted by the backbone network, and expands the self-attention mechanism to a multi-head attention mechanism to capture different feature relationships. It introduces learnable scale-level embedding and masked attention modules to improve the model's detail expression by limiting the scope of cross-attention. The segmentation prediction module adopts the two-stage architecture of Mask RCNN, introduces the ROI Align module to achieve pixel-accurate alignment processing for semantic segmentation, and uses mask classification loss and pixel-by-pixel binary mask loss for supervised training. The overall loss function L total The mixed weighted calculation formula is: L total =α·L cls +β·L mask =a·l cls L cls +β·(λ BCE L BCE +λ Dice L Dice ) Among them, L mask is the mask loss, which is used to measure the overlap between the predicted mask segmentation and the true label, L cls is the classification loss, which is used to measure the difference between the predicted category probability distribution and the true category distribution. α is the classification loss weight parameter, which is set to 0.
6. β is the binary mask loss weight parameter, which is set to 0.
4. λ is the adjustable weight parameter for different loss items. BCE =5.0,λ Dice =5.0,λ cls Set to 2.0 or 0.1 depending on whether the prediction matches the true label; Binary cross entropy loss L BCE The calculation formula is: Among them, P is the prediction result matrix, T is the label matrix, and M is the number of feature map channels; Dice loss L Dice The calculation formula is: S4. Model application and result presentation. The trained model is deployed on the edge, and a visual recognition system for the microscopic features of adulterated fish meal with high visual distinction is designed to automatically display abnormal areas in the microscopic images of fish meal to be inspected and to qualitatively identify the types of suspected adulterants.
2. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S1, when performing image enhancement processing on the training set, the angle range of random rotation is set to [-90°, 90°], the ratio range of random scaling is set to [0.8, 1.2], and the ratio range of random cropping is set to [0.7, 1].
3. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S2, the sample pretreatment screening process includes performing 40-mesh and 60-mesh screening operations on the fish meal sample in sequence, removing the undersize material, and retaining the oversize material for subsequent image acquisition to ensure that the particle size range of the collected samples is consistent, thereby improving the consistency and comparability of image features.
4. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S2, the image acquisition conditions include using a high-resolution, stable digital microscope, setting the light source intensity to 50%, the exposure time to 100ms, and the focal length to constant values, to ensure that all collected microscopic images are consistent in terms of brightness, clarity, etc., to facilitate subsequent model training and feature analysis.
5. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S3, the pixel decoder in the pixel-level module generates high-resolution per-pixel embeddings by gradually upsampling low-resolution features, providing a basis for subsequent feature fusion and prediction.
6. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S3, in the Transformer module, multiple information subspaces are processed in parallel through a multi-head attention mechanism to enhance the model's ability to capture different types of feature relationships, thereby generating high-resolution features and processing object queries to achieve more accurate mask and category predictions. The Transformer decoder is improved by integrating the masked attention mechanism and multi-scale feature fusion technology, and the model's detail expression is improved by limiting the scope of cross-attention. A learnable scale-level embedding is introduced to allow the model to dynamically adjust the feature scale, automatically learn and optimize the feature representation according to the resolution of different feature maps during the training process.
7. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S3, in the segmentation prediction module, a multilayer perceptron (MLP) is used to receive the output from the Transformer module, and generate the class prediction probability (N class predictions) and the corresponding mask embedding vector (N mask embeddings) of each pixel in parallel; The mask embedding vector is dot-producted with the pixel-by-pixel features (Per-pixel embeddings) output by the pixel decoder using a cross-attention layer, and a preliminary binary mask prediction (N mask predictions) is generated after a sigmoid activation function. The final segmentation mask is determined by the dot product result of the category prediction probability and the binary mask prediction, and the category label and segmentation mask prediction confidence of each pixel are output through threshold selection.
8. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: In step S4, the visual recognition system has the functions of image zooming in, zooming out, full-screen viewing, mask viewing and hiding, image information analysis, result saving, and generation of adulteration detection report. It supports users to observe and analyze the detection results from multiple angles and provide manual feedback and intervention on the predicted output of the model, so as to enable users to effectively manage the detection data and perform computer-aided diagnosis of complex fish meal adulteration situations.
9. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 1, characterized in that: It also includes a fishmeal adulteration non-destructive identification system that integrates microscopy and image segmentation technology, including a data set construction module, a feature classification module, a model training module, and a model deployment and result display module. Each module works together to achieve non-destructive identification of fishmeal adulteration; The data set construction module has the functions of data collection, organization, storage and division, providing rich and representative data for model training; The feature classification module accurately classifies the non-fish animal-derived adulteration features in fish meal based on morphological analysis methods, providing clear feature categories for model identification; The model training module uses a loss function and training method to optimize the Fishmeal-Mask2Former model to improve the recognition accuracy and generalization ability of the model; The model deployment and result display module deploys the trained model on the edge and intuitively displays the detection results through a visual recognition system, making it convenient for users to quickly obtain adulteration information on fish meal.
10. The microscopic visual detection method for adulteration of fish meal with animal-derived raw materials according to claim 9, characterized in that: The system also includes a data update module. When new fish meal samples or adulteration occur, the new sample data can be added to the data set construction module to update and expand the data set, re-divide the training set and test set, and retrain the model so that the system can adapt to the ever-changing fish meal adulteration situation and continue to maintain a high detection accuracy.
Citation Information
Cited By
Fermented sausage adulteration detection method based on microscopic image analysis
CN121767360A
A method for detecting adulteration of fermented sausages based on microscopic image analysis
CN121767360B