Lactation detection method, apparatus, electronic device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2026-08-11
AI Technical Summary
由于依赖人工检测和判定,容易出现数据录入错误和判定结果不一致,导致生乳检测的准确性和稳定性差,导致生乳的检测效率低
[0015]The present invention provides a raw milk detection method, apparatus, electronic device, and storage medium. It controls an image sensor to acquire images of the raw milk sample to be tested, obtaining a detection image of the sample. The detection image is then sent to an image processing device, which runs a raw milk detection model to process the image and generate a detection result for the raw milk sample. Based on the sample identifier of the raw milk sample, the device identifier of the image sensor, and the device identifier of the image processing device, a traceability identifier for the raw milk sample is generated. The traceability identifier and the detection result are then stored together. Since the raw milk detection model is obtained through machine learning of the detection images and judgment results of multiple tested raw milk samples, it achieves automated detection of raw milk samples without human intervention, reducing workload and replacing manual testing. It eliminates the need for manual data entry, removes the influence of human subjectivity on the detection results, improves the accuracy and stability of raw milk detection, and increases the efficiency of raw milk detection.
Smart Images

Figure CN122545486A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food processing technology, and in particular to a method, apparatus, electronic device, and storage medium for detecting raw milk. Background Technology
[0002] Raw milk, as the main raw material for dairy products, determines the quality of those products. Testing of raw milk includes sensory evaluation, physicochemical testing, contaminant testing, and microbiological testing. Sensory evaluation requires direct visual observation, while contaminant testing requires manually comparing the color of test strips with a colorimetric card, followed by manual recording of the results. Because of this reliance on manual testing and judgment, data entry errors and inconsistent results are prone to occur, leading to poor accuracy and stability in raw milk testing, and consequently, low testing efficiency.
[0003] Therefore, improving the efficiency of raw milk testing has become a pressing technical problem for the industry. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for detecting raw milk, addressing the technical problem of improving the efficiency of raw milk detection.
[0005] This invention provides a method for detecting raw milk, comprising: The image sensor is controlled to acquire images of the raw milk sample to be tested, thereby obtaining a detection image of the raw milk sample to be tested; The detected image is sent to an image processing device, which then runs a raw milk detection model to process the image and generate a detection result for the raw milk sample to be detected. The raw milk detection model is trained based on the detection images and judgment results of multiple previously detected raw milk samples. Based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device, a detection traceability identifier for the raw milk sample to be tested is generated. The traceability identifier and test results of the raw milk sample to be tested are associated and stored.
[0006] In some embodiments, sending the detected image to an image processing device, so that the image processing device runs a raw milk detection model to process the detected image and generate a detection result for the raw milk sample to be detected, includes: The detected image is input into the image preprocessing layer of the raw milk detection model to obtain the preprocessed image output by the image preprocessing layer; The preprocessed image is input into the image segmentation layer of the raw milk detection model to obtain the image segmentation result output by the image segmentation layer; the image segmentation result includes images of multiple sample recognition regions. The image segmentation results are input into the feature extraction layer of the raw milk detection model to obtain the image recognition features of each sample recognition region. The image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region. The feature comparison results of each sample identification region are input into the result output layer of the raw milk detection model to obtain the detection result of the raw milk sample to be tested.
[0007] In some embodiments, the image recognition features include wall-mounted recognition features, sediment recognition features, and color recognition features; the feature comparison results include wall-mounted comparison results, sediment comparison results, and color comparison results.
[0008] In some embodiments, the step of inputting the image recognition features of each sample recognition region into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region includes: The image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model, so that the feature comparison layer compares the similarity between the image recognition features of each sample recognition region and the image recognition features of the standard image, and determines the feature comparison result of each sample recognition region based on the similarity comparison result.
[0009] In some embodiments, the raw milk detection model is trained based on the following steps: Obtain the test results of the current raw milk sample to be tested; Determine the judgment result of the current raw milk sample to be tested; If the detection result is consistent with the judgment result, the detection image of the current raw milk sample to be detected is determined as a positive sample and added to the positive sample training set of the raw milk detection model; If the detection result is inconsistent with the judgment result, the detection image of the current raw milk sample to be detected is determined as a negative sample and added to the negative sample training set of the raw milk detection model. The raw milk detection model is trained based on the positive sample training set and the negative sample training set.
[0010] In some embodiments, training the raw milk detection model based on the positive sample training set and the negative sample training set includes: Training samples are randomly selected from the positive and negative training sets to incrementally train the raw milk detection model.
[0011] In some embodiments, the associated storage of the traceability identifier and the test result of the raw milk sample to be tested includes: A blockchain for raw milk testing and traceability was constructed based on a distributed computer system. The traceability identifier and test results of the raw milk sample to be tested are stored in the raw milk testing traceability blockchain.
[0012] This invention provides a raw milk detection device, comprising: The acquisition unit is used to control the image sensor to acquire images of the raw milk sample to be tested, and to obtain the detection image of the raw milk sample to be tested; The detection unit is used to send the detection image to the image processing device, so that the image processing device runs the raw milk detection model to process the detection image and generate the detection result of the raw milk sample to be detected; the raw milk detection model is trained based on the detection images and judgment results of multiple detected raw milk samples; The traceability unit is used to generate a detection traceability identifier for the raw milk sample to be tested based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device. The storage unit is used to associate and store the traceability identifier and test results of the raw milk sample to be tested.
[0013] The present invention provides an electronic 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 raw milk detection method.
[0014] The present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the raw milk detection method.
[0015] The present invention provides a raw milk detection method, apparatus, electronic device, and storage medium. It controls an image sensor to acquire images of the raw milk sample to be tested, obtaining a detection image of the sample. The detection image is then sent to an image processing device, which runs a raw milk detection model to process the image and generate a detection result for the raw milk sample. Based on the sample identifier of the raw milk sample, the device identifier of the image sensor, and the device identifier of the image processing device, a traceability identifier for the raw milk sample is generated. The traceability identifier and the detection result are then stored together. Since the raw milk detection model is obtained through machine learning of the detection images and judgment results of multiple tested raw milk samples, it achieves automated detection of raw milk samples without human intervention, reducing workload and replacing manual testing. It eliminates the need for manual data entry, removes the influence of human subjectivity on the detection results, improves the accuracy and stability of raw milk detection, and increases the efficiency of raw milk detection. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating the raw milk detection method provided by the present invention.
[0019] Figure 2 This is a schematic diagram of the raw milk detection model provided by the present invention.
[0020] Figure 3 This is a schematic diagram of the raw milk detection device provided by the present invention.
[0021] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first," "second," etc., used in this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps, units, or modules is not necessarily limited to those explicitly listed, but may include other steps, units, or modules not explicitly listed or inherent to such processes, methods, products, or devices.
[0024] In related technologies, sensory testing of raw milk involves manually observing the color of the sample and reagent reaction with the naked eye, while contaminant testing involves manually comparing the tested test strips with the colorimetric card, entering the results and submitting them. It is impossible for the same or different personnel to make consistent judgments for each result, and the results report requires visual judgment. Manual entry of test results is inefficient and prone to errors.
[0025] In order to address the shortcomings of related technologies, Figure 1 This is a schematic flowchart of the raw milk detection method provided by the present invention, as shown below. Figure 1 As shown, the method includes steps 110, 120, 130 and 140.
[0026] Step 110: Control the image sensor to acquire images of the raw milk sample to be tested, and obtain the detection image of the raw milk sample to be tested.
[0027] Specifically, the raw milk detection method provided in this embodiment of the invention is executed by a raw milk detection device. This device can be implemented in software, such as a raw milk detection program or interface software; or it can be implemented in hardware, such as a computer or server that executes the raw milk detection method.
[0028] The raw milk testing device can communicate with external systems, for example, using UDP (User Datagram Protocol). The external system can control a robotic arm to place the raw milk sample to be tested into the detection area of the vision system, which then performs the detection and transmits the results back to the external system.
[0029] Raw milk refers to the unprocessed milk produced by healthy dairy animals, without any alteration of its composition or addition of exogenous substances. Testing the relevant properties of raw milk is an important means of ensuring its quality and safety. The raw milk sample to be tested refers to a representative sample obtained after sampling the raw milk.
[0030] The raw milk detection device can include two parts: an image sensor and an image processing device. The image sensor and image processing device can be integrated or separate. They can be interconnected via a wireless network or a wired cable.
[0031] The image sensor can be a camera, used to acquire images of the raw milk sample to be tested and generate a test image of the raw milk sample.
[0032] Step 120: Send the detection image to the image processing device so that the image processing device runs the raw milk detection model to process the detection image and generate the detection result of the raw milk sample to be detected; the raw milk detection model is trained based on the detection images and judgment results of multiple detected raw milk samples.
[0033] Specifically, after the image sensor acquires the detection image, the detection image can be sent to an image processing device. The image processing device can be a server or a computer that executes image processing algorithms.
[0034] Machine learning can be used to extract and learn features from the images being tested, thus determining the test results for the raw milk sample. These results can include sensory evaluation items such as residue, sediment, and color, or color chart comparison results from contaminant testing.
[0035] A raw milk detection model can be built using a neural network as the initial model. The neural network can be a convolutional neural network, a recurrent neural network, a generative adversarial network, or an attention mechanism network, etc. The raw milk sample being tested is one that has already been tested. The judgment result is determined by professional inspectors through manual testing of the raw milk sample. A large number of images of tested raw milk samples can be collected as training samples. The judgment results of each tested raw milk sample can be used as sample labels to train the initial model, improving its feature learning ability and predictive ability, ultimately resulting in a raw milk detection model.
[0036] The raw milk detection model can be deployed on an image processing device. When a detection image is input into the image processing device, the device can run the raw milk detection model to process the image and generate the detection results for the raw milk sample to be tested.
[0037] Step 130: Based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device, generate the detection traceability identifier of the raw milk sample to be tested.
[0038] Specifically, the sample label is used to uniquely identify the raw milk sample in the sample bottle, facilitating its identification, tracking, and management. The sample label can be in the form of a QR code for easy image recognition or a barcode for machine scanning. The sample label can carry relevant information to determine the testing items required for the raw milk sample in the current sample bottle.
[0039] Equipment identification is used to uniquely identify testing equipment (including image sensors and image processing equipment). Testing traceability identification is used to trace relevant information about raw milk samples during the testing process. For example, equipment identification codes can be added sequentially after the sample identification to generate testing traceability identifications. This can be used to trace the testing process of raw milk, improving the transparency, traceability, and verifiability of information for each item during testing, tracking and recording data for each testing item in real time, helping to identify potential quality problems, improving the management efficiency of testing operations, and fundamentally improving the quality and safety of raw milk.
[0040] Step 140: Link and store the traceability identifier and test results of the raw milk sample to be tested.
[0041] Specifically, the test results and traceability identifiers of the raw milk samples to be tested are linked and stored, which can be stored on a server or in the cloud for relevant systems to query and trace.
[0042] The raw milk detection method provided in this invention involves controlling an image sensor to acquire images of the raw milk sample to be tested, obtaining a detection image of the raw milk sample; sending the detection image to an image processing device, which then runs a raw milk detection model to process the detection image and generate a detection result for the raw milk sample; generating a detection traceability identifier for the raw milk sample based on the sample identifier of the raw milk sample, the device identifier of the image sensor, and the device identifier of the image processing device; and storing the detection traceability identifier and the detection result together. Since the raw milk detection model is obtained through machine learning of the detection images and judgment results of multiple tested raw milk samples, it achieves automated detection of raw milk samples without human intervention, reducing workload and replacing manual detection of raw milk samples. It eliminates the need for manual data entry, removes the influence of human subjectivity on the detection results, provides accuracy and stability for raw milk detection, and improves the efficiency of raw milk detection.
[0043] It should be noted that each embodiment of the present invention can be freely combined, rearranged, or executed individually, and does not need to rely on or depend on a fixed execution order.
[0044] In some embodiments, the detection image is sent to an image processing device, which then runs a raw milk detection model to process the image and generate a detection result for the raw milk sample to be detected, including: The detected image is input into the image preprocessing layer of the raw milk detection model to obtain the preprocessed image output by the image preprocessing layer; The preprocessed image is input into the image segmentation layer of the raw milk detection model to obtain the image segmentation result output by the image segmentation layer; the image segmentation result includes images of multiple sample recognition regions. The image segmentation results are input into the feature extraction layer of the raw milk detection model to obtain the image recognition features of each sample recognition region. The image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region. The feature comparison results of each sample identification region are input into the output layer of the raw milk detection model to obtain the detection results of the raw milk sample to be tested.
[0045] Specifically, Figure 2 This is a schematic diagram of the raw milk detection model provided by the present invention, as shown below. Figure 2 As shown, the raw milk detection model includes an image preprocessing layer 210, an image segmentation layer 220, a feature extraction layer 230, a feature comparison layer 240, and a result output layer 250 connected in sequence.
[0046] The detection image is input into the image preprocessing layer, which performs image denoising and enhancement. The purpose of image preprocessing is to provide clearer and more reliable input for subsequent image analysis, feature extraction, and machine learning tasks by improving image quality, extracting useful features, removing noise, and enhancing image contrast. Different application scenarios may choose different preprocessing methods to improve the effectiveness and accuracy of image processing. After processing the detection image, the image preprocessing layer produces the preprocessed image.
[0047] The preprocessed image is input into the image segmentation layer, which segments the image, separating different regions. The final image segmentation result contains multiple regions, each representing a sample recognition region. Segmenting the image into multiple sample recognition regions allows for fine-grained detection and recognition, improving the accuracy of the detection results.
[0048] The image segmentation results are input into the feature extraction layer, which extracts features from the images of each sample recognition region to obtain the image recognition features of each sample recognition region. Image recognition features can include color features, texture features, edge features, and shape features, etc. Each recognition region in the image can be accurately processed, thereby achieving efficient detection of raw milk samples.
[0049] For example, convolution operations in convolutional neural networks can be used to extract image recognition features. The size of the feature map after convolution can be expressed as: N = (W - F + 2P) / S + 1. W is the width (or height, assuming the input image is square) of the input image or feature map. F is the width (or height) of the convolution kernel. P is the padding size, i.e., the number of layers of zeros added around the input image. S is the stride, i.e., the distance the convolution kernel slides across the input image.
[0050] Image recognition features of each sample identification region are input into the feature comparison layer to obtain the feature comparison results for each sample identification region. The feature comparison layer compares the image recognition features of the sample identification region with the image recognition features of a standard image to determine the feature comparison result. The feature comparison result represents the degree of similarity between the sample identification region image and the standard image. For example, comparing the color features of the sample identification region with the color features of the standard image determines whether the sample color matches the color in the standard image based on the feature similarity. The standard image can be selected according to the actual situation. For example, in sensory testing, the standard image can be an image of qualified raw milk; in contaminant testing, the standard image can be an image of raw milk containing different concentrations of contaminants.
[0051] The feature comparison results of each sample's identification region are input into the output layer to obtain the detection result of the raw milk sample to be tested. The output layer can summarize the feature comparison results of each sample's identification region to obtain the feature comparison result of the entire detection image, thereby determining the detection result of the raw milk sample to be tested. For example, the number of sediments in the feature comparison results of each sample's identification region can be accumulated to obtain the total number of sediments in the entire detection image.
[0052] In the output layer, the ReLU activation function ReLU(x) = max(0,x) can be used. Negative input values are set to zero, and positive values are retained to obtain the calculated result. This result is then compared with the previously simulated result; a smaller result indicates a negative (normal) result, while a larger result indicates a positive (abnormal) result.
[0053] The raw milk detection method provided in this embodiment of the invention includes an image preprocessing layer, an image segmentation layer, a feature extraction layer, a feature comparison layer, and a result output layer. By processing the detection image through each layer, the accuracy of raw milk detection is improved.
[0054] In some embodiments, the image recognition features include wall-mounted recognition features, sediment recognition features, and color recognition features; the feature comparison results include wall-mounted comparison results, sediment comparison results, and color comparison results.
[0055] Specifically, image recognition features include adhesion recognition features, sediment recognition features, and color recognition features. Adhesion recognition features are mainly used to identify whether adhesion occurs after raw milk reacts with relevant reagents. Sediment recognition features are mainly used to identify the presence of sediment in raw milk. Color recognition features are mainly used to identify the color of raw milk or the color of contaminant test strips.
[0056] Accordingly, the feature comparison results can include wall adhesion comparison results, sediment comparison results, and color comparison results, which correspond one-to-one with the image recognition features.
[0057] The raw milk detection method provided in this invention can identify adhering substances, sediment, and color, thereby improving the accuracy and comprehensiveness of raw milk detection.
[0058] In some embodiments, the image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region, including: The image recognition features of each sample identification region are input into the feature comparison layer of the raw milk detection model. The feature comparison layer compares the similarity of the image recognition features of each sample identification region with the image recognition features of the standard image. Based on the similarity comparison results, the feature comparison result of each sample identification region is determined.
[0059] Specifically, the feature comparison layer is used to compare the similarity between the image recognition features of each sample recognition region and the image recognition features of the standard image. Methods for feature similarity comparison can include Euclidean distance, Manhattan distance, and cosine similarity. Finally, the feature comparison result for each sample recognition region is determined based on the similarity comparison result. For example, if the similarity comparison result is greater than a preset threshold, the image of the sample recognition region is considered similar to the feature comparison result of the standard image.
[0060] The raw milk detection method provided in this invention achieves image comparison through feature similarity comparison, replacing manual detection of raw milk samples, eliminating the influence of human subjectivity on the detection results, and improving the accuracy of raw milk detection.
[0061] In some embodiments, the raw milk detection model is trained based on the following steps: Obtain the test results of the current raw milk sample to be tested; Determine the judgment result of the current raw milk sample to be tested; If the detection result is consistent with the judgment result, the detection image of the current raw milk sample to be detected is determined as a positive sample and added to the positive sample training set of the raw milk detection model; If the detection results are inconsistent with the judgment results, the detection image of the current raw milk sample to be tested is identified as a negative sample and added to the negative sample training set of the raw milk detection model. The raw milk detection model was trained using positive and negative sample training sets.
[0062] Specifically, the training methods for raw milk detection models include pre-training and incremental training. Pre-training refers to initial training with a large amount of data before fully training the model, so that the model can learn basic knowledge and features. Pre-training is usually performed on deep learning models (such as neural networks). Incremental training means that when the model receives new data, it does not need to retrain on all the data, but gradually updates its knowledge.
[0063] For the raw milk sample to be tested, the test result is the prediction obtained by the raw milk detection model after image processing. The judgment result is obtained by the inspectors through manual inspection. It can be assumed that the accuracy of the judgment result is higher than that of the test result.
[0064] If the test result matches the judgment result, the test result of the current raw milk sample can be considered correct, and it can be used as a positive sample, with the test result as the sample label, and added to the positive sample training set of the raw milk detection model. If the test result does not match the judgment result, the test result of the current raw milk sample can be considered incorrect, and it can be used as a negative sample, with the test result as the sample label, and added to the negative sample training set of the raw milk detection model.
[0065] The raw milk detection method provided in this invention trains the raw milk detection model using positive and negative sample training sets. This not only helps the model understand category features and improves generalization ability, but also avoids overfitting and enhances robustness, thereby improving the model's application effect in real-world scenarios.
[0066] In some embodiments, the raw milk detection model is trained based on a positive sample training set and a negative sample training set, including: Training samples are randomly drawn from the positive and negative training sets to incrementally train the raw milk detection model.
[0067] Specifically, a certain number of samples are randomly drawn from both the positive and negative training sets. Sampling strategies can include uniform sampling and weighted sampling. Uniform sampling involves drawing the same number of samples from both the positive and negative sets. Weighted sampling, on the other hand, involves setting different sampling probabilities based on the imbalance between the positive and negative samples (e.g., increasing the sampling probability of negative samples and decreasing the sampling probability of positive samples) to ensure a reasonable distribution of the training samples.
[0068] The incremental training process includes: training on randomly selected training samples and updating model parameters; evaluating the model's performance on the validation set to check for overfitting or underfitting; and adjusting hyperparameters such as the learning rate and batch size as needed. This process is repeated multiple times, with new training samples randomly selected for incremental training, until training termination conditions are met (such as reaching the maximum number of training iterations or error convergence).
[0069] The raw milk detection method provided in this invention improves the generalization and adaptability of the model while ensuring efficient training by randomly selecting training samples from the positive and negative sample training sets and incrementally training the model.
[0070] In some embodiments, the traceability identifier of the raw milk sample to be tested and the test results are stored together, including: A blockchain for raw milk testing and traceability was constructed based on a distributed computer system. The traceability identifier and test results of the raw milk sample to be tested are stored in the raw milk testing traceability blockchain.
[0071] Specifically, a distributed computer system refers to a computing system that connects multiple computers (as nodes) together to collaboratively complete computing tasks.
[0072] A blockchain for raw milk testing and traceability can be built using a distributed computer system to trace the testing process of raw milk, thereby improving product transparency, ensuring food safety, and enhancing consumer trust. Blockchain technology, especially in the traceability field, can provide tamper-proof records, decentralized verification mechanisms, and real-time data updates, thus ensuring the accuracy and reliability of traceability information.
[0073] In terms of blockchain type, you can choose public blockchains, private blockchains, or consortium blockchains. Private blockchains can guarantee data privacy while allowing control over participating nodes (like a processing plant). Consortium blockchains can have multiple processing plants participating, ensuring data sharing and transparency. Public blockchains, on the other hand, are open to all users, including consumers, which can enhance consumer trust.
[0074] In the blockchain's node design, each participant involved in the raw milk testing process can be a blockchain node. Each node stores its own data and participates in the block generation and verification process. Nodes collaborate to ensure the reliability and security of data on the blockchain.
[0075] After the test results and traceability labels of raw milk samples are uploaded to the blockchain, a wide range of users, including consumers and producers, can clearly trace the source to the specific testing process through the traceability labels.
[0076] The raw milk testing method provided in this invention stores the test results and traceability identifiers of raw milk samples in a raw milk testing traceability blockchain, enabling transparent, real-time monitoring and data recording of the entire raw milk testing process. Blockchain provides the immutable and decentralized characteristics of raw milk testing traceability, allowing all participants (consumers, regulatory authorities, manufacturers, etc.) to trust and verify traceability data, thereby effectively improving product quality and food safety levels.
[0077] Based on the above embodiments, the raw milk detection method provided by the present invention can be implemented through vision system software.
[0078] The method of using a vision system to determine sample status first involves preparing several sets of negative (normal) and positive (abnormal) control samples. The vision software memorizes their respective states, noting the differences in their states (precipitate, wall adhesion, color, etc.). After obtaining the corresponding parameters for precipitate, wall adhesion, and color, the vision system records the amount of precipitate, wall adhesion, and color, establishing a basic judgment standard. After the next inspection, the vision system takes a picture for judgment and returns the result to the inspector. If an error occurs, the vision software re-identifies the situation at the time of the photograph, re-identifies the quantity or color of that set, records it in the corresponding parameter data, and modifies the quantity parameters accordingly.
[0079] The vision system software has implemented an automated process for result judgment and output. Therefore, when a task is received, it is necessary to ensure that it is in an open state. After being opened, the main interface displays photos of the sensory results of all detection items. The vision system software will train the model based on the sample data collected from this interface, and analyze and judge the image through the trained model. Manual training methods can also be adopted.
[0080] The user interface of the vision system software can be divided into left and right screens. The left screen is the workflow page, where you can view the inspection status of all items, including the inspection items, inspection time, result issuance status, and whether the entire inspection step has been completed. Select the item you want to view on the workflow page. The right screen contains the tools. The tools section displays more detailed information about this item, including the corresponding vision method; if images are involved, the image size can also be identified. Clicking the plus button at the bottom of the workflow page allows you to add other workflows, facilitating the addition of new judgment items later.
[0081] In the tools interface, select the sample you want to view, and click the "Open File" button. After clicking, you can view the sensory image of the sample. The image acquisition interface also shows the saved path of the image file and the specific camera used, facilitating traceability. Clicking the "Run" button helps the vision system learn. You can also upload images to a folder, select the corresponding image by clicking the image file, and then click the "Run" button below. The system will then evaluate the sample. At this point, you can manually confirm whether the evaluation is correct. If the evaluation is incorrect, the vision inspection software will record this result and modify the corresponding parameters for future evaluation.
[0082] By setting parameters and collecting sample data during daily inspections, the model is trained to help the vision system learn actively. It can also be trained manually to automate the result interpretation process, ensuring consistency in result interpretation, reducing human error, and lowering the error rate. It also integrates well with the software of the existing system to achieve data interaction and timely and accurate results without the need for manual entry.
[0083] The apparatus provided in the embodiments of the present invention will be described below. The apparatus described below can be referred to in correspondence with the method described above.
[0084] Figure 3 This is a schematic diagram of the raw milk detection device provided by the present invention, as shown below. Figure 3 As shown, the device includes: The acquisition unit 310 is used to control the image sensor to acquire images of the raw milk sample to be tested, and to obtain the detection image of the raw milk sample to be tested; The detection unit 320 is used to send the detection image to the image processing device, so that the image processing device runs the raw milk detection model to process the detection image and generate the detection result of the raw milk sample to be detected; the raw milk detection model is trained based on the detection images and judgment results of multiple detected raw milk samples; The traceability unit 330 is used to generate a detection traceability identifier for the raw milk sample to be tested based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device. Storage unit 340 is used to associate and store the traceability identifier and test results of the raw milk sample to be tested.
[0085] The raw milk testing device provided in this invention controls an image sensor to acquire images of raw milk samples to be tested, obtaining test images of the raw milk samples; the test images are sent to an image processing device, which then runs a raw milk testing model to process the test images and generate test results for the raw milk samples; based on the sample identifier of the raw milk samples to be tested, the device identifier of the image sensor, and the device identifier of the image processing device, a traceability identifier for the raw milk samples to be tested is generated; the traceability identifier for the raw milk samples to be tested and the test results are associated and stored; since the raw milk testing model is obtained by machine learning from the test images and judgment results of multiple tested raw milk samples, it realizes automated testing of raw milk samples without human intervention, reducing the workload of personnel, replacing manual testing of raw milk samples, eliminating the need for manual data entry, eliminating the influence of human subjectivity on the test results, providing accuracy and stability of raw milk testing, and improving the efficiency of raw milk testing.
[0086] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communications bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communications bus 440. The processor 410 can call logical commands stored in the memory 430 to execute the methods described in the above embodiments, for example: The system controls the image sensor to acquire images of the raw milk sample to be tested, obtaining a detection image of the raw milk sample; the detection image is sent to the image processing device, which then runs the raw milk detection model to process the detection image and generate the detection result of the raw milk sample to be tested; the raw milk detection model is trained based on the detection images and judgment results of multiple tested raw milk samples; based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device, a detection traceability identifier of the raw milk sample to be tested is generated; the detection traceability identifier of the raw milk sample to be tested and the detection result are associated and stored.
[0087] Furthermore, when the logical commands in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several commands to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0088] The processor in the electronic device provided in this embodiment of the invention can call logical instructions in the memory to implement the above method. Its specific implementation method is the same as the aforementioned method implementation method and can achieve the same beneficial effects, which will not be repeated here.
[0089] This invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the methods provided in the above embodiments.
[0090] The specific implementation method is the same as the aforementioned method implementation method and can achieve the same beneficial effects, so it will not be repeated here.
[0091] This invention provides a computer program product, including a computer program that, when executed by a processor, implements the method described above.
[0092] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0093] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting raw milk, characterized in that, include: The image sensor is controlled to acquire images of the raw milk sample to be tested, thereby obtaining a detection image of the raw milk sample to be tested; The detected image is sent to an image processing device, which then runs a raw milk detection model to process the image and generate a detection result for the raw milk sample to be detected. The raw milk detection model is trained based on the detection images and judgment results of multiple previously detected raw milk samples. Based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device, a detection traceability identifier for the raw milk sample to be tested is generated. The traceability identifier and test results of the raw milk sample to be tested are associated and stored.
2. The method for detecting raw milk according to claim 1, characterized in that, The step of sending the detected image to an image processing device, so that the image processing device runs a raw milk detection model to process the detected image and generate the detection result of the raw milk sample to be detected, includes: The detected image is input into the image preprocessing layer of the raw milk detection model to obtain the preprocessed image output by the image preprocessing layer; The preprocessed image is input into the image segmentation layer of the raw milk detection model to obtain the image segmentation result output by the image segmentation layer; the image segmentation result includes images of multiple sample recognition regions. The image segmentation results are input into the feature extraction layer of the raw milk detection model to obtain the image recognition features of each sample recognition region. The image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region. The feature comparison results of each sample identification region are input into the result output layer of the raw milk detection model to obtain the detection result of the raw milk sample to be tested.
3. The raw milk detection method according to claim 2, characterized in that, The image recognition features include wall-mounted recognition features, sediment recognition features, and color recognition features; the feature comparison results include wall-mounted comparison results, sediment comparison results, and color comparison results.
4. The method for detecting raw milk according to claim 2, characterized in that, The step of inputting the image recognition features of each sample recognition region into the feature comparison layer of the raw milk detection model to obtain the feature comparison results of each sample recognition region includes: The image recognition features of each sample recognition region are input into the feature comparison layer of the raw milk detection model, so that the feature comparison layer compares the similarity between the image recognition features of each sample recognition region and the image recognition features of the standard image, and determines the feature comparison result of each sample recognition region based on the similarity comparison result.
5. The method for detecting raw milk according to claim 1, characterized in that, The raw milk detection model was trained based on the following steps: Obtain the test results of the current raw milk sample to be tested; Determine the judgment result of the current raw milk sample to be tested; If the detection result is consistent with the judgment result, the detection image of the current raw milk sample to be detected is determined as a positive sample and added to the positive sample training set of the raw milk detection model; If the detection result is inconsistent with the judgment result, the detection image of the current raw milk sample to be detected is determined as a negative sample and added to the negative sample training set of the raw milk detection model. The raw milk detection model is trained based on the positive sample training set and the negative sample training set.
6. The method for detecting raw milk according to claim 5, characterized in that, The training of the raw milk detection model based on the positive sample training set and the negative sample training set includes: Training samples are randomly selected from the positive and negative training sets to incrementally train the raw milk detection model.
7. The method for detecting raw milk according to claim 1, characterized in that, The process of associating and storing the traceability identifier and test results of the raw milk sample to be tested includes: A blockchain for raw milk testing and traceability was constructed based on a distributed computer system. The traceability identifier and test results of the raw milk sample to be tested are stored in the raw milk testing traceability blockchain.
8. A raw milk detection device, characterized in that, include: The acquisition unit is used to control the image sensor to acquire images of the raw milk sample to be tested, and to obtain the detection image of the raw milk sample to be tested; The detection unit is used to send the detection image to the image processing device, so that the image processing device runs the raw milk detection model to process the detection image and generate the detection result of the raw milk sample to be detected; the raw milk detection model is trained based on the detection images and judgment results of multiple detected raw milk samples; The traceability unit is used to generate a detection traceability identifier for the raw milk sample to be tested based on the sample identifier of the raw milk sample to be tested, the device identifier of the image sensor, and the device identifier of the image processing device. The storage unit is used to associate and store the traceability identifier and test results of the raw milk sample to be tested.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the raw milk detection method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the raw milk detection method according to any one of claims 1 to 7.