A method for detecting fertilizer particles based on small sample learning

Through the twin network model and industrial cameras based on small sample learning, intelligent monitoring of fertilizer particles is realized, which solves the problems of labor time and safety hazards in the traditional fertilizer granulation process, and improves detection efficiency and safety.

CN118429728BActive Publication Date: 2024-09-27HEFEI INSTITUTE OF PHYSICAL SCIENCE CHINESE ACADEMY OF SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410881242.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-27
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

The traditional fertilizer granulation process relies on naked eye observation, which is time-consuming and labor-intensive, and long-term exposure of workers to chemical gases may lead to ammonia poisoning, which poses safety hazards and low efficiency.

Method used

Adopt a fertilizer particle detection method based on small sample learning, use twin network models and industrial cameras to capture images of fertilizer particles, perform image preprocessing through the weighted average method and sharpening filtering, build an image pair data set, and train the model to identify qualified and unqualified particles to achieve unmanned intelligent monitoring.

Benefits of technology

It reduces labor costs, improves the safety of the working environment, realizes efficient and intelligent monitoring of fertilizer particles, avoids the potential harm of ammonia poisoning of workers, and overcomes the problem of data imbalance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118429728B
    Figure CN118429728B
Patent Text Reader

Abstract

The invention discloses a fertilizer particle detection method based on small sample learning, which relates to the field of artificial intelligence technology. A fertilizer particle image containing fertilizer particles and a reference standard image set are sent to a trained twin network model, and similarity scores between the fertilizer particle image and a qualified reference standard image and an unqualified reference standard image are output; weighted similarities are calculated for all similarity scores obtained; and the obtained weighted similarities are compared with preset qualified thresholds and unqualified thresholds for difference. If #imgabs0#, it is judged that the fertilizer particles corresponding to the fertilizer particle image to be detected are qualified; if #imgabs1#, it is judged that the fertilizer particles corresponding to the fertilizer particle image to be detected are unqualified. The fertilizer particle detection method realizes unmanned and intelligent fertilizer particle monitoring, which not only reduces labor costs but also improves safety.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a fertilizer particle detection method based on small sample learning. Background Art

[0002] With the development of science and technology, factory production methods have shifted from mechanization to automation and intelligence. Fertilizer plays an important role in crop growth, so the granulation size of fertilizer has become a key factor affecting the final quality. The amino acid granulation process is a common fertilizer production process. Through chemical reactions in a drum granulator, sulfuric acid, ammonia, monoammonium phosphate, sulfuric acid and raw materials such as urea, potassium chloride, and distilled water are converted into small fertilizer particles. However, the traditional amino acid granulation process requires technical workers to observe the material state and fertilizer in the granulator at close range to determine whether the amount of water vapor added is appropriate and adjust the added water vapor. This method that relies on naked eye observation is time-consuming and labor-intensive, and chemical gases emitted during the fertilizer granulation process, such as ammonia, may cause workers to suffer from ammonia poisoning. Summary of the invention

[0003] Based on the technical problems existing in the background technology, the present invention proposes a fertilizer particle detection method based on small sample learning, which not only reduces the labor cost but also improves the safety of the working environment.

[0004] The present invention proposes a fertilizer particle detection method based on small sample learning, which is used to judge whether the fertilizer particles are qualified. The method is characterized in that a fertilizer particle image containing fertilizer particles and a reference standard image set are sent to a trained twin network model, wherein the reference standard image set includes qualified reference standard images and unqualified reference standard images, and similarity scores between the fertilizer particle image and the qualified reference standard image and the unqualified reference standard image are output;

[0005] Calculate weighted similarity for all similarity scores obtained based on weights corresponding to qualified reference standard images and unqualified reference standard images;

[0006] The obtained weighted similarity is compared with the preset qualified threshold and unqualified threshold respectively. , then the fertilizer particles corresponding to the fertilizer particle image to be detected are judged to be qualified. , then the fertilizer particles corresponding to the fertilizer particle image to be detected are judged to be unqualified, where represents the difference between the weighted similarity and the qualified threshold, represents the difference between the weighted similarity and the disqualified threshold;

[0007] The main structure of the twin network model is a ResNet50 structure that has been pre-trained with a large data set. After removing the last fully connected layer of the ResNet50 structure, all remaining layers are frozen, and then the pooling layer and the comparison layer are sequentially connected to the output end of the ResNet50 structure with the fully connected layer removed.

