Intelligent metal sorting method based on machine vision technology, medium and equipment
Through the self-learning metal sorting method based on machine vision, the YOLOv8 object detection model is constructed and combined with the self-learning algorithm, the problem of poor adaptability in the existing technology is solved, efficient and accurate sorting in complex environments is achieved, and the robustness and adaptability of the system are improved.
Patent Information
- Application Number
- CN202510328618.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-07-25
AI Technical Summary
When facing complex and changing material characteristics and industrial sorting needs, existing metal sorting technologies have problems such as poor adaptability and insufficient generalization ability. Especially when dealing with materials with severe surface pollution or large covering layers, the recognition effect is limited, and lacks adaptive learning ability, making it difficult to dynamically adjust to adapt to changes in different batches of materials.
The self-learning metal sorting method based on machine vision technology is adopted to construct the YOLOv8 object detection model through a self-learning algorithm, combining the projection head network and adversarial training losses and projection head comparison learning losses to achieve dynamic optimization and adaptability improvement, combining information entropy formula to screen high uncertainty samples for semi-automatic annotation, and updating the model weight by minimizing the joint loss function, forming a closed loop from data acquisition to model optimization.
It realizes the efficient and accurate metal sorting ability in a complex and changeable industrial environment, improves the robustness and adaptability of the system, improves the sorting accuracy and efficiency, and enhances the adaptive learning ability of the system.
Smart Images

