Improved metallographic detection method of 6 series aluminum alloy during hot forming process based on YOLOv8
By improving the YOLOv8 model and combining it with data enhancement and the EMA attention mechanism, efficient and accurate metallographic detection of 6-series aluminum alloys during the hot forming process was achieved, solving the problems of low detection accuracy and efficiency in existing technologies and providing high-precision metallographic detection results.
Patent Information
- Application Number
- CN202410511125.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-04-26
AI Technical Summary
The existing technology has low accuracy, low detection efficiency and low recognition rate in metallographic detection of 6 series aluminum alloy during hot forming, making it difficult to achieve efficient and accurate metallographic detection.
An improved target detection method based on YOLOv8 is adopted. A data set is formed by collecting and preprocessing TEM metallographic photos. The YOLOv8 model is optimized by combining data enhancement technology and EMA attention mechanism module for training and detection, and the category and location information of aluminum alloy metallographic images are output.
It improves the accuracy and efficiency of aluminum alloy metallographic testing, reduces manual marking errors, and supports the optimization of hot forming process parameters.
Smart Images

Figure CN118865050B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision target detection, and in particular to a metallographic detection method for 6 series aluminum alloys in a hot forming process based on YOLOv8. Background Art
[0002] Hot forming technology is increasingly being used in aluminum alloy stampings. To improve the material's forming properties and reduce the scrap rate of parts, technical software such as Autoform and Abaqus have been used in recent years to simulate the forming process, greatly reducing the actual cost of frequent mold trials and openings, and guiding the optimization of process parameters from a more macro perspective.
[0003] However, from a microscopic perspective, the industry's research on aluminum alloy composition, processing parameters, and microstructural properties has never slowed down. Aluminum alloy microstructure plays a decisive role in its mechanical properties. Small-sized equiaxed grains often give aluminum alloys high yield strength, uniform plastic deformation, and resistance to crack propagation. Therefore, studying the evolution of aluminum alloy microstructure has important physical and practical significance.
[0004] In recent years, with the continuous advancement of computer vision technology and its widespread application in many fields such as robot navigation, intelligent video surveillance, industrial inspection, aerospace, etc., object detection algorithms are becoming a key research and application direction. Currently, object detection methods based on deep learning are mainly divided into two categories:
[0005] One type is based on the Region Proposal Network (RPN). This type of algorithm generates candidate regions in an image and then performs classification and bounding box regression on these candidate regions to accurately locate and identify objects. The other type is single-stage detectors, such as You Only Look Once (YOLO) and Faster R-CNN. These methods detect and classify objects directly within a single network, offering strong real-time performance. Both of these methods are widely used in diverse scenarios and for diverse needs, providing efficient and accurate object detection solutions for various industries.
[0006] The key technical challenge that urgently needs to be addressed is how to achieve precise application of the improved model for metallographic inspection of 6-series aluminum alloys during hot forming, combining the improved target detection capabilities with the specificity of aluminum alloy metallographic images during hot forming to accurately map the types and size distributions of aluminum alloy metallographic structures, thereby achieving efficient and accurate metallographic inspection and reducing the labor cost of repetitive work. Summary of the Invention
[0007] The purpose of the present invention is to address the shortcomings of the existing technology and provide a metallographic detection method for 6 series aluminum alloys in the hot forming process based on YOLOv8 improvement, so as to solve the problems of low accuracy, low detection efficiency and low recognition rate of existing aluminum alloy metallographic detection.
[0008] The technical solution adopted by the present invention to achieve the above-mentioned purpose is:
[0009] A metallographic detection method for 6 series aluminum alloy in a hot forming process based on an improved YOLOv8, comprising the following steps:
[0010] (1) Collect TEM metallographic photographs of 6-series aluminum alloy during hot forming and preprocess the TEM metallographic photographs to form a metallographic dataset of 6-series aluminum alloy;
[0011] (2) Anchoring the metallographic photographs pre-processed in step (1) in VOC mode and generating an .xml annotation file, which includes the position information and category information of the anchor frames;
[0012] (3) Convert the generated .xml annotation file into a .txt annotation file corresponding to the metallographic photograph;
[0013] (4) Using data enhancement technology to expand the original data set;
[0014] (5) The 6-series aluminum alloy metallographic dataset is randomly divided into training set, validation set and test set in a certain proportion;
[0015] (6) The YOLO network framework is used to cluster the real bounding boxes of the 6-series aluminum alloy metallographic dataset to obtain prediction boxes of various scales for the prediction of targets of different scales;
[0016] (7) Introducing the EMA attention mechanism module to optimize the target detection algorithm YOLOv8 model;
[0017] (8) Using the optimized target detection algorithm YOLOv8 model, based on the open source pre-trained weight YOLOV8n.pt file, the training set divided in step (5) is trained, and by adjusting the parameters and testing the validation set, the target detection algorithm YOLOv8 model is optimized until convergence, and the optimal weight file best.pt suitable for metallographic detection of 6 series aluminum alloy is obtained and saved;
[0018] (9) Using the optimal weight parameter file best.pt obtained through training, the test data in the test set divided in step (5) is input into the target detection algorithm YOLOv8 model for detection and evaluation, and the final test results are generated. The image with the prediction frame and the .txt file containing the category and position information of the target phase in the TEM metallographic photograph are output to realize the metallographic detection of the 6 series aluminum alloy during the hot forming process.
[0019] Step (2) specifically includes: using the labelimg plug-in in the pycharm software to annotate the collected TEM metallographic photos with anchor boxes, classifying them according to the categories of the actual metallographic phases in the solid solution state of the 6 series aluminum alloy, and obtaining the marking boxes and text outputs of different categories of metallographic phases.
[0020] The step (4) specifically includes: augmenting the original data set by rotation, brightness enhancement and contrast adjustment to enrich the database in the training set.
[0021] The ratio of step (5) is: randomly dividing the 6 series aluminum alloy metallographic data set into a training set, a validation set and a test set in a ratio of 8:1:1.
[0022] The EMA attention mechanism module in step (7) is specifically formulated as follows:
[0023] θ EMA,t+1 =(1-λ)*θ EMA,t +λ*θ t
[0024] Where θ t is the network parameter at time t, θ EMA,t is the network parameter after sliding average at time t, and the sliding average result at time t+1 is the weighted fusion of the two, and λ is a number close to 1.
[0025] The step (8) of optimizing the target detection algorithm YOLOv8 model to convergence includes accelerating the model convergence during the training process by adjusting parameters such as epoch and batch size in the default.yaml file of YOLOv8.
[0026] The network architecture of the YOLOv8 object detection algorithm includes: Input, Backbone, Neck, Head, Loss, and Detect. Images of different scales are fed into the Input layer. These images pass through the neural network's hierarchical structure, undergoing downsampling by the Backbone and upsampling by the Neck, resulting in feature maps of varying dimensions. This helps capture features of objects at varying scales, enabling the network to more comprehensively understand image content. The Loss calculation process consists of two parts: a positive and negative sample allocation strategy and Loss calculation. Finally, Detect uses convolution to predict features from the input image of varying dimensions and outputs an image with a predicted bounding box and confidence score, along with a text file containing the corresponding category and location information.
[0027] A metallographic detection system for 6-series aluminum alloys during hot forming processes improved based on YOLOv8 comprises a data processing module, a data training module and a result prediction module. The data processing module is used to perform anchor frame annotation and classification on the collected metallographic images of the 6-series aluminum alloys during the hot forming processes to form a metallographic data set, and divide the metallographic data set into a training set, a validation set and a test set. At the same time, the real bounding boxes of the metallographic data set are clustered to obtain prediction boxes of multiple scales. An EMA attention mechanism module is introduced to optimize the target detection algorithm YOLOv8 model, and a metallographic detection system for 6-series aluminum alloys during hot forming processes improved based on YOLOv8 is constructed. The data training module trains the training data of the training set by improving the YOLOv8 model, predicts the position and category of the aluminum alloy metallographic target by using the prediction box, and obtains and saves the optimal weight parameter file best.pt by training with a loss function. The result prediction module uses the optimal weight parameter file best.pt obtained by training to input the test data of the test set into the YOLOv8 model for detection, and outputs the category and position of the aluminum alloy metallographic target.
[0028] A device for metallographic detection of 6-series aluminum alloys during a hot forming process improved based on YOLOv8 includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement the steps of the metallographic detection method of 6-series aluminum alloys during a hot forming process improved based on YOLOv8 when storing the computer program.
[0029] A computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the improved metallographic detection method for 6-series aluminum alloys during hot forming processes based on YOLOv8 are implemented.
[0030] The beneficial effects of the present invention are:
[0031] 1. For metallographic testing of 6-series aluminum alloys during hot forming, this paper uses the YOLOv8 model. Transmission electron microscopy (TEM) is used to collect metallographic photographs of 6-series aluminum alloys under different working conditions. After preprocessing, a 6-series aluminum alloy metallographic dataset is generated. The labelimg plug-in in PyCharm software is used to annotate the metallographic photographs with anchor boxes, and classification is performed based on the actual metallographic classification, making the model more accurate.
[0032] 2. In the data enhancement stage, the present invention adopts a combination of rotation, brightness enhancement and contrast adjustment techniques to cleverly expand the original dataset and improve the diversity of the training set, thereby reducing the risk of overfitting and enhancing the generalization ability and robustness of the model.
[0033] 3. The EMA attention mechanism module is introduced to optimize the target detection algorithm YOLOv8 model, which reduces the number of calculation parameters and improves the detection accuracy.
[0034] 4. The improved YOLOv8 target detection method was introduced and successfully applied to the field of metallographic detection of 6-series aluminum alloys during hot forming. By adjusting parameters such as epoch and batch size in the default.yaml file of YOLOv8, the convergence of the model during training was accelerated. While maintaining high precision, this method effectively improved the detection efficiency of the model, making it perform excellently in metallographic detection of 6-series aluminum alloys. Traditional manual labeling requires manual labeling of each target one by one and is prone to errors. The present invention greatly reduces the errors caused by subjectivity and experience when experimenters manually label metallographically, and at the same time provides technical support for the subsequent adjustment of hot forming process parameters of aluminum alloys. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a specific flow chart of an embodiment of the present invention;
[0036] Figure 2 This is the overall framework diagram of the original YOLOv8;
[0037] Figure 3 Improve the overall framework diagram of YOLOv8 for the present invention;
[0038] Figure 4 This is the principle diagram of the EMA attention mechanism of the present invention
[0039] Figure 5 This is a diagram of the modules of the YOLOv8 framework of the present invention;
[0040] Figure 6 This is one of the actual detection effects of the model of the present invention;
[0041] Figure 7This is the second actual detection effect of the model of the present invention. DETAILED DESCRIPTION
[0042] Example: See Figures 1 to 7 This embodiment provides a metallographic detection method for 6-series aluminum alloy during a hot forming process based on an improved YOLOv8, comprising the following steps: first, using a TEM electron microscope to collect metallographic photographs of the 6-series aluminum alloy during the hot forming process, and preprocessing the TEM metallographic photographs of the 6-series aluminum alloy to form a metallographic dataset of the 6-series aluminum alloy; annotating the preprocessed metallographic photographs with anchor frames in VOC mode, and generating an .xml annotation file, which includes position information and category information of the annotated anchor frames;
[0043] By using manual labeling and pre-trained automatic labeling models, and the labelimg plug-in in the pycharm software, the pre-processed metallographic photos are annotated with anchor boxes, which can greatly save the time cost of early data processing. The 6 series aluminum alloy is classified according to the actual metallographic categories in the solid solution state, and the marking boxes and text outputs of different categories of metallographic images are obtained.
[0044] Specifically, the collected and processed data was screened and categorized into four categories based on the actual metallographic structure of 6-series aluminum alloys in the solid solution state: other alloy aggregates (impurities), GP zone, β'', and β'. Considering the impact of size and recognizing different scales, such as 50nm and 100nm, the inclusion of Greek letters in the path made it difficult for the model to read the data. Therefore, the metallographic labels were simplified, such as "other," "GP," "B2," "B1," and "100nm."
[0045] The generated .xml annotation file is formatted and a .txt annotation file corresponding to the metallographic photograph is generated. The original dataset is expanded using data augmentation technology through a combination of rotation, brightness enhancement, and contrast adjustment techniques to appropriately enrich the database in the training set. The 6-series aluminum alloy metallographic dataset is randomly divided into training set, validation set, and test set in a ratio of 8:1:1. The YOLO network framework is used to cluster the true bounding boxes of the 6-series aluminum alloy metallographic dataset to obtain prediction boxes of various scales for the prediction of targets of different scales. The EMA attention mechanism module is introduced to optimize the target detection algorithm YOLOv8 model. The optimized target detection algorithm YOLOv8 is used. The model is based on the open source pre-trained weight YOLOV8n.pt file, and the divided training set is trained. By adjusting the parameters and testing the validation set, the target detection algorithm YOLOv8 model is optimized until convergence, and the optimal weight file best.pt suitable for metallographic detection of 6 series aluminum alloys is obtained and saved; using the optimal weight parameter file best.pt obtained by training, the test data in the divided test set is input into the target detection algorithm YOLOv8 model for detection and evaluation, and the final test results are generated. The image with the prediction box and the .txt file containing the category and position information of the target phase in the TEM metallographic photograph are output to realize the metallographic detection of 6 series aluminum alloys during the hot forming process.
[0046] The EMA attention mechanism module is specifically formulated as follows:
[0047] θ EMA,t+1 =(1-λ)*θ EMA,t +λ*θ t
[0048] Where θ t is the network parameter at time t, θ EMA,t is the network parameter after sliding average at time t, and the sliding average result at time t+1 is the weighted fusion of the two, and λ is a number close to 1.
[0049] The EMA attention mechanism module is introduced to optimize the target detection algorithm YOLOv8 model, which reduces the number of calculation parameters and improves the detection accuracy.
[0050] Experimental content Precision Parameters YOLOv8 84.5% 3157184 YOLOv8+EMA 86.0% 3022581
[0051] Optimizing the YOLOv8 object detection algorithm model to convergence involves accelerating model convergence during training by adjusting parameters such as epoch and batch size in the YOLOv8 default.yaml file.
[0052] To ensure sufficient network robustness, effectively reduce the risk of overfitting, and improve the generalization of the model, data augmentation techniques were used to expand the dataset while increasing the diversity of target detection during training. This enabled the model to achieve good detection results while maintaining high accuracy.
[0053] The network architecture of the target detection algorithm YOLOv8 model includes: Input, Backbone, Neck, Head, Loss, and Detect. Among them, images of different scales are input through the Input and resized to 640×640 pixels by YOLO. The C2f structure used in the Backbone and Neck of YOLOv8 refers to the design concept of ELAN of YOLOv7 and is used to replace the CSP structure in YOLOv5. Since the C2f structure has more residual connections, it has a richer gradient flow. The Task Aligned Assigner positive sample matching strategy is adopted for Loss calculation, and Distribution Focal Loss is introduced. In the Head of YOLOv8, there is no longer the previous Obj branch, only decoupled classification and regression branches, and the regression branch uses the integral form representation mentioned in Distribution Focal Loss.
[0054] Using the optimal weight parameter file (best.pt) obtained through training, the test set data was fed into the YOLOv8 model. Feature extraction and aggregation were performed within the model, ultimately resulting in the Detect layer generating bounding box coordinates, corresponding confidence scores, and class probabilities for objects that may contain aluminum alloy metallographic targets. To improve detection accuracy, non-maximum suppression was used to remove redundant detection boxes, resulting in a refined final detection result. This process effectively detects aluminum alloy metallographic targets, outputting the target's specific category and accurate location information.
[0055] A metallographic detection system for 6-series aluminum alloys during hot forming processes improved based on YOLOv8 comprises a data processing module, a data training module and a result prediction module. The data processing module is used to perform anchor frame annotation and classification on the collected metallographic images of the 6-series aluminum alloys during the hot forming processes to form a metallographic data set, and divide the metallographic data set into a training set, a validation set and a test set. At the same time, the real bounding boxes of the metallographic data set are clustered to obtain prediction boxes of multiple scales. An EMA attention mechanism module is introduced to optimize the target detection algorithm YOLOv8 model, and a metallographic detection system for 6-series aluminum alloys during hot forming processes improved based on YOLOv8 is constructed. The data training module trains the training data of the training set by improving the YOLOv8 model, predicts the position and category of the aluminum alloy metallographic target by using the prediction box, and obtains and saves the optimal weight parameter file best.pt by training with a loss function. The result prediction module uses the optimal weight parameter file best.pt obtained by training to input the test data of the test set into the YOLOv8 model for detection, and outputs the category and position of the aluminum alloy metallographic target.
[0056] A device for metallographic detection of 6-series aluminum alloys during a hot forming process improved based on YOLOv8 includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement the steps of the metallographic detection method of 6-series aluminum alloys during a hot forming process improved based on YOLOv8 when storing the computer program.
[0057] A computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the improved metallographic detection method for 6-series aluminum alloys during hot forming processes based on YOLOv8 are implemented.
[0058] The above description is only a preferred embodiment of the present invention and is not intended to limit the patent scope of the present invention. Therefore, any changes in the method steps made using the contents of the present invention specification are included in the protection scope of the present invention.
Claims
1. A metallographic detection method for 6 series aluminum alloys in hot forming process based on YOLOv8 improvement, characterized in that: It includes the following steps: (1) Collect TEM metallographic photographs of 6-series aluminum alloy during hot forming and preprocess the TEM metallographic photographs to form a metallographic dataset of 6-series aluminum alloy; (2) Using the labelimg plug-in in pycharm software, perform anchor frame annotation on the metallographic photograph preprocessed in step (1) in VOC mode, and generate an .xml annotation file, which includes the position information and category information of the annotation anchor frame; (3) Convert the generated .xml annotation file into a .txt annotation file corresponding to the metallographic photograph; (4) Using data enhancement technology to expand the original data set; (5) The 6-series aluminum alloy metallographic dataset is randomly divided into training set, validation set and test set in a certain proportion; (6) The YOLO network framework is used to cluster the real bounding boxes of the 6-series aluminum alloy metallographic dataset to obtain prediction boxes of various scales for the prediction of targets of different scales; (7) Introducing the EMA attention mechanism module to optimize the target detection algorithm YOLOv8 model; (8) Using the optimized target detection algorithm YOLOv8 model, based on the pre-trained weight YOLOV8n.pt file, the training set divided in step (5) is trained, and by adjusting the parameters and testing the validation set, the target detection algorithm YOLOv8 model is optimized until convergence, and the optimal weight file best.pt suitable for metallographic detection of 6 series aluminum alloy is obtained and saved; (9) Using the optimal weight parameter file best.pt obtained through training, the test data in the test set divided in step (5) is input into the target detection algorithm YOLOv8 model for detection and evaluation, and the final test results are generated. The image with the prediction frame and the .txt file containing the category and position information of the target phase in the TEM metallographic photograph are output to realize the metallographic detection of the 6 series aluminum alloy during the hot forming process.
2. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 improvement according to claim 1 is characterized in that: Step (2) specifically includes: using the labelimg plug-in in the pycharm software to annotate the collected TEM metallographic photos with anchor boxes, classifying them according to the categories of the actual metallographic phases in the solid solution state of the 6 series aluminum alloy, and obtaining the marking boxes and text outputs of different categories of metallographic phases.
3. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 improvement according to claim 1 is characterized in that: The step (4) specifically includes: augmenting the original data set by rotation, brightness enhancement and contrast adjustment to enrich the database in the training set.
4. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 according to claim 1 is characterized in that: The ratio of step (5) is: randomly dividing the 6 series aluminum alloy metallographic data set into a training set, a validation set and a test set in a ratio of 8:1:
1.
5. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 improvement according to claim 1 is characterized in that: The EMA attention mechanism module in step (7) uses the following formula: i EMA,t+1 =(1-λ)*θ EMA,t +λ*θ t Where θ t is the network parameter at time t, θ EMA,t is the network parameter after sliding average at time t, and the sliding average result at time t+1 is the weighted fusion of the two, and λ is a number close to 1.
6. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 improvement according to claim 1 is characterized in that: The step (8) of optimizing the target detection algorithm YOLOv8 model to convergence includes accelerating the model convergence during the training process by adjusting parameters such as epoch and batch size in the default.yaml file of YOLOv8.
7. The metallographic detection method of 6 series aluminum alloy in hot forming process based on YOLOv8 according to claim 1 is characterized in that: The network architecture of the target detection algorithm YOLOv8 model includes: Input, Backbone, Neck, Head, Loss and Detect. Among them, images of different scales are input through Input, and the images of different scales are processed through the hierarchical structure of the neural network, down-sampling by Backbone and up-sampling by Neck to obtain feature maps of different dimensions. The Loss calculation process includes two parts: positive and negative sample allocation strategy and Loss calculation. Finally, Detect uses convolution to predict the input image features of different dimensions and outputs an image with a predicted box and confidence level, as well as a text file with corresponding category and location information.
8. A metallographic detection system for 6 series aluminum alloys in hot forming process based on YOLOv8, characterized in that: It includes a data processing module, a data training module and a result prediction module; the data processing module is used to collect the metallographic images of 6 series aluminum alloys in the hot forming process, use the labelimg plug-in in the pycharm software, perform anchor frame annotation and classification in the VOC mode, form a 6 series aluminum alloy metallographic data set, and divide it into a training set, a validation set and a test set, and use the YOLO network framework to cluster the real bounding boxes of the 6 series aluminum alloy metallographic data set to obtain prediction boxes of various scales; introduce the EMA attention mechanism module, optimize the target detection algorithm YOLOv8 model, and construct the metallographic detection of 6 series aluminum alloys in the hot forming process improved based on YOLOv8; the data training module uses the optimized target detection algorithm YOLOv8 model based on pre-training The training data of the training set are trained using the weighted YOLOV8n.pt file, the position and category of the aluminum alloy metallographic target are predicted using the prediction box, the target detection algorithm YOLOv8 model is trained through the loss function in the optimized target detection algorithm, and the target detection algorithm YOLOv8 model is optimized until convergence by adjusting parameters and testing the validation set, and the optimal weight parameter file best.pt suitable for metallographic detection of 6 series aluminum alloys is obtained and saved; the result prediction module uses the optimal weight parameter file best.pt obtained by training, inputs the test data of the test set into the YOLOv8 model for detection, and outputs an image with a prediction box and a .txt file containing the category and position information of the target phase in the TEM metallographic photograph, thereby realizing the metallographic detection of 6 series aluminum alloys during the hot forming process.
9. A metallographic detection device for 6 series aluminum alloys in hot forming process based on YOLOv8, characterized in that: including memory and processor; memory for storing computer programs; A processor, configured to implement the steps of the improved YOLOv8-based metallographic detection method for 6-series aluminum alloys during hot forming as claimed in any one of claims 1 to 7 when storing a computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the metallographic detection method of 6-series aluminum alloy in the hot forming process improved based on YOLOv8 are implemented as described in one of claims 1 to 7.
Citation Information
Patent Citations
Extrusion die and aluminum alloy profile extrusion method
CN112792149A
Quantitative statistical characterization method of micron-level second phase in aluminum alloy based on deep learning
US20230184703A1