[0008] The training process of the twin network model is as follows:

[0009] S1, acquiring a plurality of fertilizer particle images and preprocessing them, and using the preprocessed fertilizer particle images as a fertilizer particle image dataset;

[0010] S2. construct an image pair dataset based on the fertilizer particle image dataset, wherein the image pair dataset includes a plurality of positive sample image pairs and a plurality of negative sample image pairs, wherein the positive sample image pair is a combination of two images with the same attributes selected from the fertilizer particle image dataset, and the negative sample image pair is a combination of two images with different attributes selected from the fertilizer particle image dataset;

[0011] S3, input the positive sample image pair or the negative sample image pair in the image pair dataset into the twin network model, perform feature extraction based on the ResNet50 structure, and obtain the corresponding two image features respectively;

[0012] S4, after the two image features are pooled by the pooling layer, they enter the comparison layer to calculate the similarity and generate similarity scores respectively;

[0013] S5. According to the labels and similarity scores corresponding to the two image features, the hierarchical dynamic similarity loss function is applied to calculate the loss of the twin network model, and the model parameters of the twin network model are updated through the optimization algorithm.

[0014] Furthermore, the hierarchical dynamic similarity loss function The details are as follows:

[0015]

[0016] in, is the number of image pairs in the image pair dataset in the batch. The image pairs in the image pair dataset are the general term for the mixture of positive sample image pairs and negative sample image pairs. Represents the image pair in the dataset The labels of the image pairs, is the similarity score between the two images of an image pair in the image pair dataset, and are the loss functions for similar image pairs and dissimilar image pairs, respectively. and Respectively represent the thresholds of similar sample pairs and dissimilar sample pairs, is a hyperparameter used to balance the regularization term impact.

[0017] Furthermore, after the training of the twin network model is completed, it is verified through the fertilizer particle image verification dataset. The specific verification process is as follows:

[0018] Acquire multiple fertilizer particle images and preprocess them to obtain a fertilizer particle image verification dataset, and construct an image pair verification dataset based on the fertilizer particle image verification dataset;

[0019] Input a group of image combinations in the positive sample verification image pair or a group of image combinations in the negative sample verification image pair in the image pair verification data set into the trained twin network model, and output the predicted classification results of the fertilizer particles;

[0020] If the predicted classification results of the fertilizer particles always deviate from the actual classification results of the fertilizer particles, the frozen ResNet50 structure will be unfrozen layer by layer from the top layer, and the unfrozen twin network models will be trained and verified in sequence by reducing the learning rate until the performance of the twin network model no longer improves.

[0021] Further, in step S1, a plurality of fertilizer particle images are obtained and preprocessed as follows:

[0022] S11, using a weighted average method to assign different weight values ​​to the three channels RGB of the same pixel position of the obtained fertilizer particle image, specifically:

[0023]

[0024] in, Represents the calculated grayscale value of the pixel position, Indicates the red component value of the pixel position; Indicates the green component value of the pixel position; Indicates the blue component value of the pixel position;

[0025] S12, using a sharpening filter to filter the grayscale processed fertilizer particle image to obtain a preprocessed fertilizer particle image.

[0026] Further, in step S12, the sharpening filter operation uses a predefined filter kernel, and the filter kernel is configured to enhance the edge of the image, wherein the predefined filter kernel is a 3x3 filter matrix, the central element of the filter matrix is ​​a positive value, and the surrounding elements are negative values, and the predefined filter kernel is specifically the following filter matrix:

[0027]

[0028] The fertilizer particle images after filtering are stored and used as preprocessed fertilizer particle images to construct a fertilizer particle image dataset.

[0029] The advantages of the fertilizer particle detection method based on small sample learning provided by the present invention are: the fertilizer particle detection method based on small sample learning provided in the structure of the present invention uses an industrial camera to regularly shoot images of fertilizer particles in the production process, an industrial computer reads the RGB image of the industrial camera, and then uses the weighted average method to grayscale the RGB image; then sharpening filtering is performed to highlight the image features; then an image pair data set is constructed based on the existing fertilizer particle image data set, thereby overcoming the data imbalance problem caused by the scarcity of unqualified samples; then the twin network model is trained to obtain weights; finally, the trained twin network model is used to identify and monitor fertilizer particles, and the monitoring results are fed back and uploaded; this non-contact monitoring method realizes unmanned and intelligent fertilizer particle monitoring, which not only reduces labor costs, but also avoids the potential harm of ammonia poisoning to workers caused by long-term inhalation of air mixed with ammonia, thereby improving safety. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 is a flow chart of the fertilizer particle detection method;