Figure CN120375038A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an intelligent metal sorting method, medium and equipment based on machine vision technology. Background Art
[0002] In the field of metal sorting, existing detection and sorting technologies mainly include visible light sorting and X-ray sorting.
[0003] Visible light sorting technology, especially machine vision sorting technology, has been widely used. This technology collects image information on the surface of materials and uses image processing algorithms and deep learning models to achieve intelligent recognition of metal types and morphological characteristics. This technology relies on high-speed camera equipment and parallel computing hardware to obtain high-resolution images of materials in real time, and based on machine learning models, accurately analyze complex surface textures, colors and shape features, so as to quickly complete data processing and sorting decisions. This feature makes it particularly suitable for large-scale metal sorting needs in continuous industrial processes. However, the recognition effect of machine vision sorting technology will be limited when dealing with materials with severe surface contamination or a large number of covering layers. In addition, this technology has high requirements for the robustness of deep learning models and the diversity of training samples, and it is necessary to continuously optimize algorithms and improve data sets in practical applications.
[0004] X-ray sorting technology mainly includes X-ray fluorescence spectroscopy sorting (XRF) and X-ray transmission sorting (XRT). XRF technology identifies metal components based on the fluorescence spectrum produced after X-rays excite the atoms of materials. It can identify a variety of metal elements, and the analysis results are direct and accurate. However, since spectral analysis equipment usually lacks spatial resolution, it cannot process a large number of materials at the same time, resulting in low sorting efficiency. XRT technology uses the penetration effect of X-rays to classify materials according to their different X-ray absorption rates. It can more clearly collect the morphology, position and internal structure information of materials and adapt to more complex sorting environments. In particular, dual-energy X-ray transmission (DE-XRT) technology can reduce the impact of changes in material size or thickness through differences in X-ray absorption at different energy levels. However, XRT technology has low sensitivity to heavy metal materials, and the characteristic calibration of different materials depends on the specific composition of the sorting object, lacking sufficient robustness.
[0005] Furthermore, when the XRF technology identifies metal components, it cannot dynamically adapt to the characteristics of different materials. In the face of changes in material types, shapes, and surface features, existing spectral devices often result in a decrease in sorting accuracy due to signal parsing failures. Especially for materials with complex shapes or surface obstructions, the XRF technology is difficult to adjust the spectral analysis method, and the identification performance is significantly reduced. In addition, this technology lacks the ability to efficiently process a large number of materials and can only rely on fixed rules for individual analysis, making it difficult to meet the industrial sorting requirements. Similarly, the DE-XRT technology's reliance on material characteristic information also limits its adaptive ability. Existing calibration methods are mostly static and difficult to dynamically adjust to adapt to the characteristics of complex or mixed materials, thus affecting the sorting accuracy. Especially for heavy metal materials, when the absorption characteristics are close to those of other substances, the DE-XRT technology cannot accurately identify them. In addition, existing algorithms lack the ability of adaptive learning and cannot optimize the sorting strategy based on on-site data, showing insufficient robustness in complex environments.
[0006] Traditional machine vision technology also has limitations. This technology mainly relies on pre-set fixed features (such as color, shape, texture, etc.) for target detection and recognition. However, in the face of complex and dynamically changing material characteristics, this method shows obvious limitations. Due to the lack of the ability to adaptively adjust to new on-site data, when the material type, form, or surface features change, the model often has difficulty effectively identifying, resulting in a decrease in sorting accuracy. Moreover, traditional machine vision technology has poor adaptability to the environment. In actual industrial scenarios, problems such as lighting conditions, background interference, and material occlusion will significantly affect the detection effect of the model. Even with the introduction of some enhancement algorithms, it still cannot fully meet the sorting requirements for diverse materials and complex environments. In addition, most existing machine vision systems adopt an offline processing mode and are insufficient in responding to the real-time changes and dynamic sorting requirements of materials in industrial scenarios. Systems lacking online monitoring and real-time optimization capabilities limit the sorting efficiency and accuracy.
[0007] In summary, existing metal sorting technologies have many deficiencies when facing complex and changing material characteristics and industrial sorting requirements. Especially the lack of the ability to achieve dynamic learning and optimization through on-site data leads to the system's difficulty in adapting to the changes in different batches of materials and the diverse requirements of complex industrial scenarios. The sorting performance highly depends on the support of initial calibration and fixed models, with high update and iteration costs. When sorting complex materials, the lack of adaptive adjustment and generalization ability and the inability to efficiently handle changes in material characteristics significantly limit its practical application value in industrial scenarios. Therefore, it is necessary to develop a new type of metal sorting technology to solve the problems existing in the existing technology. Summary of the Invention
[0008] In view of the deficiencies of the prior art, the present invention proposes a self-learning metal sorting method based on machine vision technology, aiming to solve the key problems of poor adaptability to complex and changeable material environments and insufficient generalization ability exposed by the prior art when facing metal materials with diverse types, shapes, and sizes.
[0009] Based on machine vision technology, the present invention constructs a set of self-adaptive learning sorting methods. By introducing self-learning algorithms, a dynamic optimization closed-loop from data collection, automatic annotation to model fine-tuning is achieved, which can dynamically adapt to changes in material characteristics. At the same time, the present invention also focuses on the generalization ability and robustness of the system. By continuously optimizing the object detection model, accurate identification of multiple metal elements is achieved. Even when facing materials with complex shapes and surface occlusions, a high sorting accuracy can be maintained.
[0010] According to one aspect of the present invention, as Figure 1 shown, an intelligent metal sorting method based on machine vision technology is provided, and the steps are as follows:
[0011] Step 1. Self-learning model training: Collect metal material sample images to generate a virtual annotation data set; construct an object detection model based on YOLOv8, which integrates a projection head network, and complete model training by jointly optimizing the YOLOv8 detection loss, adversarial training loss, and projection head contrastive learning loss; deploy the trained model, and online adjust the class weights of the YOLOv8 detection head according to the detection frequency and error distribution of specific target materials to optimize the response to specific features of the materials.
[0012] Step 2. Material identification and sorting: Collect real-time material images and perform preprocessing; use the trained model to identify the metal type and generate a sorting control signal to perform sorting.
[0013] Step 3. Semi-automatic data annotation: Based on the improved information entropy formula H * (x) = H(x) + λf(I), where screen high-uncertainty samples, and generate an annotation database after manual review.
[0014] Step 4. Model iterative optimization: Dynamically adjust the image preprocessing parameters according to the annotation data, update the model weights by minimizing the joint loss function and apply the updated model parameters to the material identification and sorting steps.
[0015] Optionally, the above intelligent metal sorting method further includes that the calculation formula of the adversarial training loss in Step 1 is L adv = λL YOLO (x, y) + (1 - λ)L YOLO (x adv, y), where the adversarial example x adv is generated by .
[0016] Optionally, the above intelligent metal sorting method further includes that the projection head contrast learning loss in step one adopts the InfoNCE loss function where z i , z j are the projection variables of samples of the same category.
[0017] Optionally, the above intelligent metal sorting method further includes that the preprocessing in step two includes: performing histogram equalization and brightness compensation in real time; using a guided filter to eliminate background noise; dynamically applying gamma correction and contrast stretching according to real-time lighting conditions.
[0018] Optionally, the above intelligent metal sorting method further includes that identifying the metal type and generating a sorting control signal to perform sorting in step two specifically includes: calculating the information entropy of the real-time inference result, triggering multiple inferences of test-time augmentation (TTA) when the information entropy is greater than a preset threshold, the TTA generates multiple groups of inference results by image transformation with different angles and lighting conditions, and determines the final classification result according to weighted voting; after the high-entropy samples are recorded, they are added to the training data set for key training during the iterative optimization process in step four.
[0019] Optionally, the physical feature parameters of the improved information entropy formula in step three of the above intelligent metal sorting method include: I avg is the gray mean value of the metal block, I max is the maximum gray value, I min is the minimum gray value, and λ is the weight coefficient optimized through experiments.
[0020] Optionally, the model weight adjustment in step four of the above intelligent metal sorting method includes: calculating the sample importance score according to S(x) = αH * (x) + βC(x) + γD(x).
[0021] According to another aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored, wherein when the program is executed by a processor, the steps described in any one of the above methods are implemented.
[0022] According to another aspect of the present invention, there is provided an electronic device, the electronic device includes a processor, a memory, and a computer program stored on the memory, and the processor is used to implement the steps described in any one of the above methods when executing the computer program.
[0023] In summary, the metal sorting method of the present invention realizes a complete closed-loop from data acquisition, automatic annotation, model training to sorting execution by integrating machine vision and self-learning algorithms. This method can dynamically adjust and optimize according to the characteristics of different batches of materials, and maintain high-efficiency and accurate sorting capabilities in a complex and changeable industrial environment. Through continuous experimental feedback and model optimization, the present invention effectively improves the accuracy and efficiency of metal sorting, while enhancing the robustness and adaptability of the system. Generally speaking, the present invention provides an intelligent and automated metal sorting solution, and its innovation lies in the application of an adaptive learning mechanism, enabling the system to continuously optimize and adapt to various working conditions, bringing significant efficiency improvement and technological progress to the field of metal sorting.
[0024] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings incorporated into the specification and constituting a part of the specification illustrate the embodiments of the present invention and, together with the related written description, are used to explain the principles of the present invention. In these drawings, like reference numerals are used to represent like elements. The drawings in the following description are some embodiments of the present invention, not all embodiments. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 is a schematic flowchart of an intelligent metal sorting method based on machine vision technology shown according to an exemplary embodiment.
[0027] Figure 2 is a block diagram of a computer device 200 of an intelligent metal sorting method based on machine vision technology shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention. It should be noted that, without conflict, the embodiments and features in the present application can be combined with each other arbitrarily.
[0029] Typical machine vision-based metal sorting technologies usually include processes such as data acquisition, image preprocessing, feature extraction, model training and classification stage, model evaluation and parameter optimization, and real-time sorting system deployment. However, this method has significant limitations: cross-modal fusion of traditional handcrafted features and deep learning features has not been achieved, resulting in incomplete characterization of the intrinsic physical and chemical properties of metals; even with ensemble learning, the accuracy of static models is still less than 80%, and they cannot adapt to material distribution offsets online; moreover, preprocessing relies on manual experience for parameter tuning (such as HSV threshold setting), and it is difficult for real-time systems to balance accuracy and speed requirements.
[0030] To break through the above limitations, the present invention innovatively combines a multi-modal dynamic learning architecture with an adaptive optimization strategy to achieve dynamic optimization and wide adaptability, significantly enhancing the generalization ability and sorting accuracy of the system.
[0031] In an exemplary embodiment, an intelligent metal sorting method based on machine vision technology includes the following steps:
[0032] Step 1: Self-learning model training: Collect metal material sample images to generate a virtual annotation dataset; construct an object detection model based on YOLOv8, which fuses a projection head network, and complete model training by jointly optimizing the YOLOv8 detection loss, adversarial training loss, and projection head contrastive learning loss; deploy the trained model, and online adjust the class weights of the YOLOv8 detection head according to the detection frequency and error distribution of specific target materials to optimize the response to specific features of the materials. Combining the improved loss function of the adversarial training loss and the contrastive learning loss of the projection head, the model robustness is improved through adversarial training, and the feature representation ability is enhanced through contrastive learning. The combination of the two can significantly improve the performance of the model.
[0033] In one implementation, optionally, the generation of the virtual annotation dataset in Step 1 can be achieved through the following steps:
[0034] 1-1-1. Collect small batches of target material samples (such as copper, aluminum, stainless steel), and determine the class labels of each material through manual sorting;
[0035] 1-1-2. Use an industrial camera to collect multi-angle images of the classified materials to obtain raw image data, and perform preliminary annotation based on an edge detection algorithm;
[0036] 1-1-3. Crop the labeled material sample regions from the images, and fuse the cropped material sample regions to a blank background through image stitching technology to generate a virtual dataset containing multi-angles and multi-illumination conditions. Through virtual synthesis technology, the problem of insufficient initial labeled data can be solved, the manual labeling cost can be reduced, and the texture features of the real scene can be retained.
[0037] In one implementation, optionally, the construction of the YOLOv8 model with the fusion projection head in step one means that in the initial model training stage, based on the generated virtual annotation dataset, the model is trained by jointly optimizing three loss functions: the YOLOv8 basic detection loss (including object localization loss, classification loss, and confidence loss), the adversarial training loss (the model output deviation loss calculated based on the adversarial sample generation strategy), and the projection head contrast learning loss (using the InfoNCE loss function to measure the similarity of projection features of samples of the same category). Specifically, it can be achieved through the following steps:
[0038] 1-2-1. Construct an object detection model based on the fusion of YOLOv8 and the projection head, and use the virtual annotation dataset to train the model. The goal is to accurately detect the metal type and locate the boundary of the metal material. The projection head is a non-linear mapping network (MLP), which is introduced into the adversarial learning loss to project the features extracted by YOLOv8 into a space suitable for contrast learning, making the features of samples of the same category closer and the features of different category samples more separated. Given the features F(x) extracted by YOLOv8, the projection head (Projection Head) is:
[0039] z = MLP(F(x)) = W2(ReLU(W1F(x) + b1)) + b2
[0040] W1, b1 are the weights and biases of the first layer of MLP
[0041] W2, b2 are the weights and biases of the second layer of MLP
[0042] ReLU is used as the non-linear activation function
[0043] The output z is a low-dimensional representation (such as 128 dimensions) for calculating the contrast loss
[0044] 1-2-2. Adversarial training loss. To enhance the adversarial robustness of the model, the present invention embodiment introduces adversarial training to enable the model to still correctly classify and detect metal targets in the face of perturbations. Adversarial samples can be generated through the FGSM method:
[0045]
[0046] x is the original image
[0047] y is the true class label
[0048] L(x, y) is the loss function of YOLOv8
[0049] θ is the model parameter
[0050] is the gradient of the loss function with respect to the input
[0051] ε is a hyperparameter for the perturbation strength
[0052] Adversarial loss:
[0053] L adv = λL YOLO (x, y) + (1 - λ)L YOLO (x adv , y)
[0054] L YOLO (x, y) is the loss for the original image
[0055] L YOLO (x adv , y) is the loss for the adversarial sample
[0056] λ controls the trade - off between the two
[0057] 1 - 2 - 3. Contrastive learning loss (introduced by the projection head): In contrastive learning, the embodiments of the present invention adopt the InfoNCE loss to bring the projection vectors of samples of the same class closer and make the projection vectors of samples of different classes farther apart;
[0058]
[0059] z i , z j are the projection variables of samples of the same class;
[0060] z k is a randomly selected contrast sample among all samples;
[0061] is the cosine similarity;
[0062] Τ is a temperature hyperparameter.
[0063] 1 - 2 - 4. The final loss function combines the YOLOv8 loss, adversarial training loss, and contrastive learning loss:
[0064]
[0065] λ1, λ2, λ3 control the weights of the loss terms;
[0066] L YOLO is responsible for object detection;
[0067] L adv makes the model resistant to interference;
[0068] L NCE makes the model features more separated and improves the metal classification accuracy.
[0069] 1-2-5. Introduce dynamic data cleaning and adaptive enhancement strategies. When loading data, perform real-time image quality checks (such as blur detection and overexposure screening) to ensure the reliability of the input images. Analyze the illumination and material characteristics in real time, and dynamically apply enhancement methods (such as gamma correction and contrast stretching) to the input images.
[0070] 1-2-6. During the training process, introduce data augmentation techniques (such as random cropping, rotation, and brightness variation) to improve the generalization ability of the model.
[0071] In one implementation, optionally, deploying the trained model and online adjusting the class weights of the YOLOv8 detection head according to the detection frequency and error distribution of specific target materials to optimize the response to specific material features specifically means deploying the initial model to the actual production system, performing sorting operations, and generating real-time sorting data. In the initial deployment stage, according to the detection frequency and error distribution of specific target materials, dynamically fine-tune the detection head layer of YOLOv8 through the online weight adjustment module to optimize the response to specific material features.
[0072] In step one, by constructing a self-learning model training system, multi-dimensional technical improvements are achieved in the metal material sorting and detection system: First, based on the virtual dataset generation method of edge detection and background fusion, use a small batch of real samples to quickly construct labeled data, significantly reducing the manual labeling cost and breaking through the limitation of scarce initial data; Second, through the joint optimization mechanism of fusion adversarial training and projection head contrast learning, while improving the model's adaptability to conventional interferences such as illumination changes and material occlusions, enhance its defense performance against adversarial attacks; Further, combined with the dynamic weight adjustment strategy of online detection frequency and error distribution, enable the model to autonomously enhance the recognition accuracy of specific material features (such as oxidized surfaces and deformed contours) according to the actual operating state of the production line; Finally, the synergistic effect of the above technical means enables the trained model to have environmental self-adaptability during the deployment stage, effectively cope with practical problems such as background differences and equipment parameter fluctuations in different industrial scenarios, form a full-link optimization closed-loop from data generation, model training to production line application, realize dynamic adaptation to the diversity and complexity of different batches of materials, and improve the generalization ability and long-term performance stability of the system.
[0073] Step two: Material recognition and sorting: Collect real-time material images and perform preprocessing; Use the trained model to identify the metal type and generate a sorting control signal to perform sorting.
[0074] After collecting the image data of the material through a high-resolution industrial camera and obtaining its internal characteristics and composition information, data transmission and preprocessing are carried out. In one implementation, optionally, the preprocessing includes: light and environment adaptive correction, real-time analysis of the brightness and contrast distribution of the collected image, and improvement of the image quality through histogram equalization and brightness compensation. And denoising and feature enhancement, using an adaptive filtering algorithm (guided filter) to eliminate background noise and at the same time enhance the edge features of the target area. By performing histogram equalization and brightness compensation in real time; using the guided filter to eliminate background noise; dynamically applying gamma correction and contrast stretching according to the real-time lighting conditions, the preprocessing strategy has achieved a significant improvement in image quality, an increase in recognition speed and real-time performance, an enhancement of system robustness and adaptability, an enhancement of the generalization ability of the target detection model in complex industrial environments, and efficient and accurate sorting. The combined effect of these technical effects enables the metal sorting system to work stably in various complex working environments, achieving high-efficiency, high-accuracy, and low-cost metal sorting.
[0075] Next, the data is analyzed through an adaptive YOLOv8 target detection model to accurately classify the material types and locate their positions. In one implementation, optionally, identifying the metal type and generating a sorting control signal to perform sorting specifically includes: calculating the information entropy of the real-time inference result, and when the information entropy is greater than a preset threshold, triggering multiple inferences of test-time augmentation (TTA). The TTA generates multiple sets of inference results through image transformations under different angles and lighting conditions, and determines the final classification result according to weighted voting. In this way, through multiple rounds of inferences with images under different angles and lighting, the robustness can be improved; after the high-entropy samples are recorded, they are added to the training data set for key training during the iterative optimization process in step four.
[0076] Finally, a blowing control signal is generated according to the classification result. During this process, the upper computer in the control device is responsible for generating and sending control instructions, and realizing precise control of the blowing head through a programmable logic controller (PLC). The PLC drives the blowing head to accurately sort the materials according to the instructions of the upper computer, thereby realizing the efficient separation of the target materials.
[0077] Step 3: Semi-automated data annotation: Based on the improved information entropy formula H * (x)=H(x)+λf(I), where Filter high-uncertainty samples, and generate an annotation database after manual review.
[0078] After the sorting in step two is completed, the system continues to collect on-site data, including the position, type, and sorting status of the materials, and then conducts sample collection and matching. Specifically, it includes: calculating the confidence level (i.e., information entropy) of the materials after the system sorting. For each sorted material sample, the system will evaluate the certainty degree of its classification result. Set a threshold H th , if the entropy value H * > H th , then it is considered that this sample has a large uncertainty and needs to be labeled first. Samples with high information entropy mean that the model has a large uncertainty in the classification result of this sample, and such samples are more likely to be misclassified. Therefore, select these samples with high information entropy as key samples and process them preferentially. For the materials selected as key samples, the manual confirmation process will be triggered, and experts will review and label the samples to ensure data quality. By focusing on learning these most challenging samples, the system can more effectively optimize the model and improve the classification accuracy. After the labeling is completed, the system will match and verify the manual labeling results with the sorting log and store the final matching results in the database to be labeled. This process ensures the accuracy and consistency of the data and provides a reliable data basis for subsequent model training and optimization.
[0079] Traditional information entropy calculation methods are mainly based on classification probabilities, but in the actual application of metal sorting, only considering classification probabilities is not enough. To more accurately reflect the uncertainty of material sorting, the embodiment of the present invention combines the physical characteristics of metals and proposes an improved information entropy formula:
[0080]
[0081] H * (x) = H(x) + λf(I)
[0082] H * (x) is the improved information entropy, H(x) is the classical information entropy, is the uncertainty measurement function based on the physical characteristics of metals. In this embodiment, I is the gray value of the identified metal block, I avg is the average gray value of the identified metal block, I max is the maximum gray value of the identified metal block, I min is the minimum gray value of the identified metal block. λ is the weight function optimized through experiments.
[0083] Based on the improved information entropy formula, high-uncertainty samples are screened, and after manual review, a labeled database is generated. This formula combines the physical properties of metals and is used to measure the uncertainty of the model, thereby more accurately identifying high-uncertainty samples and improving the classification accuracy of the model. In metal sorting, the physical properties of materials (such as size, shape, density, conductivity, hardness, magnetism, size, etc.) have an important impact on the classification results. By introducing physical characteristic parameters, the improved information entropy formula can more comprehensively reflect the uncertainty of samples. At the same time, by adjusting the weight coefficient λ, the influence degree of different factors on the information entropy can be flexibly controlled, so as to better adapt to different sorting scenarios and requirements.
[0084] Finally, the manual operator confirms and corrects the labels generated by the system to ensure accurate data labeling and form a labeled database.
[0085] Step Four: Model Iterative Optimization: Dynamically adjust the image preprocessing parameters according to the labeled data, and update the model weights by minimizing the joint loss function and apply the updated model parameters to the material identification and sorting step (i.e., Step Two) to ensure that the sorting accuracy is not affected when the material properties or environmental conditions change, and improve the sorting effect.
[0086] In one implementation, optionally, Step Four can be implemented through the following steps:
[0087] 4-1-1. Store the labeled data, calculate the importance score for each sample, and screen according to the set threshold S thresh to select high-value samples for storage and training, and at the same time eliminate low-quality samples (i.e., samples with low information entropy, high classification confidence but too many categories in the dataset). Optionally, calculate the sample importance score according to the following formula;
[0088] S(x) = αH * (x) + βC(x) + γD(x)
[0089] H * (x) is the improved information entropy,
[0090] C(x) is the reciprocal of the confidence: the lower the classification confidence, the higher the sample uncertainty, defined as:
[0091]
[0092] where max(p i ) is the highest probability of the model's prediction for the sample.
[0093] D(x) is the class balance factor. If the sample belongs to a category with a small number in the training dataset, its importance is increased, and it is set as:
[0094]
[0095] α, β, and γ are hyperparameters that can be adjusted through experiments.
[0096] By dynamically adjusting the loss weights, this formula enables the model to pay more attention to samples with high uncertainty and high error during training, thereby enhancing the recognition ability for complex samples, avoiding overfitting, and optimizing the overall classification performance.
[0097] 4-1-2. During the preprocessing process, parameter augmentation techniques are adopted. For newly collected material samples, the input data is optimized through dynamic feature enhancement and adaptive illumination compensation. At the same time, according to the distribution law of the collected data, the preprocessing module is dynamically updated to enhance its adaptability to different scenarios and material characteristics. In addition, a parameter adjustment mechanism based on data analysis is added to automatically adjust the enhancement and filtering strategies after new data is collected to further improve the preprocessing effect.
[0098] Through the above optimization of labeled data storage and preprocessing, the data quality and preprocessing efficiency have been significantly improved, the class imbalance problem has been effectively alleviated, the adaptability of the system to different scenarios and materials has been enhanced, the automatic adjustment of preprocessing parameters has been realized, the resource utilization has been optimized, and reliable data and technical guarantees have been provided for subsequent model training and application.
[0099] 4-2-1. To improve the classification ability of the model in complex scenarios, the optimization objective can be expressed as:
[0100]
[0101] The first term L(x, y, θ) is the standard loss function and serves as the core optimization objective of the model.
[0102] The second term L(x adv , y, θ) introduces the loss of adversarial samples to enhance the robustness of the model.
[0103] The third term introduces the contrastive learning loss to separate samples of different classes.
[0104] The fourth term H * (x) is the improved information entropy, which is used to measure the uncertainty of the model and improve the discrimination ability for easily confused classes, where γ is a hyperparameter that controls the influence of the improved information entropy in the optimization.
[0105] Based on this optimization objective, the following strategies are adopted for parameter adjustment during training:
[0106] (1) Data Selection: Regularly perform small-batch fine-tuning using newly labeled data. Select the top 80% of samples with the highest information entropy S(x) from the new data pool for training instead of using all the data to enhance the model's attention to highly uncertain samples.
[0107] (2) Loss Optimization: Dynamically adjust the class weights and bounding box prediction weights of the YOLOv8 detection head so that high-error targets receive higher weights during loss optimization.
[0108] (3) Information Entropy Regulation: In the case of large classification biases, use information entropy to screen high-error classes and adaptively adjust the model's classification weights. During training, samples with high information entropy are given greater loss weights. Optionally, the top 80% of samples with scores higher than the threshold are given greater loss weights to reduce the error of difficult-to-classify samples; at the same time, reduce the loss weights of low-entropy samples to prevent the model from overfitting to simple data and achieve loss balance.
[0109] (4) Adversarial Training Enhancement: Introduce the adversarial loss L(x adv , y, θ) to optimize the model's adaptability to perturbed samples and improve classification robustness.
[0110] Through the above optimization objectives and strategies, the classification ability and robustness of the model in complex scenarios have been significantly improved, the misclassification rate of easily confused classes has been effectively reduced, and through adaptive adjustment of loss weights and information entropy regulation, the model has achieved precise learning of high-uncertainty and high-error samples. At the same time, the introduction of adversarial training further enhances the generalization ability of the model.
[0111] After training and optimization with the adaptive learning method, the system iteratively updates the object detection model using the stored labeled data. Subsequently, the system collects feedback data in actual applications and continuously optimizes the model to improve the recognition accuracy and sorting effect. At the same time, the system monitors the performance of the new model in real time, analyzes the errors and combines the feedback data to further optimize the sorting strategy to ensure continuous improvement of the model performance.
[0112] In summary, the metal sorting method of the present invention realizes a complete closed-loop from data acquisition, automated annotation, model training to sorting execution by integrating machine vision and self-learning algorithms. This method can be dynamically adjusted and optimized according to the characteristics of different batches of materials, and maintains high-efficiency and precise sorting ability in complex and changeable industrial environments. Through continuous experimental feedback and model optimization, the present invention effectively improves the accuracy and efficiency of metal sorting, while enhancing the robustness and adaptability of the system. Generally speaking, the present invention provides an intelligent and automated metal sorting solution, and its innovation lies in the application of the adaptive learning mechanism, enabling the system to continuously optimize and adapt to various working conditions changes, bringing significant efficiency improvement and technological progress to the metal sorting field.
[0113] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the intelligent metal sorting method based on machine vision technology provided by the embodiment of the present invention are implemented.
[0114] Figure 2 It is a block diagram of a computer device 200 for an intelligent metal sorting method based on machine vision technology shown according to an exemplary embodiment. For example, the computer device 200 can be provided as a server. Referring to Figure 2 , the computer device 200 includes a processor 201, and the number of processors can be set to one or more according to needs. The computer device 200 also includes a memory 202 for storing instructions executable by the processor 201, such as application programs. The number of memories can be set to one or more according to needs. The application programs stored therein can be one or more. The processor 301 is configured to execute instructions to perform the above-mentioned intelligent metal sorting method based on machine vision technology.
[0115] When implementing the present invention, those of ordinary skill in the art can understand that the object detection model involved in the present invention is not limited to using a specific formula or a specific implementation method. The present invention aims to cover all technical solutions that can achieve the same function, including but not limited to alternative solutions that use substantially the same means, achieve substantially the same function, and achieve substantially the same effect. These alternative solutions include but are not limited to using other methods similar to the YOLOv8 object detection model adaptive method to implement the self-learning sorting system, minor adjustments to existing formulas, changes in parameters, optimizations of structures, etc., and these adjustments or changes are obvious to those of ordinary skill in the art.
[0116] Those of ordinary skill in the art should understand that the embodiments of the present invention can be provided as systems and methods. Therefore, the present invention can adopt the form of a complete hardware embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) characterized by containing computer-usable program codes.
[0117] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices produce means for implementing the functions specified in one or more flows and / or one or more blocks. Figure 1 in one or more flows and / or one or more blocks Figure 1 of the specified functions.
[0118] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in one or more flows and / or one or more blocks. Figure 1 in one or more flows and / or one or more blocks Figure 1 of the specified functions.
[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more flows and / or one or more blocks. Figure 1 in one or more flows and / or one or more blocks Figure 1 of the specified functions.
[0120] It should be noted that in the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim listing several means, several of these means can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names.
[0121] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0122] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
[0123] In the description of the present invention, it should be understood that the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, the meaning of "a plurality" is two or more unless otherwise specifically defined.
[0124] In the present invention, unless otherwise clearly specified and defined, the terms such as "mounted", "connected", "connected to", "fixed" and the like should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or integrated; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0125] In the present invention, unless otherwise clearly specified and defined, the first feature being "on" or "under" the second feature may be that the first and second features are in direct contact, or the first and second features are indirectly in contact through an intermediate medium. Moreover, the first feature being "above", "over" and "on top of" the second feature may be that the first feature is directly above or obliquely above the second feature, or merely indicates that the first feature has a higher horizontal height than the second feature. The first feature being "under", "below" and "beneath" the second feature may be that the first feature is directly below or obliquely below the second feature, or merely indicates that the first feature has a lower horizontal height than the second feature.
[0126] In the description of this specification, the description with reference to terms such as "an embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms should not be understood as necessarily referring to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0127] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
Claims
1. An adaptive metal sorting method based on machine vision, characterized in that It includes the following steps: Step 1, Self-learning model training: Collect metal material sample images to generate a virtual annotation dataset; Construct an object detection model based on YOLOv8, and the model integrates a projection head network; Complete model training by jointly optimizing the YOLOv8 detection loss, adversarial training loss, and projection head contrast learning loss; Step 2, Material identification and sorting: Collect real-time material images and perform preprocessing; Use the trained model to identify the metal type and generate a sorting control signal to perform sorting; Step 3: Semi-automated data annotation: Based on the improved information entropy formula H * (x) = H(x) + λf(I), where screen high-uncertainty samples, and generate an annotation database after manual review; Step 4. Model Iterative Optimization: Dynamically adjust the image preprocessing parameters according to the labeled data, and update the model weights by minimizing the joint loss function and apply the updated model parameters to the material recognition and sorting steps.
2. The method according to claim 1, characterized in that, The calculation formula of the adversarial training loss in the first step is L adv = λL YOLO (x, y) + (1 - λ)L YOLO (x adv , y), where the adversarial sample x adv is generated through .
3. The method according to claim 1, characterized in that The contrastive learning loss of the projection head in the first step adopts the InfoNCE loss function where z i , z j are the projection variables of samples of the same category.
4. The method according to claim 1, wherein Step 1 further includes: Deploy the trained model, and online adjust the class weights of the YOLOv8 detection head according to the detection frequency and error distribution of specific target materials to optimize the response to specific features of the materials.
5. The method according to claim 1, characterized in that The preprocessing in Step 2 includes: Perform histogram equalization and brightness compensation in real time; Use a guided filter to eliminate background noise; Dynamically apply gamma correction and contrast stretching according to real-time lighting conditions.
6. The method according to claim 1, characterized in that Identifying the metal type and generating a sorting control signal to perform sorting in Step 2 specifically includes: Calculating the information entropy of the real-time inference result, and triggering multiple inferences of test-time augmentation (TTA) when the information entropy is greater than a preset threshold. The TTA generates multiple groups of inference results by image transformation under different angles and lighting conditions, and determines the final classification result according to weighted voting; After the high-entropy samples are recorded, they are added to the training dataset for key training during the iterative optimization process in Step 4.
7. The method according to claim 1, characterized in that The physical characteristic parameters of the improved information entropy formula in the third step include: I avg is the average gray value of the metal block, I max is the maximum gray value, I min is the minimum gray value, and λ is the weight coefficient optimized through experiments.
8. The method according to claim 1, characterized in that, The model weight adjustment in Step 4 includes: Calculate the sample importance score according to S(x) = αH * (x) + βC(x) + γD(x).
9. A computer-readable storage medium, characterized in that, There is a computer program, and when the computer program is executed, the steps of the method according to any one of claims 1 to 8 are implemented.
10. A computer device, characterized in that, It includes a processor, a memory, and a computer program stored on the memory. When the processor executes the computer program, the steps of the method according to any one of claims 1-8 as described above are implemented.