A method, device, medium and product for measuring fat content of meat and bone meal
By pulverizing, drying, and defatting meat and bone meal, gradient samples of oil content are generated. Images are collected and an improved ResNet50 model is constructed, which solves the problems of long time consumption, complicated operation, and high cost in detecting the oil content of meat and bone meal, and realizes rapid, non-destructive, low-cost, and high-precision detection.
Patent Information
- Application Number
- CN202610798313.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-04
- Publication Date
- 2026-08-25
AI Technical Summary
Existing meat and bone meal fat content detection technologies suffer from problems such as long detection time, cumbersome operation, high cost, poor adaptability, and insufficient quantitative accuracy, which cannot meet the industrial needs of meat and bone meal production quality inspection, raw material acceptance, and rapid on-site screening for small and medium-sized enterprises.
By pulverizing, drying, and defatting meat and bone meal, adding oil solution to prepare samples with different fat content gradients, generating labeled sample sets, collecting images and performing size standardization and data augmentation processing, constructing an improved ResNet50 model, performing feature extraction and iterative verification, and achieving high-precision quantitative regression of fat content.
It enables rapid, non-destructive, low-cost, and high-precision detection of fat content in meat and bone meal, making it suitable for quality inspection in meat and bone meal production and rapid on-site screening in small and medium-sized enterprises. It also features strong batch adaptability and high inference accuracy.
Smart Images