[0031] Figure 2 It is a structural flow chart of the detection system;

[0032] Figure 3 Schematic diagram of the structure and training strategy of the twin network model;

[0033] Figure 4 Schematic diagram of fertilizer particle image preprocessing;

[0034] Figure 5 This is the training flow chart of the twin network model;

[0035] Figure 6 This is a flow chart for the detection system’s judgment on the eligibility of chemical particles. DETAILED DESCRIPTION

[0036] Below, the technical solution of the present invention is described in detail through specific embodiments. Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific implementation disclosed below.

[0037] like Figures 1 to 6 As shown, the present invention proposes a fertilizer particle detection method based on small sample learning, which is used to determine whether the fertilizer particles are qualified, specifically:

[0038] Sending a fertilizer particle image containing fertilizer particles and a reference standard image set into a trained twin network model, wherein the reference standard image set includes qualified reference standard images and unqualified reference standard images, and outputting similarity scores between the fertilizer particle image and the qualified reference standard images and the unqualified reference standard images respectively;

[0039] Calculate weighted similarity for all similarity scores obtained based on weights corresponding to qualified reference standard images and unqualified reference standard images;

[0040] The obtained weighted similarity is compared with the preset qualified threshold and unqualified threshold respectively. , then the fertilizer particle corresponding to the fertilizer particle image to be detected is judged to be qualified, and the fertilizer particle image can be added to the qualified reference standard image to increase the number of images in the qualified reference standard image. , then the fertilizer particles corresponding to the fertilizer particle image to be detected are judged to be unqualified, and the fertilizer particle image can be added to the unqualified reference standard image to increase the number of images in the unqualified reference standard image, where represents the difference between the weighted similarity and the qualified threshold, represents the difference between the weighted similarity and the disqualified threshold;

[0041] The performance of the entire detection system can be evaluated regularly, and based on the performance evaluation results, the detection system can be adjusted to improve the accuracy of detecting whether the fertilizer particles are qualified.

[0042] The training process of the twin network model is as follows:

[0043] S1, acquiring a plurality of fertilizer particle images and preprocessing them, and using the preprocessed fertilizer particle images as a fertilizer particle image dataset, specifically including steps S11 to S12;

[0044] S11, graying the obtained fertilizer particle image by using a weighted average method;

[0045] For electronic images, the smallest unit that makes up the image is a pixel. Each pixel is represented by three components, R\G\B (red\green\blue), and the value range of each channel is 0 to 255. When processing images, the red, green, and blue color channels of the RGB image are often converted into one color channel to reduce the amount of image processing calculations and the amount of image storage data, greatly improving the efficiency of image processing. This embodiment uses the weighted average method for grayscale conversion, and assigns different weight values ​​to the three channels RGB at the same pixel position of the obtained fertilizer particle image. The conversion formula is:

[0046]

[0047] in, Represents the calculated grayscale value of the pixel position, Indicates the red component value of the pixel position; Indicates the green component value of the pixel position; Indicates the blue component value of the pixel position;

[0048] The above formula is used to grayscale the image. Compared with the image grayscaled with only a single channel, the image grayscaled with this formula has more distinct layers. Specifically: Improve the efficiency of subsequent processing: Grayscale images only contain brightness information, and the amount of data is smaller than that of color images, so they are more efficient to process. Improve image quality: The weighted average method can more effectively preserve the visual information and details of the original image, especially in terms of color contrast and edge clarity. Compatibility and simple implementation: Although the weighted average method involves different weights, its implementation is still simple and intuitive. This makes it easy to implement and apply in various programming and image processing environments without the need for complex algorithm support.

[0049] S12, using a sharpening filter to filter the grayscale processed fertilizer particle image to obtain a preprocessed fertilizer particle image;

[0050] During the generation and transmission of images, image noise is often generated due to interference and influence of various noises, which will have an adverse effect on the subsequent image processing. Therefore, in order to suppress noise and improve image quality, the image needs to be pre-processed for denoising. This embodiment uses a sharpening filter to reduce the noise of the fertilizer particle image after grayscale processing, thereby highlighting the features. A linear filtering operation is applied to the fertilizer particle image after grayscale processing, and the linear filtering operation uses a predefined filter kernel, which is configured to enhance the image edge, wherein the predefined filter kernel is a 3x3 filter matrix, the central element of the filter matrix is ​​a positive value, and the surrounding elements are negative values, so as to enhance the contrast of the fertilizer particle image after grayscale processing and sharpen the image edge. Among them, the predefined filter kernel is specifically the following filter matrix:

[0051]

[0052] The filter matrix increases the weight of the central pixel value of the image relative to the surrounding pixel values, thereby achieving image sharpening. The fertilizer particle image after filtering is stored and used as the preprocessed fertilizer particle image to construct the fertilizer particle image dataset. The process is as follows: Figure 4 shown.

[0053] S2. construct an image pair dataset based on the fertilizer particle image dataset, wherein the image pair dataset includes a plurality of positive sample image pairs and a plurality of negative sample image pairs, wherein the positive sample image pair is a combination of two images with the same attributes selected from the fertilizer particle image dataset, and the negative sample image pair is a combination of two images with different attributes selected from the fertilizer particle image dataset;

[0054] The fertilizer particle image dataset is divided into two categories, one category represents the qualified situation of fertilizer particles, recorded as qualified samples, and the other category represents the unqualified situation, recorded as unqualified samples. Two images are selected from the qualified samples to form a positive sample image pair. Similarly, two images are selected from the unqualified samples to form a positive sample image pair to represent a combination of images with similar attributes or categories. In addition, one image is selected from each of the qualified samples and the unqualified samples to form a negative sample image pair to represent a combination of images with different attributes or categories.

[0055] These image pairs and corresponding labels are stored to form an image pair dataset specifically used to train the twin network model. This is intended to provide sufficient training data for the twin network model so that it can accurately identify and classify qualified and unqualified fertilizer particles. This dataset construction method can overcome the problem of data imbalance caused by small samples, that is, it can make up for the problem of data imbalance when the number of unqualified samples is insufficient. The twin network model focuses on the similarity between image pairs, thereby overcoming the data imbalance problem caused by the scarcity of unqualified samples. It helps to improve the accuracy and robustness of the model, so as to better meet the needs of fertilizer quality control in industrial production.

[0056] S3, input the positive sample image pair or the negative sample image pair in the image pair dataset into the twin network model, perform feature extraction based on the ResNet50 structure, and obtain the corresponding two image features respectively;

[0057] The main structure of the twin network model is the ResNet50 structure that has been pre-trained with a large dataset. After removing the last fully connected layer of the ResNet50 structure, all other layers are frozen. Then, the pooling layer and the comparison layer are sequentially connected to the output of the ResNet50 structure with the fully connected layer removed to calculate the similarity. At the beginning, the convolutional layers of the ResNet50 pre-trained network are frozen. By freezing these layers, the rich feature representations learned by ResNet50 on large datasets (such as ImageNet) can be directly used. These features often have good generalization capabilities. Then, ResNet50 is gradually unfrozen as needed. Based on the performance of the twin network model on the image pair verification dataset, it is evaluated whether the twin network model needs to be further fine-tuned.

[0058] ResNet network (Residual net) is a general concept of residual network; ResNet50 refers to a ResNet network containing 50 convolutional layers (including convolutional layers, pooling layers, fully connected layers, etc.). ResNet50 is a specific network structure proposed based on training on the ImageNet dataset.

[0059] After the training of the twin network model is completed, it is verified using the fertilizer particle image verification dataset. The verification process is as follows: multiple fertilizer particle images are obtained and preprocessed to obtain the fertilizer particle image verification dataset, and an image pair verification dataset is constructed based on the fertilizer particle image verification dataset; a group of image combinations in the positive sample verification image pairs or a group of image combinations in the negative sample verification image pairs in the image pair verification dataset are input into the trained twin network model, and the predicted classification results of the fertilizer particles are output; if the predicted classification results of the fertilizer particles always deviate from the true classification results of the fertilizer particles, the frozen ResNet50 structure is thawed layer by layer from the top layer, and the thawed twin network models are trained and verified in turn by reducing the learning rate until the performance of the twin network model no longer improves