Figure CN122631632A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of meat and bone meal fat content measurement, and in particular to a method, equipment, medium and product for measuring meat and bone meal fat content. Background Technology
[0002] Meat and bone meal, a high-protein byproduct of livestock slaughtering and processing, is widely used in compound feed preparation and water-soluble fertilizer production. Its oil content is a key indicator for evaluating the quality of meat and bone meal and guiding subsequent deep processing. Currently, the detection of oil content in meat and bone meal mainly relies on traditional physicochemical testing methods and indirect spectroscopic detection methods. Traditional physicochemical testing methods, such as Soxhlet extraction, rely on repeated extraction, hydrolysis, and distillation with organic solvents. This process is cumbersome, with a single sample taking 4 to 8 hours to complete. Furthermore, the process involves flammable and explosive reagents, posing serious safety hazards and environmental pollution risks. It is also highly dependent on professional operators, and even minor deviations in pretreatment can significantly affect the accuracy of results, making it unsuitable for real-time quality control on production lines and rapid screening of incoming raw materials. While non-destructive testing technologies such as near-infrared spectroscopy have shortened testing time in recent years, they are limited by the complex composition of meat and bone meal, uneven distribution of aggregates and impurities leading to overlapping and interference of spectral signals, poor model generalization ability, and the need for repeated calibration for different batches. Additionally, the equipment is expensive, maintenance costs are high, and it has stringent requirements for environmental temperature and humidity and sample flatness, making it difficult to implement in small and medium-sized enterprises. Moreover, existing visual recognition technologies mostly focus on sorting impurities or detecting particle size in meat and bone meal, and have not yet established a deep correlation between oil content and visual characteristics such as the surface color, texture, and gloss of meat and bone meal, making it impossible to accurately quantify oil content through image features. In summary, existing testing technologies generally suffer from problems such as long testing time, cumbersome operation, high cost, poor adaptability, and insufficient quantitative accuracy. Traditional physicochemical methods and existing non-destructive technologies cannot simultaneously achieve accuracy, efficiency, and economy, which restricts the industrial application of rapid meat and bone meal quality testing technology and fails to fully meet the industrial needs of meat and bone meal production quality inspection, raw material acceptance, and rapid on-site screening for small and medium-sized enterprises. Summary of the Invention
[0003] The purpose of this application is to provide a method, equipment, medium, and product for measuring the fat content of meat and bone meal, in order to solve the problem that traditional physicochemical methods and existing non-destructive technologies cannot fully meet the industrial needs of meat and bone meal production quality inspection, raw material acceptance, and rapid on-site screening for small and medium-sized enterprises.
[0004] To achieve the above objectives, this application provides the following solution: In a first aspect, this application provides a method for measuring the fat content of meat and bone meal, including: S1. After the meat and bone meal is crushed, dried and degreased, an oil solution is added to prepare meat and bone meal samples with different oil content gradients. The true oil content of each meat and bone meal sample is calculated by physicochemical determination, and a true oil content label is generated to obtain a labeled sample set. S2, according to the labeled sample set, each meat and bone meal sample is placed in a collection dish, shaken and spread evenly, and images are collected under preset lens distance and flash conditions. After clarity screening, an original image set is generated. S3, Based on the original image set, the images are normalized in size and data augmented, and divided according to a preset ratio to generate a training set, a validation set and a test set; S4. Based on the training set, validation set and test set, construct an improved ResNet50 model, and obtain a trained oil content prediction model by forward feature extraction and backward parameter optimization, and iteratively verify the deviation between the model output value and the real oil content label. S5. Obtain the target image of the meat and bone meal to be tested, input the target image into the trained oil content prediction model, and output the predicted value of the oil content of the meat and bone meal to be tested through backbone network feature extraction and enhanced regression prediction head calculation.
[0005] Secondly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described method for measuring the fat content of meat and bone meal.
[0006] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method for measuring the fat content of meat and bone meal.
[0007] Fourthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for measuring the fat content of meat and bone meal.
[0008] According to the specific embodiments provided in this application, this application has the following technical effects: This application prepares meat and bone meal samples with different fat content gradients by pulverizing, drying, and defatting the meat and bone meal, and then adding an oil solution. The true fat content of each meat and bone meal sample is calculated through physicochemical measurements, generating a true fat content label and resulting in a labeled sample set, ensuring the accuracy of the regression benchmark from the source. Based on the labeled sample set, each meat and bone meal sample is placed in a collection dish, shaken, and spread evenly. Images are acquired under preset lens distance and flash conditions, and after sharpness filtering, an original image set is generated. Based on the original image set, the images are normalized and data augmented, and divided according to preset proportions to generate training, validation, and test sets. This application effectively eliminates the interference of ambient light fluctuations and uneven sample distribution on image representation by combining fixed-distance acquisition, sharpness filtering, size normalization, and targeted data augmentation strategies, improving data consistency. On this basis, relying on the improved ResNet50 model in step S4, forward feature extraction and backward parameter optimization are performed, and the deviation between the model output value and the true fat content label is iteratively verified to obtain a trained fat content prediction model, achieving high-precision quantitative regression from visual features to fat content. Finally, the target image of the meat and bone meal to be tested is acquired and input into the trained oil content prediction model. After feature extraction by the backbone network and calculation by the enhanced regression prediction head, the predicted oil content value of the meat and bone meal to be tested is output, completing the non-contact rapid inference output of the target image. This application completely abandons the dependence on organic solvents and the cumbersome process of several hours in the traditional Soxhlet extraction method, eliminates the risk of flammability and explosion and irreversible damage to the sample, and breaks through the bottlenecks of expensive spectroscopic equipment, poor model generalization due to component interference and the need for frequent correction, as well as the limitations of existing vision technology that can only perform qualitative sorting and cannot accurately quantify. It has achieved significant advantages such as short single sample detection time, no need for chemical reagent consumption, low operation threshold, and deployment with only conventional imaging devices and computers. It has strong batch adaptability and high inference accuracy, and fully meets the industrial needs of meat and bone meal production quality inspection, raw material acceptance and rapid on-site screening of small and medium-sized enterprises. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 A flowchart illustrating a method for measuring the fat content of meat and bone meal provided in this application embodiment; Figure 2 Comparison images of meat and bone meal samples before and after image processing provided in this application embodiment; Figure 2Image (a) in the image is a schematic diagram of meat and bone meal before processing. Figure 2 (b) in the image is a schematic diagram of the processed meat and bone meal. Figure 3 The diagram shows the ResNet50-MBM network structure. Figure 4 The network structure diagram of MBM-BTNK residual modules in ResNet50-MBM is shown below; Figure 5 The network structure diagram of the BTNK1 residual module of ResNet50-MBM; Figure 6 The network structure diagram of the BTNK2 residual module of ResNet50-MBM; Figure 7 A schematic diagram of the training and validation loss curves of the improved ResNet50 model provided in the embodiments of this application; Figure 8 A scatter plot comparing the actual and predicted values of the oil content of the improved ResNet50 model provided in this embodiment of the application. Detailed Implementation
[0011] 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, and 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.
[0012] To make the objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0013] like Figure 1 As shown in the embodiment of this application, a method for measuring the fat content of meat and bone meal is provided, including: S1. After the meat and bone meal is crushed, dried and degreased, an oil solution is added to prepare meat and bone meal samples with different fat content gradients. The true fat content of each meat and bone meal sample is calculated by physicochemical determination, and a true fat content label is generated to obtain a labeled sample set.
[0014] S2, according to the labeled sample set, each meat and bone meal sample is placed in a collection dish and shaken to flatten it. Images are collected under preset lens distance and flash conditions. After clarity screening, an original image set is generated.
[0015] S3. Based on the original image set, the images are normalized in size and data augmented, and divided according to a preset ratio to generate a training set, a validation set, and a test set.
[0016] S4. Based on the training set, validation set, and test set, an improved ResNet50 model is constructed. Through forward feature extraction and backward parameter optimization, and by iteratively verifying the deviation between the model output value and the real oil content label, a trained oil content prediction model is obtained.
[0017] S5. Obtain the target image of the meat and bone meal to be tested, input the target image into the trained oil content prediction model, and output the predicted value of the oil content of the meat and bone meal to be tested through backbone network feature extraction and enhanced regression prediction head calculation.
[0018] In an exemplary embodiment, S1 specifically includes: S11. The meat and bone meal is thoroughly pulverized in a grinder and passed through a multi-mesh sieve. After being dried in an oven, it is cooled to room temperature to obtain pretreated meat and bone meal.
[0019] S12, the pretreated meat and bone meal is degreased by using n-hexane and then dried in a vacuum drying oven. The initial oil quality is determined by Soxhlet extraction to obtain the basic oil data.
[0020] S13, Prepare an oil solution based on the basic oil data, and uniformly add the oil solution to the defatted meat and bone meal while stirring. After the addition is complete, continue stirring until fully dispersed. After evaporating the solvent under vacuum at 40°C and cooling to room temperature, meat and bone meal samples with different oil content gradients are prepared, and the labeled sample set is generated.
[0021] In an exemplary embodiment, the basic oil data in S12 is (m2-m1) / m×100%; where m1 is the constant weight of the empty extraction cup, m2 is the constant weight of the extraction cup and the fat, and m is the sample mass.
[0022] S13 specifically includes: taking the lard produced during the preparation of meat and bone meal, melting it in a water bath at a set temperature, and adding n-hexane at 3 times the mass of the lard and stirring thoroughly to obtain the oil solution.
[0023] Multiple oil content gradients are set up according to the oil content. The oil solution is added to the weighed meat and bone meal. Multiple parallel samples are set up for each oil content gradient. The oil content of each meat and bone meal sample is determined again by Soxhlet extraction and recorded by numbering to form the true oil content label, thus obtaining a labeled sample set.
[0024] Furthermore, such as Figure 2 As shown in (a)-(b) above, the meat and bone meal pretreatment process specifically includes: (1) Grind the meat and bone meal thoroughly in a grinder and then pass the ground meat and bone meal through an 80-mesh sieve.
[0025] (2) Place the sieved meat and bone meal into a 105℃ oven and dry for 3-4 hours. After drying, cool to room temperature.
[0026] (3) Degreasing treatment of meat and bone meal: meat and bone meal was degreased using n-hexane, dried in a vacuum drying oven (40℃), and the oil content in meat and bone meal was determined by Soxhlet extraction.
[0027] Oil content = (m2-m1) / m×100 Where m1 = constant weight of empty extraction cup (g); m2 = constant weight of extraction cup + fat (g); m = sample mass (g).
[0028] (4) Take the lard produced during the preparation of meat and bone meal, melt it in a water bath at 40°C, add n-hexane at 3 times the mass of the lard, and stir thoroughly.
[0029] (5) Weigh 50.00g of meat and bone meal used to determine the fat content in (3) and place it in a beaker. There are 49 portions in total. Set up 49 fat content gradients according to the fat content of 3%-20%. Add oil solution according to the calculation. Take the solution and add it evenly to the meat and bone meal while stirring. After adding, continue stirring for 10 minutes to fully disperse. Vacuum evaporate the solvent at 40℃ and cool to room temperature.
[0030] (6) The oil content of each sample was determined by Soxhlet extraction and recorded by number.
[0031] In an exemplary embodiment, S2 specifically includes: S21, Weigh 1g of meat and bone meal sample from the labeled sample set, place it in a ceramic dish, and shake the ceramic dish to make the meat and bone meal sample evenly distributed.
[0032] S22, set the lens to a set distance from the ceramic dish, adjust the focal length to completely include the meat and bone powder sample in the image acquisition frame, acquire the image, and obtain the initial captured image.
[0033] S23, Perform S21-S22 on meat and bone meal samples with each fat content gradient, take multiple duplicate photos, remove shaky and blurry photos from the initial images, and select clear photos to form the original image set.
[0034] Further, image acquisition: (1) Weigh about 1g of processed meat and bone meal into an alumina ceramic dish (white flat bottom), gently shake the ceramic dish to distribute the meat and bone meal evenly, and collect images. Set up 5 parallel samples for each type of oil content for each sample and take pictures.
[0035] (2) Set the lens 13cm-15cm away from the ceramic dish, adjust the focal length to completely include the sample in the image acquisition frame, turn on the flash to acquire the image, take 3 duplicate photos of each sample and select the photos without shaking or blur for subsequent model training.
[0036] In an exemplary embodiment, S3 specifically includes: S31, group and name the images in the original image set, and associate and map each image name with the corresponding real oil content label to obtain a mapped image set.
[0037] S32, batch scale the images in the mapped image set to a set size and perform standardization processing to obtain a standardized image set.
[0038] S33, randomly crop, rotate, flip, and color jitter the images used for training in the standardized image set to generate enhanced training images, and only perform center cropping and standardization processing on the images used for verification and testing in the standardized image set to generate standard verification images.
[0039] S34, the enhanced training images and the standard verification images are randomly allocated in an 8:1:1 ratio to generate the training set, verification set and test set.
[0040] Further image preprocessing: (1) Group and name the collected images, and organize the image names and corresponding oil content; (2) Batch standardize all images and scale them to 256×256.
[0041] (3) Data augmentation: Randomly crop, rotate, flip, and color jitter the training set images to prevent overfitting and improve generalization ability; only center cropping and standardization are used for the validation and test sets, and random augmentation is not used.
[0042] (4) The preprocessed images are randomly assigned to the training set, validation set and test set in a ratio of 8:1:1.
[0043] In an exemplary embodiment, the construction of the improved ResNet50 model in S4 specifically includes: S41, replace the 7×7 single convolutional layer of the ResNet50 model with two 3×3 convolutional stacked structures, and connect a batch normalization layer and a Mish activation function sequentially after each convolutional stack to generate a basic feature extraction layer; the Mish activation function Mish(x) is Mish(x)=x·tanh(ln(1+e xThis is used to perform a nonlinear transformation on the input feature value x output by the convolution stack structure, retaining negative features and outputting the basic feature map.
[0044] S42, for the basic feature extraction layer, the stride of the convolutional layer of the first residual block of Layer 4 in the backbone network of the ResNet50 model is adjusted from (2,2) to (1,1), and the stride of the downsampling module of the residual block is adjusted to (1,1) simultaneously. The downsampling operation of Layer 4 in the backbone network is canceled. Based on the forward propagation of the adjusted network, a backbone feature map that retains high-frequency texture features is generated, and an improved ResNet50 model is constructed.
[0045] In an exemplary embodiment, the construction of the improved ResNet50 in S4 further includes: replacing the first residual block of Layer 3 and Layer 4 of the backbone network in the ResNet50 model with an MBM-BTNK module. S43, replace the conv2 layer of the first residual block of Layer 3 of the backbone network and the conv2 layer of the first residual block of Layer 4 of the backbone network with deformable convolutional layers with a kernel size of 3×3 and a stride (padding) of 1 to generate a deformable sampling layer.
[0046] S44, based on the deformable convolutional layer, the sampling position is adaptively adjusted according to the irregular shape of the meat and bone meal particles, and the forward computation logic follows... The adaptive feature map is calculated and input into the next network layer; where, To output feature maps in The pixel value at the location, where R is the sampling grid of the standard convolution. p n This is the preset offset within the sampling grid. ( p n ) represents the convolution kernel weights. x () represents the input feature map, Δ p n The deformable offset learned by the network. m n The sampling weight mask learned by the network and m n The value range is [0,1].
[0047] In an exemplary embodiment, the construction of the improved ResNet50 model in S4 further includes: inserting a CBAM attention mechanism module into the backbone network. S45, after the output of Layer 3 and Layer 4 of the backbone network, a CBAM attention mechanism module is inserted respectively to obtain a two-level attention injection network.
[0048] S46. Based on the dual-level attention injection network, the feature map is processed by adaptive average pooling and adaptive max pooling, and then input into a fully connected network consisting of two 1×1 convolutional layers. After processing by the Mish activation function, the channel attention weights are output through the Sigmoid function to obtain the channel attention-weighted feature map.
[0049] S47, Based on the feature map after channel attention weighting, spatial attention weights are generated through convolution operation. The channel attention weights and spatial attention weights are multiplied with the original feature map to generate an oil feature enhancement map; the original feature map is the target image.
[0050] In an exemplary embodiment, building the improved ResNet50 model in S4 further includes building an enhanced regression prediction head.
[0051] The predicted oil content output in S5 is specifically based on the enhanced regression prediction head: S51, the enhanced oil feature map is subjected to multi-scale feature fusion to obtain multi-scale fused features. The multi-scale fused features are input into the enhanced regression prediction head to output the predicted oil content of the meat and bone meal to be tested. The enhanced regression prediction head includes four fully connected layers connected in series. The first fully connected layer reduces the input dimension from 2048 to 1024 and connects the batch normalization layer, the Mish activation function, and the dropout layer with a dropout probability of 0.3 to obtain the first-level dimensionality reduction feature. The second fully connected layer reduces the dimension of the first-level dimensionality reduction feature from 1024 to 512 and connects the batch normalization layer, the Mish activation function, and the dropout layer with a dropout probability of 0.2 to obtain the second-level dimensionality reduction feature. The third fully connected layer reduces the dimension of the second-level dimensionality reduction feature from 512 to 128 and connects the batch normalization layer and the Mish activation function to obtain the third-level nonlinear feature. The fourth fully connected layer reduces the dimension of the third-level nonlinear feature from 128 to 1 and directly outputs the predicted oil content.
[0052] In an exemplary embodiment, step S4 involves iteratively verifying the deviation between the model output value and the actual oil content label using an evaluation formula to obtain a trained oil content prediction model. Specifically, this includes: S48, input the validation set into the improved ResNet50 model, and based on the predicted values output by the model and the true oil content labels, through... Calculate the mean absolute error (MAE) and based on... Calculate the root mean square error (RMSE); where N is the number of samples in the test set. This represents the true label value of the fat content in the i-th meat and bone meal sample; This is the predicted fat content output by the improved ResNet50 model for the i-th meat and bone meal sample.
[0053] S49, based on the predicted value, the actual oil content label, and the mean of the actual oil content labels in the test set. ,pass Calculate the coefficient of determination R 2 .
[0054] Furthermore, such as Figures 3-6 As shown, the construction process of the improved ResNet50 model (i.e., ResNet50-MBM) specifically includes: (1) To address the technical problem of losing fine meat and bone meal texture during downsampling using the original ResNet50, the 7×7 single convolutional layer of ResNet50 was replaced with a stacked structure of two 3×3 convolutional layers. This reduced the kernel size and improved the ability to capture fine meat and bone meal texture. The structure is as follows: Figure 3 As shown.
[0055] Each convolutional layer is followed by a batch normalization layer to accelerate model convergence and suppress overfitting. After batch normalization, the Mish activation function is used instead of the ReLU activation function to address the issue of ReLU losing negative features, improving the completeness of feature extraction and adapting to the needs of meat and bone meal fat content regression tasks. Figures 5-6 As shown. Mish activation function formula: Mish(x) = x.tanh(ln(1+e) x )) Where x is the input feature value of the output of the convolutional layer / fully connected layer, tanh() is the hyperbolic tangent function, ln() is the natural logarithm function, and e is the natural constant.
[0056] To address the issue of fine texture in meat and bone meal that is easily lost during downsampling, downsampling suppression optimization is performed on Layer 4 of the backbone network. Specifically, the stride of the convolutional layer (conv2) of the first residual block in Layer 4 is adjusted from (2,2) to (1,1), and the stride of the downsampling module (downsample) of the same residual block is also adjusted to (1,1). This cancels the downsampling operation of Layer 4, maximizing the preservation of high-frequency texture features in the meat and bone meal image and providing support for accurate prediction of subsequent oil content.
[0057] Considering the irregular morphology and uneven distribution of meat and bone meal particles, the first residual block of Layer 3 and Layer 4 of the backbone network is replaced with an MBM-BTNK module, such as... Figure 4 As shown, this allows the convolutional kernel to adaptively adjust the sampling position according to the actual shape of the meat and bone meal particles, improving the model's ability to adapt to irregular features. The MBM-BTNK structure is as follows: the conv2 layer of the first residual block in Layer 3 and the conv2 layer of the first residual block in Layer 4 are both replaced with deformable convolutional layers (DCNv2). The kernel size remains 3×3, padding=1, and the stride is consistent with the original convolutional layer in the corresponding layer, ensuring the continuity and completeness of feature extraction. The core formula of deformable convolution DCNv2 is: In the formula, y(p0) is the pixel value of the output feature map at position p0, and R is the sampling grid of the standard convolution. This is the preset offset within the sampling grid. ( ) represents the convolution kernel weights, x() represents the input feature map, and Δ The deformable offset learned by the network. The sampling weight mask learned by the network has a value range of [0,1].
[0058] To further enhance the model's ability to identify fat-related features in meat and bone meal, a CBAM (hybrid channel attention and spatial attention) attention mechanism module is inserted into the key layers of the feature extraction backbone network to achieve accurate localization and enhancement of fat-related features. Specific structural parameters: In the channel attention submodule, the feature map, after adaptive average pooling and adaptive max pooling, is input into a fully connected network consisting of two 1×1 convolutional layers (reduction coefficient = 16). After processing by the Mish activation function, the channel attention weights are output through the Sigmoid function. The spatial attention submodule, based on the channel attention-weighted feature map, generates spatial attention weights through convolution operations. Finally, the channel attention weights and spatial attention weights are multiplied by the original feature map to achieve feature enhancement. To ensure accurate enhancement of mid-to-high-level features and improve the model's accuracy in identifying fat features, two CBAM attention modules are inserted after Layer 3 and Layer 4 of the backbone network, respectively.
[0059] To fully utilize the different scale features extracted from the backbone network and improve regression prediction accuracy, a multi-scale feature fusion mechanism is constructed, and an enhanced regression prediction head (ERPH) is designed to adapt to the small-range continuous value prediction needs of meat and bone meal fat content.
[0060] The regression prediction head is based on multi-scale fused features and is constructed using a four-layer fully connected network, replacing the single-layer fully connected classification head of ResNet50. It is specifically adapted for predicting continuous values of meat and bone meal fat content. The specific structure is as follows: Figure 3 As shown: The first fully connected layer has an input dimension of 2048 and an output dimension of 1024. It connects a batch normalization layer (BatchNorm1d), a Mish activation function, and a dropout layer (dropout probability 0.3) to reduce feature dimensionality and suppress overfitting. The second fully connected layer has an input dimension of 1024 and an output dimension of 512. It connects the batch normalization layer, the Mish activation function, and the dropout layer (dropout probability 0.2) to further reduce dimensionality and enhance feature representation. The third fully connected layer has an input dimension of 512 and an output dimension of 128. It connects the batch normalization layer and the Mish activation function to enhance the non-linear expressive power of features. The fourth fully connected layer has an input dimension of 128 and an output dimension of 1, directly outputting continuous predicted values of meat and bone meal fat content.
[0061] (2) Using the coefficient of determination R 2 The mean absolute error (MAE) and root mean square error (RMSE) are used to evaluate the model's prediction accuracy.
[0062] Coefficient of determination R 2 formula: In the formula, N is the number of samples in the test set. This represents the true labeled value of the fat content in the i-th meat and bone meal sample. To predict the fat content of the i-th meat and bone meal sample using the improved ResNet50 model, This represents the mean of the true labels in the test set.
[0063] The formula for Mean Absolute Error (MAE) is as follows: In the formula, M is the total number of valid meat and bone meal samples in the validation set; || is the absolute value operator.
[0064] Root-Mean-Square Error (RMSE) formula: (4) The final model has a total of 24.69M parameters, and the test set R 2The value is 0.9897, the MAE value is 0.4377, the RMSE value is 0.5425, and the inference speed reaches 449.43 frames per second, which meets the actual production needs.
[0065] S50, based on the mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination... R 2 Construct a comprehensive loss function to guide the model's backpropagation in updating network weights; when the determination coefficients... R 2 When the mean absolute error (MAE) and root mean square error (RMSE) converge to a preset threshold range, training is stopped and the model parameters are fixed, generating the trained oil content prediction model. The training and validation loss curves of the improved ResNet50 model are shown below. Figure 7 As shown in the figure, the scatter plot comparing the actual and predicted values of the oil content of the improved ResNet50 model is as follows. Figure 8 As shown.
[0066] Existing methods for detecting the fat content of meat and bone meal mainly include Soxhlet extraction and near-infrared spectroscopy. Compared with existing technologies, the method for measuring the fat content of meat and bone meal constructed in this application has the advantages of high detection efficiency, no damage and no chemical consumption, low operating threshold, low cost and high degree of automation.
[0067] The advantages of this application are reflected in the following aspects: 1. High detection efficiency.
[0068] Soxhlet extraction requires sample pretreatment, solvent reflux, and drying to constant weight, with single-sample analysis taking 4–8 hours. Near-infrared spectroscopy requires periodic instrument calibration and modeling, making the process cumbersome. This technology only requires image acquisition and model inference, and the analysis time for a single sample can be controlled within 5 minutes. It supports continuous and rapid analysis of batches of samples, significantly improving detection efficiency.
[0069] 2. No damage and no chemical consumption.
[0070] Soxhlet extraction requires the use of organic solvents such as hexane and petroleum ether, posing risks of flammability and explosion, as well as chemical pollution, and causing irreversible damage to the sample. This technology, based on non-invasive optical imaging, requires no sample destruction, uses no chemical reagents, and is safe, pollution-free, and environmentally friendly, allowing for sample retention and repeated testing.
[0071] 3. Low barrier to entry.
[0072] Traditional methods require professionals to strictly adhere to national standard procedures, placing high demands on personnel skills and environmental conditions. This technology, on the other hand, only requires the meat and bone meal sample to be evenly spread and images to be acquired in a standardized manner to complete the test. It requires no complex pretreatment or specialized chemical operations, and can be quickly mastered by ordinary operators, making it a low-barrier-to-entry technique.
[0073] 4. Low cost.
[0074] Soxhlet extraction requires consumables and has high long-term operating costs, while near-infrared spectroscopy requires expensive instruments. This technology only requires an imaging device and a computer for model operation, with low equipment costs, no consumables, and can be deployed on-site and operated remotely, making it suitable for continuous screening of large batches of samples.
[0075] In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments. The computer device can be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device stores data to be processed. The I / O interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communicating with an external terminal via a network connection. When the computer program is executed by the processor, it implements the above-described methods.
[0076] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0077] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0078] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0079] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by hardware related to computer program instructions. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0080] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0081] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0082] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for measuring the fat content of meat and bone meal, characterized in that, include: S1. After the meat and bone meal is crushed, dried and degreased, an oil solution is added to prepare meat and bone meal samples with different oil content gradients. The true oil content of each meat and bone meal sample is calculated by physicochemical determination, and a true oil content label is generated to obtain a labeled sample set. S2, according to the labeled sample set, each meat and bone meal sample is placed in a collection dish, shaken and spread evenly, and images are collected under preset lens distance and flash conditions. After clarity screening, an original image set is generated. S3, Based on the original image set, the images are normalized in size and data augmented, and divided according to a preset ratio to generate a training set, a validation set and a test set; S4. Based on the training set, validation set and test set, construct an improved ResNet50 model, and obtain a trained oil content prediction model by forward feature extraction and backward parameter optimization, and iteratively verify the deviation between the model output value and the real oil content label. S5. Obtain the target image of the meat and bone meal to be tested, input the target image into the trained oil content prediction model, and output the predicted value of the oil content of the meat and bone meal to be tested through backbone network feature extraction and enhanced regression prediction head calculation.
2. The method for measuring the fat content of meat and bone meal according to claim 1, characterized in that, S1 specifically includes: S11, the meat and bone meal is fully pulverized in a grinder and passed through a multi-mesh sieve, then dried in an oven and cooled to room temperature to obtain pretreated meat and bone meal; S12, the pretreated meat and bone meal is degreased by using n-hexane and then dried in a vacuum drying oven. The initial oil quality is determined by Soxhlet extraction to obtain the basic oil data. S13, Prepare an oil solution based on the basic oil data, and uniformly add the oil solution to the defatted meat and bone meal while stirring. After the addition is complete, continue stirring until fully dispersed. After evaporating the solvent under vacuum at 40°C and cooling to room temperature, meat and bone meal samples with different oil content gradients are prepared, and the labeled sample set is generated.
3. The method for measuring the fat content of meat and bone meal according to claim 2, characterized in that, The basic oil data in S12 is (m2-m1) / m×100%; where m1 is the constant weight of the empty extraction cup, m2 is the constant weight of the extraction cup and the fat, and m is the sample mass. S13 specifically includes: taking the lard produced during the preparation of meat and bone meal, melting it in a water bath at a set temperature, and adding n-hexane at 3 times the mass of the lard and stirring thoroughly to obtain the oil solution; Multiple oil content gradients were set up according to the oil content, and the oil solution was added to the weighed meat and bone meal. Multiple parallel samples were set up for each oil content gradient. The oil content of each meat and bone meal sample was determined again by Soxhlet extraction and recorded by numbering to form the true oil content label, thus obtaining a labeled sample set. S2 specifically includes: S21, Weigh 1g of meat and bone meal sample from the labeled sample set, place it in a ceramic dish, and shake the ceramic dish to make the meat and bone meal sample evenly distributed. S22, Set the lens to a set distance from the ceramic dish, adjust the focal length to completely include the meat and bone powder sample in the image acquisition frame, acquire the image, and obtain the initial captured image; S23, Perform S21-S22 on meat and bone meal samples with each fat content gradient, take multiple duplicate photos, remove shaky and blurry photos from the initial images, and select clear photos to form the original image set; S3 specifically includes: S31, group and name the images in the original image set, and associate each image name with the corresponding real oil content label to obtain a mapped image set; S32, batch scale the images in the mapped image set to a set size and perform standardization processing to obtain a standardized image set; S33, randomly crop, rotate, flip and color jitter the images used for training in the standardized image set to generate enhanced training images, and only perform center cropping and standardization on the images used for verification and testing in the standardized image set to generate standard verification images. S34, the enhanced training images and the standard verification images are randomly allocated in an 8:1:1 ratio to generate the training set, verification set and test set.
4. The method for measuring the fat content of meat and bone meal according to claim 1, characterized in that, The S4 section describes the construction of an improved ResNet50 model, specifically including: S41, replace the 7×7 single convolutional layer of the ResNet50 model with two 3×3 convolutional stacked structures, and connect a batch normalization layer and a Mish activation function sequentially after each convolutional stack to generate a basic feature extraction layer; the Mish activation function Mish(x) is Mish(x)=x·tanh(ln(1+e x This function is used to perform a non-linear transformation on the input feature value x output by the convolution stack structure, retaining negative features and outputting the basic feature map. S42, for the basic feature extraction layer, the stride of the convolutional layer of the first residual block of Layer 4 in the backbone network of the ResNet50 model is adjusted from (2,2) to (1,1), and the stride of the downsampling module of the residual block is adjusted to (1,1) simultaneously. The downsampling operation of Layer 4 in the backbone network is canceled. Based on the forward propagation of the adjusted network, a backbone feature map that retains high-frequency texture features is generated, and an improved ResNet50 model is constructed.
5. The method for measuring the fat content of meat and bone meal according to claim 3, characterized in that, The construction of the improved ResNet50 in S4 also includes replacing the first residual block of Layer 3 and Layer 4 of the backbone network in the ResNet50 model with an MBM-BTNK module. S43, replace the conv2 layer of the first residual block of Layer 3 of the backbone network and the conv2 layer of the first residual block of Layer 4 of the backbone network with deformable convolutional layers with a kernel size of 3×3 and a stride of 1 to generate a deformable sampling layer. S44, based on the deformable convolutional layer, the sampling position is adaptively adjusted according to the irregular shape of the meat and bone meal particles, and the forward computation logic follows... The adaptive feature map is calculated and input into the next network layer; where, To output feature maps in The pixel value at the location, where R is the sampling grid of the standard convolution. p n This is the preset offset within the sampling grid. ( p n ) represents the kernel weights. x () represents the input feature map, Δ p n The deformable offset learned by the network m n The sampling weight mask learned by the network and m n The value range is [0,1]; The construction of the improved ResNet50 model in S4 also includes: inserting a CBAM attention mechanism module into the backbone network. S45, after the output of Layer 3 and Layer 4 of the backbone network, a CBAM attention mechanism module is inserted to obtain a two-level attention injection network. S46. Based on the dual-level attention injection network, the feature map is processed by adaptive average pooling and adaptive max pooling, and then input into a fully connected network consisting of two 1×1 convolutional layers. After processing by the Mish activation function, the channel attention weights are output through the Sigmoid function to obtain the channel attention-weighted feature map. S47, Based on the feature map after channel attention weighting, spatial attention weights are generated through convolution operation. The channel attention weights and spatial attention weights are multiplied with the original feature map to generate an oil feature enhancement map; the original feature map is the target image.
6. The method for measuring the fat content of meat and bone meal according to claim 5, characterized in that, The construction of the improved ResNet50 model in S4 also includes: constructing an enhanced regression prediction head; The predicted oil content output in S5 is specifically based on the enhanced regression prediction head: S51, the enhanced oil feature map is subjected to multi-scale feature fusion to obtain multi-scale fused features. The multi-scale fused features are input into the enhanced regression prediction head to output the predicted oil content of the meat and bone meal to be tested. The enhanced regression prediction head includes four fully connected layers connected in series. The first fully connected layer reduces the input dimension from 2048 to 1024 and connects the batch normalization layer, the Mish activation function, and the dropout layer with a dropout probability of 0.3 to obtain the first-level dimensionality reduction feature. The second fully connected layer reduces the dimension of the first-level dimensionality reduction feature from 1024 to 512 and connects the batch normalization layer, the Mish activation function, and the dropout layer with a dropout probability of 0.2 to obtain the second-level dimensionality reduction feature. The third fully connected layer reduces the dimension of the second-level dimensionality reduction feature from 512 to 128 and connects the batch normalization layer and the Mish activation function to obtain the third-level nonlinear feature. The fourth fully connected layer reduces the dimension of the third-level nonlinear feature from 128 to 1 and directly outputs the predicted oil content.
7. The method for measuring the fat content of meat and bone meal according to claim 1, characterized in that, In step S4, the deviation between the model output value and the actual oil content label is iteratively verified using an evaluation formula to obtain a trained oil content prediction model, specifically including: S48, input the validation set into the improved ResNet50 model, and based on the predicted values output by the model and the true oil content labels, through... Calculate the mean absolute error (MAE) and based on... Calculate the root mean square error (RMSE); where M is the total number of valid meat and bone meal samples in the validation set; and N is the number of samples in the test set. This represents the true label value of the fat content in the i-th meat and bone meal sample; The predicted fat content output by the improved ResNet50 model for the i-th meat and bone meal sample; S49, based on the predicted value, the actual oil content label, and the mean of the actual oil content labels in the test set. ,pass Calculate the coefficient of determination R 2 ; S50, based on the mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination... R 2 Construct a comprehensive loss function to guide the model's backpropagation in updating network weights; when the determination coefficients... R 2 When the mean absolute error (MAE) and root mean square error (RMSE) converge to a preset threshold range, training is stopped and the model parameters are fixed to generate the trained oil content prediction model.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the method for measuring the fat content of meat and bone meal according to any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method for measuring the fat content of meat and bone meal according to any one of claims 1-7.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the method for measuring the fat content of meat and bone meal according to any one of claims 1-7.