[0060] Specifically: initially, the twin network model is trained on the basis of a completely frozen ResNet50 structure, and then the trained twin network model is verified by an image pair verification data set. If the predicted classification results of the fertilizer particles always deviate from the actual classification results of the fertilizer particles, the frozen ResNet50 structure will be unfrozen layer by layer from the top layer, and a part of the ResNet50 structure will be unfrozen each time. Then, the partially unfrozen twin network model will be trained with the image pair data set used for training, and then the image pair verification data set will be used to verify the trained twin network model. If the predicted classification results of the fertilizer particles always deviate from the actual classification results of the fertilizer particles, a part of the ResNet50 structure will continue to be unfrozen, and the training and verification phase of the twin network model will be entered again until the performance of the twin network model is no longer significantly improved.

[0061] Each unfrozen layer is used together with the previously unfrozen layer as the unfrozen layer of the ResNet50 structure, and the remaining unfrozen layers are still frozen. The unfreezing order of the ResNet50 structure starts from the top layer. Generally speaking, the layers closer to the top are more task-specific, while the bottom layers focus more on general features. When unfreezing layers for training, it is important to use a smaller learning rate to avoid destroying the valuable features that already exist in these layers. Repeat this process, unfreezing more layers each time, until the model performance is no longer significantly improved.

[0062] S4, after the two image features are pooled by the pooling layer, they enter the comparison layer to calculate the similarity and generate similarity scores respectively;

[0063] S5. According to the labels and similarity scores corresponding to the two image features, the hierarchical dynamic similarity loss function is applied to calculate the loss of the twin network model, and the model parameters of the twin network model are updated through the optimization algorithm.

[0064] The twin network model processes the input image pair dataset as follows: first, training data is extracted from the previous image pair dataset, which consists of image pairs and labels; then, the images in the image pairs are respectively passed through the ResNet50 structure part, where the network weights are shared and used to capture deep image features; then, the extracted image feature representation is used to calculate the similarity between the two image features through a comparison layer to generate a similarity score.

[0065] Then, according to the labels and similarity scores of the image pairs, the hierarchical dynamic similarity loss function is applied to calculate the loss value of the twin network, and the network parameters are updated through the optimization algorithm to reduce the loss value; the hierarchical dynamic similarity loss function, for each image pair in the twin network and its tags ( =1 means the image pair is similar, = 0 means the image pair is not similar), the loss function The formula is:

[0066]

[0067] in, is the number of image pairs in the image pair dataset in the batch. The image pairs in the image pair dataset are the general term for the mixture of positive sample image pairs and negative sample image pairs. Represents the image pair in the dataset The labels of the image pairs, is the similarity score between the two images of an image pair in the image pair dataset, and are the loss functions for similar image pairs and dissimilar image pairs, respectively. and Respectively represent the thresholds of similar sample pairs and dissimilar sample pairs, is a hyperparameter used to balance the regularization term impact.

[0068] Threshold : This threshold is usually used to distinguish the similarity level in similar sample pairs, and sample pairs below this threshold are considered "highly similar". Threshold : This threshold is usually used to distinguish the degree of difference in dissimilar sample pairs. Sample pairs exceeding this threshold are considered to be "significantly dissimilar".

[0069] in, and Different levels of similarity are considered, for example by thresholding and To define different similarity or distance intervals. For similar sample pairs, we hope that the similarity score between samples is The smaller the better, especially when the similarity score is less than the threshold When , the formula is:

[0070]

[0071] For dissimilar sample pairs, we hope that the similarity score between the samples The larger the better, especially when the similarity score is greater than the threshold When , the formula is:

[0072]

[0073] It is a regularization term that dynamically adjusts the loss contribution of each image pair based on the classification confidence of the twin network model for the current image pair (the probability predicted by the model), aiming to increase the penalty for those sample pairs that are difficult for the twin network model to classify correctly (i.e., the confidence predicted by the twin network model is low).

[0074] Regularization term It can be defined as:

[0075]

[0076] It is image pairs, labeled The probability of is a positive tuning parameter that controls the degree of penalty for low confidence predictions.

[0077] This loss function The core idea of ​​the proposed method is to introduce the concept of similarity grading into the twin network model, and dynamically adjust the learning focus according to the processing ability of the twin network model for image pairs with different levels of similarity during training.

[0078] Hierarchical processing: For similar image pairs: Can be based on and , such as using piecewise functions or based on and A smooth function of the difference between and to distinguish different degrees of similarity. For dissimilar image pairs: Similarly, we can process and The relationship definition distinguishes different degrees of difference.

[0079] The fertilizer particles to be tested are sent to the trained twin network model to output the classification results of the fertilizer particles and judge the classification results of the fertilizer particles. If the fertilizer particles are found to be unqualified, the LED alarm will light up red to prompt the operator to adjust the raw material input ratio. Under normal circumstances, the LED alarm is green and all test indicators will be displayed on the industrial computer interface. At the same time, the industrial computer will send the image of the fertilizer particles to be tested taken by the industrial camera and the final test results (qualified or unqualified) to the cloud platform through the HTTPS transmission protocol, so that remote personnel can view the current fertilizer production status in real time.

[0080] In this embodiment, when determining the eligibility of fertilizers, the detection system includes a monitoring module, an alarm module and a cloud platform module;

[0081] In the monitoring module, the industrial computer communicates with the industrial camera through Ethernet transmission, thereby controlling the operation of the industrial camera and reading the fertilizer particle image information obtained by the industrial camera. After preprocessing, the fertilizer particle image is sent to the twin network model for identification and monitoring. Figure 6As shown in the figure, this process not only includes the steps of automatically detecting the size of fertilizer particles using the twin network model, but also integrates a dynamic learning mechanism to continuously optimize and update the reference standard image library. The following is the detailed process: (1) Similarity calculation: The fertilizer particle image to be detected is calculated to have a similarity with all the reference standard images in a preset sample image set to obtain a similarity score, wherein the preset sample image set includes multiple qualified reference standard images and multiple unqualified reference standard images; (2) Comprehensive scoring: Based on all the similarity scores obtained in the previous step, a comprehensive scoring mechanism is used to evaluate the status of the fertilizer particle image to be detected. Based on the weights corresponding to the qualified reference standard images and the unqualified reference standard images, a weighted similarity is calculated for all the similarity scores obtained, wherein the weights of the qualified reference standard images and the unqualified reference standard images may be different; (3) Judgment and classification: The obtained weighted similarity is compared with the preset qualified threshold and unqualified threshold, respectively. If the weighted similarity is closer to the qualified threshold, the fertilizer particles corresponding to the fertilizer particle image to be tested are judged to be qualified, and the qualified fertilizer particle image to be tested is added to the qualified reference standard image. If the weighted similarity is closer to the unqualified threshold, the fertilizer particles corresponding to the fertilizer particle image to be tested are judged to be unqualified, and the unqualified fertilizer particle image to be tested is added to the unqualified reference standard image. (4) Manual re-inspection: For cases where the system judgment results are inconsistent with the actual situation, that is, misjudgments discovered by manual re-inspection, these images are regarded as new situations, and the misjudged qualified fertilizer particle images to be tested are added to the qualified reference standard images, and the misjudged unqualified fertilizer particle images to be tested are added to the unqualified reference standard images. After the reference standard image library is updated, it can be used in future inspections to improve the accuracy of judgment. (5) Dynamic optimization: Regularly evaluate the performance of the entire detection system, especially the misjudgment rate discovered after manual re-inspection. Based on the performance evaluation results, adjust the threshold, decision logic, update the reference standard image library information, and even retrain the twin network model to ensure that the detection logic can adapt to changes in production conditions and standards. This process introduces dynamic learning and feedback mechanisms, which not only enables the detection system to self-optimize based on new data, but also increases the system's ability to cope with unknown or emerging situations. This approach can significantly improve long-term detection accuracy and system reliability.

[0082] Alarm module: The industrial computer is connected to an LED alarm light through a USB interface. Different LED alarm light states are displayed according to different test results. When unqualified fertilizer particles appear, the operator will be notified of the abnormal situation in time so as to adjust the production raw material ratio. Under normal conditions, the LED alarm is green, and all test indicators are displayed on the industrial computer interface.

[0083] Cloud platform module. The industrial computer sends the images and final detection results of the industrial camera to the WEB cloud platform through the HTTPS transmission protocol, so that remote personnel can also view the current fertilizer production status.

[0084] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A fertilizer particle detection method based on small sample learning, used to determine whether the fertilizer particles are qualified, characterized in that: Sending a fertilizer particle image containing fertilizer particles and a reference standard image set into a trained twin network model, wherein the reference standard image set includes qualified reference standard images and unqualified reference standard images, and outputting similarity scores between the fertilizer particle image and the qualified reference standard image and the unqualified reference standard image respectively; Calculate weighted similarity for all similarity scores obtained based on weights corresponding to qualified reference standard images and unqualified reference standard images; The obtained weighted similarity is compared with the preset qualified threshold and unqualified threshold respectively. , then the fertilizer particles corresponding to the fertilizer particle image to be detected are judged to be qualified. , then the fertilizer particles corresponding to the fertilizer particle image to be detected are judged to be unqualified, where represents the difference between the weighted similarity and the qualified threshold, represents the difference between the weighted similarity and the disqualified threshold; The main structure of the twin network model is a ResNet50 structure that has been pre-trained with a large data set. After removing the last fully connected layer of the ResNet50 structure, all other layers are frozen. Then, the pooling layer and the comparison layer are sequentially connected to the output end of the ResNet50 structure from which the fully connected layer is removed. The training process of the twin network model is as follows: S1, acquiring a plurality of fertilizer particle images and preprocessing them, and using the preprocessed fertilizer particle images as a fertilizer particle image dataset; S2. construct an image pair dataset based on the fertilizer particle image dataset, wherein the image pair dataset includes a plurality of positive sample image pairs and a plurality of negative sample image pairs, wherein the positive sample image pair is a combination of two images with the same attributes selected from the fertilizer particle image dataset, and the negative sample image pair is a combination of two images with different attributes selected from the fertilizer particle image dataset; S3, input the positive sample image pair or the negative sample image pair in the image pair dataset into the twin network model, perform feature extraction based on the ResNet50 structure, and obtain the corresponding two image features respectively; S4, after the two image features are pooled by the pooling layer, they enter the comparison layer to calculate the similarity and generate similarity scores respectively; S5. According to the labels and similarity scores corresponding to the two image features, a hierarchical dynamic similarity loss function is applied to calculate the loss of the twin network model, and the model parameters of the twin network model are updated through an optimization algorithm; The hierarchical dynamic similarity loss function The details are as follows: in, is the number of image pairs in the batch image pair dataset. The image pairs in the image pair dataset are the general term for the mixture of positive sample image pairs and negative sample image pairs. Represents the image pair in the dataset The labels of the image pairs, is the similarity score between the two images of an image pair in the image pair dataset, and are the loss functions for similar image pairs and dissimilar image pairs, respectively. and Respectively represent the thresholds of similar sample pairs and dissimilar sample pairs, is a hyperparameter used to balance the regularization term The impact of Represents the product.

2. The fertilizer particle detection method based on small sample learning according to claim 1 is characterized in that: After the training of the twin network model is completed, it is verified using the fertilizer particle image verification dataset. The specific verification process is as follows: Acquire multiple fertilizer particle images and preprocess them to obtain a fertilizer particle image verification dataset, and construct an image pair verification dataset based on the fertilizer particle image verification dataset; Input a group of image combinations in the positive sample verification image pair or a group of image combinations in the negative sample verification image pair in the image pair verification data set into the trained twin network model, and output the predicted classification results of the fertilizer particles; If the predicted classification results of the fertilizer particles always deviate from the actual classification results of the fertilizer particles, the frozen ResNet50 structure will be unfrozen layer by layer from the top layer, and the unfrozen twin network models will be trained and verified in sequence by reducing the learning rate until the performance of the twin network model no longer improves.

3. The fertilizer particle detection method based on small sample learning according to claim 1 is characterized in that: In step S1, a plurality of fertilizer particle images are obtained and preprocessed as follows: S11, using a weighted average method to assign different weight values ​​to the three channels RGB of the same pixel position of the obtained fertilizer particle image, specifically: in, Represents the calculated grayscale value of the pixel position, Indicates the red component value of the pixel position; Indicates the green component value of the pixel position; Indicates the blue component value of the pixel position; S12, using a sharpening filter to filter the grayscale processed fertilizer particle image to obtain a preprocessed fertilizer particle image.

4. The fertilizer particle detection method based on small sample learning according to claim 3 is characterized in that: In step S12, the sharpening filter operation uses a predefined filter kernel, and the filter kernel is configured to enhance the edge of the image, wherein the predefined filter kernel is a 3x3 filter matrix, the center element of the filter matrix is ​​a positive value, and the surrounding elements are negative values. The predefined filter kernel is specifically the following filter matrix: The fertilizer particle images after filtering are stored and used as preprocessed fertilizer particle images to construct a fertilizer particle image dataset.