Hydraulic pump parts complete set detection method based on improved convolutional neural network
By improving the convolutional neural network and YOLOV8s target detection algorithm, a hydraulic pump parts complete detection model is established, which solves the problem of low efficiency of traditional manual detection, realizes automated parts complete detection, improves detection accuracy and efficiency, and ensures the hydraulic pump Correct matching of parts.
Patent Information
- Application Number
- CN202410273026.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-03-11
AI Technical Summary
Traditional inspection of complete sets of hydraulic pump parts relies on manual verification, which is inefficient and can easily lead to missing or misplaced parts, affecting product quality.
A hydraulic pump parts complete detection method based on an improved convolutional neural network is adopted. By establishing a hydraulic pump parts complete detection model, using the YOLOV8s target detection algorithm and adding the convolution block attention mechanism module, a hydraulic pump parts image data set is constructed. Model training and verification, and building a hardware system to implement automatic detection.
It greatly reduces the probability of human errors, improves detection efficiency and quality, ensures the completeness and accuracy of hydraulic pump parts, reduces time costs, and improves production efficiency.
Smart Images

Figure CN117876371B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quality control of aerospace hydraulic pump assembly process, and in particular to a method for detecting a complete set of hydraulic pump parts based on an improved convolutional neural network. Background Art
[0002] Aerospace hydraulic pumps are an important part of aerospace equipment, providing continuous pressure and flow supply for the hydraulic system. They have complex structures, a wide variety of components, and strict quality control during the assembly process. In the assembly process of aerospace hydraulic pumps, there are repeated assembly and disassembly and multiple tests. There is a connection between the parts of the hydraulic pump after the initial assembly. If they are mixed with other hydraulic pump parts, it will affect the product quality. Therefore, the process requires the establishment of parts control means, that is, to perform matching operations on the hydraulic pump before assembly operations. Matching operations refer to placing all parts of the entire hydraulic pump product or component in a pallet container (trace management box) to form a set of parts that meet the needs of assembly operations. The inspection process of manually checking whether the parts are complete is called complete set inspection.
[0003] Traditional matching operations rely on manual verification of part types and quantities, which results in low inspection efficiency. Manual visual inspection also causes visual fatigue, which can easily lead to problems such as missing or misplacing parts, affecting product quality. When a hydraulic pump undergoes a complete set inspection without quality control, problems such as missing parts and part confusion may occur during the subsequent assembly process. At this time, the entire hydraulic pump needs to be taken offline, which greatly affects assembly efficiency and quality. Summary of the invention
[0004] The present invention provides a method for detecting the complete set of hydraulic pump parts based on an improved convolutional neural network to solve the technical problems raised in the background technology.
[0005] The technical solution adopted by the present invention to solve the above technical problems is:
[0006] The hydraulic pump parts complete set detection method based on improved convolutional neural network includes the following steps:
[0007] Step S1. Establish a hydraulic pump parts complete set detection model: Based on the basic target detection algorithm network model, establish an improved convolutional neural network hydraulic pump parts complete set detection model.
[0008] Step S2. Constructing a hydraulic pump parts image dataset: by photographing a plurality of hydraulic pump parts images in the field of supporting operations, processing the collected hydraulic pump parts images, and producing a hydraulic pump parts image dataset.
[0009] Step S3. Verify the hydraulic pump parts complete set detection model: use the hydraulic pump parts image data set to train and test the parts complete set detection model to verify the detection accuracy and speed of the hydraulic pump parts complete set detection model.
[0010] Step S4. Test the hydraulic pump parts complete set detection model: build a parts complete set detection hardware system, deploy the hydraulic pump parts complete set detection model in the cloud server, transmit data between the industrial computer and the server, realize the back-end parts complete set detection and front-end result display, and complete the test of the parts complete set detection method.
[0011] As a further preferred embodiment of the present invention, the specific steps of step S1 are:
[0012] S11. Select a basic target detection algorithm: The basic target detection algorithm is the YOLOV8s target detection algorithm, and the network structure includes an input end, feature extraction, feature fusion and a detection head; the hydraulic pump part image is input at the input end and adaptively scaled to a size of 640×640 pixels, and three feature maps of different sizes of 20×20, 40×40, and 80×80 are obtained through the feature extraction network. The three feature maps of different sizes are passed through a top-down and bottom-up path aggregation network, and feature fusion is performed to obtain a feature map containing high-level strong semantic information and low-level positioning information, and the detection head is used to predict the final result.
[0013] S12. Improve the basic algorithm: Improve the data enhancement module in the YOLOV8s target detection algorithm to Mosaic-9: Select nine different feature maps and randomly splice them into one image, so that more data information can be obtained in one image, while increasing the number of small target objects, and in disguise increasing the number of single-batch training data, reducing the amount of calculation.
[0014] S13. Establish algorithm model:
[0015] S131. Add a convolution block attention mechanism module: the convolution block attention mechanism module consists of a channel attention module and a spatial attention module. The channel attention module and the spatial attention module adaptively adjust the importance of different channels and different positions in the feature map by learning the weight of each channel and the weight of each position respectively; the calculation formula of the convolution block attention mechanism module is as follows:
[0016] ,
[0017] In the formula, the input feature is defined as , the one-dimensional channel attention weight is defined as , the two-dimensional spatial attention weight is defined as , F is used as the input of the channel attention module and is derived , and then F and The result after multiplication As the input of the spatial attention module and derive , and eventually and Multiply to get the refined output features .
[0018] In the channel attention module, the input feature F is subjected to maximum pooling and average pooling to generate maximum pooling features And average pooling features , the input feature map size is changed from becomes , and then through the shared multi-layer perceptron module, the number of channels is compressed and then expanded to the original number of channels, and the channel attention weights are obtained by element-by-element addition. Finally, the attention weights are normalized by the Sigmoid function to obtain ;
[0019] In the spatial attention module, the features processed by the channel attention module are The maximum pooling feature is obtained by maximum pooling and average pooling And average pooling features , the feature map size is changed from becomes , then the two feature maps are spliced, and the attention weights are normalized by 7*7 convolution and Sigmoid function to obtain ; The above process is summarized into the following formula:
[0020] ,
[0021] ,
[0022] Step S132. Add the target detection result processing module: The target detection result processing module defines the input as the type of part detected ,quantity and location , in the module with the correct type of hydraulic pump parts ,quantity ,Location To compare, first determine whether the types and quantities of parts are consistent, and then determine whether the parts are located in the same place. If all errors are within the allowable error range, the detection result is output as correct, otherwise the detection result is output as wrong. The calculation formula of the target detection result processing module is as follows:
[0023]
[0024] As a further preferred embodiment of the present invention, the specific steps of step S2 are:
[0025] S21. Image acquisition of hydraulic pump parts: Build a shooting site and classify the hydraulic pump complete set detection conditions, including complete parts, incomplete parts and no parts. Image acquisition is performed on the complete set detection of various models of hydraulic pumps in each of the three conditions.
[0026] S22. Hydraulic pump parts image annotation: Use Labelme open source image annotation tool to annotate the collected hydraulic pump parts images, store the location and category information of the hydraulic pump parts in Json format files, and then use Python script program to batch read Json files and convert them into TXT files containing category label and normalized annotation center point X-axis coordinate x, annotation center point Y-axis coordinate y, annotation width w, and annotation height h information.
[0027] S23. Data enhancement of hydraulic pump parts images and division of data sets: Using a python script program, the annotated hydraulic pump parts images are enhanced by translation, rotation, scaling, mirroring, cropping, and contrast and brightness adjustment. At the same time, the part position information in the annotation file is adjusted, and the annotated and data-enhanced hydraulic pump parts images are divided according to a preset ratio to obtain sample training sets and test sets, which are determined as the hydraulic pump parts image data set.
[0028] As a further preferred embodiment of the present invention, the specific steps of step S3 are:
[0029] S31. Model pre-training: Load the hydraulic pump parts image data training set established in step S2, and pre-train the hydraulic pump parts complete set detection model established in step S1. The model training iteration batch is 150 times to obtain a pre-training parameter data file.
[0030] S32. Dataset and parameter optimization: Use the pre-trained parameter data file to detect the hydraulic pump parts image test set. After obtaining the preliminary detection results, re-collect and expand the data set for parts with low accuracy, and readjust the model training parameters. Re-train the hydraulic pump parts complete set detection model established in step S1, and the model training iteration batch is 150 times.
[0031] S33. Model effect evaluation: Load the model parameter file, use the hydraulic pump parts complete set detection model, detect on the hydraulic pump parts image verification set, use the average precision mAP@0.5 when the IoU threshold is 0.5 and the average precision mAP@0.95 at different IoU thresholds as evaluation indicators, and find that its accuracy meets the usage requirements; among which, the different IoU thresholds are 0.5~0.95, and the step size is 0.05; the calculation formula of the average precision mAP is as follows:
[0032] ,
[0033] In the formula, It is the target detection result for a certain category, K is the number of categories, and the average precision is Represents the area between the PR curve and the horizontal and vertical axes. The PR curve is drawn by the algorithm's precision P and recall R. The precision P refers to the ratio of correctly predicted positive samples to all positive samples, and the recall R refers to the ratio of correctly predicted positive samples to the true positive samples.
[0034] As a further preferred embodiment of the present invention, the specific steps of step S4 are:
[0035] S41. Build the test environment: Build a complete set of hydraulic pump parts detection hardware system, which consists of industrial cameras, industrial computers, conveyor belts, PLCs, buttons, motors, production vehicles, etc.; PLC reads the camera release button signal and controls the motor operation signal, establishes Ethernet communication with PLC through the host computer software in the industrial computer, and uses Opencv visual library to control the industrial camera. Fastapi communication is used to establish data transmission between the industrial computer and the server.
[0036] S42. Test model effect: Use Winform framework to develop host computer software, use C# programming language to establish communication with PLC and control industrial camera in the back end, develop visualization page in the front end, use Docker technology to publish Fastapi service in Windows Server, start hydraulic pump parts complete set detection model in this service through Python programming language, and wait for detection signal and detection image transmitted by host computer software.
[0037] Compared with the prior art, the present invention has the following advantages or technical effects:
[0038] By collecting images of hydraulic pump parts in matching operations, using the hydraulic pump parts matching detection model to infer the matching results, an error prevention mechanism in hydraulic pump matching operations is provided and established. This mechanism uses machine vision instead of human eyes to determine whether the parts are complete, greatly reducing the probability of human errors in the matching process, reducing time costs, improving production efficiency and quality, and achieving the purpose of controlling the quality of matching operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0040] Figure 1 This is a flow chart of the complete set detection of hydraulic pump parts based on the improved convolutional neural network of the present invention;
[0041] Figure 2 Improved convolutional neural network structure diagram for the present invention;
[0042] Figure 3 A simulation diagram of the hydraulic pump parts complete set detection hardware system established by the present invention;
[0043] Figure 4 A physical diagram of the hydraulic pump parts complete set detection hardware system established for the present invention;
[0044] Figure 5 This is a diagram of the hydraulic pump parts complete set detection results based on the improved convolutional neural network of the present invention. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] like Figure 1 As shown, the present invention provides a method for detecting a complete set of hydraulic pump parts based on an improved convolutional neural network, comprising four steps of establishing a complete set detection mode for hydraulic pump parts, constructing an image data set for hydraulic pump parts, verifying a complete set detection model for hydraulic pump parts, and testing a complete set detection model for hydraulic pump parts.
[0047] Step S1, establishing a complete set detection model for hydraulic pump parts:
[0048] In order to establish a complete set of parts detection model with detection accuracy and detection speed that meet the needs of industrial sites, according to the development status of target detection technology, a suitable basic algorithm model is selected, and network improvements are performed on it to establish a complete set of parts detection model suitable for hydraulic pumps. The specific steps are as follows:
[0049] Step S11, select the basic target detection algorithm: the basic target detection algorithm is the YOLOV8s target detection algorithm, and the network structure includes an input end, feature extraction, feature fusion and a detection head. First, the hydraulic pump part image is input at the input end (Input) and adaptively scaled to 640×640 pixels. Then, the feature extraction network (Backbone) is used to obtain feature maps of three different sizes: 20×20, 40×40, and 80×80. The three different sizes of feature maps are then passed through the top-down and bottom-up path aggregation network (Path Aggregation Network, PAN). After feature fusion, a feature map containing high-level strong semantic information and low-level positioning information is obtained, and the final result is predicted by the detection head.
[0050] The input part mainly includes mosaic data enhancement, adaptive image scaling and other technologies. Mosaic data enhancement was proposed by YOLO v4. It randomly crops, scales and arranges four images into one image as training data. It can increase the diversity of the data set and provide more background and target combinations, thereby helping the model to better learn the contextual information and positional relationship of the target object. The adaptive image scaling technology was proposed by YOLO v5. By designing the most suitable size for the image, adding the least gray edge to fill the missing edge, retaining the characteristics of the image, reducing the amount of calculation, and improving the reasoning speed.
[0051] The feature extraction part is the backbone network, including Conv, C2f and SPPF modules. The Conv module consists of a convolution layer, a batch normalization layer, and a SiLu activation function. It extracts features through convolution operations and accelerates model convergence through batch normalization operations. The C2f module is used to learn residual features and enrich the gradient flow information of the model through more branch cross-layer links. The SPPF module is a spatial pyramid pooling module. Without changing the size of the feature map, it performs pooling operations on feature maps of different scales to achieve the fusion of local features and global features at the feature map level.
[0052] The feature fusion part adopts the PANet structure. The feature maps of three different sizes, 20×20, 40×40, and 80×80, are obtained by the feature extraction part. After upsampling and channel fusion, the three output branches of PAN are finally sent to the detection head for loss calculation and result solution.
[0053] The detection head decouples the classification and detection processes, mainly including loss calculation and target detection box screening. The loss calculation includes two branches: classification and regression. The classification branch uses BCE Loss, and the regression branch uses Distribution Focal Loss and CIOU loss functions.
[0054] Step S12, improve the basic algorithm: improve the data enhancement module in the YOLOv8s target detection algorithm to Mosaic-9. The original data enhancement method in YOLOv8s is to divide four different images into four regions according to a certain ratio, and randomly splice these regions into a new synthetic image to improve the model's target detection and generalization capabilities in complex situations. Instead, randomly splicing nine different images into one image can obtain more data information in one image, while increasing the number of small target objects, and in disguise increasing the number of single-batch training data, reducing the amount of calculation.
[0055] Step S13: Establishing an algorithm model:
[0056] Step S131, add the Convolutional Block Attention Module (CBAM): The Convolutional Block Attention Module consists of a Channel Attention Module (CAM) and a Spatial Attention Module (SAM). The Channel Attention Module and the Spatial Attention Module respectively learn the weight of each channel and the weight of each position to adaptively adjust the importance of different channels and different positions in the feature map to enrich the target feature information and improve the accuracy of the algorithm. The calculation process of CBAM can be summarized as the following formula:
[0057] ,
[0058] In the formula, the input feature is defined as , the one-dimensional channel attention weight is defined as , the two-dimensional spatial attention weight is defined as , F is used as the input of the channel attention module and is derived , and then F and The result after multiplication As the input of the spatial attention module and derive , and eventually and Multiply to get the refined output features ;
[0059] In the channel attention module, the input feature F is subjected to maximum pooling and average pooling to generate maximum pooling features And average pooling features , the input feature map size is changed from becomes , and then through the shared multi-layer perceptron module, the number of channels is compressed and then expanded to the original number of channels, and the channel attention weights are obtained by element-by-element addition. Finally, the attention weights are normalized by the Sigmoid function to obtain ;
[0060] In the spatial attention module, the features processed by the channel attention module are The maximum pooling feature is obtained by maximum pooling and average pooling And average pooling features , the feature map size is changed from becomes , then the two feature maps are spliced, and the attention weights are normalized by 7*7 convolution and Sigmoid function to obtain ; The above process is summarized into the following formula:
[0061] ,
[0062] ,
[0063] Step S132. Add the target detection result processing module: The target detection result processing module defines the input as the type of part detected ,quantity and location , in the module with the correct type of hydraulic pump parts ,quantity ,Location To compare, first determine whether the types and quantities of parts are consistent, and then determine whether the parts are located in the same place. If all errors are within the allowable error range, the detection result is output as correct, otherwise the detection result is output as wrong. The calculation formula of the target detection result processing module is as follows:
[0064] ,
[0065] Step S2: Construction of hydraulic pump parts image dataset:
[0066] Provide training and verification samples for the complete set detection model established in step S1, and produce a hydraulic pump parts image dataset. The specific process is as follows:
[0067] Step S21, hydraulic pump parts image acquisition: set up shooting equipment, select the CMOS sensor industrial camera with a focal length of 3.6mm and a resolution of 2560*1440, set the LED fill light to improve the on-site lighting conditions by using a forward high-angle bathing light source. Classify the hydraulic pump complete set detection situation, and divide it into three situations after considering positive and negative samples: complete parts, incomplete parts, and no parts. Image acquisition is performed for the four models of hydraulic pump complete set detection in the three situations, and a total of 6356 images are collected, including 400 background images without parts.
[0068] Step S22, hydraulic pump parts image annotation: use Labelme open source image annotation tool to annotate the collected hydraulic pump parts images, store the location and category information of the hydraulic pump parts, and other metadata related to the hydraulic pump parts images in Json format files, and then use the python script program to batch read the Json files and convert them into TXT files containing the category label and the normalized annotation center point X-axis coordinate x, the annotation center point Y-axis coordinate y, the annotation width w, and the annotation height h information.
[0069] Step S23, data enhancement of hydraulic pump parts images and division of data sets: using a python script program, the annotated hydraulic pump parts images are enhanced by translation, rotation, scaling, mirroring, cropping, contrast and brightness adjustment, etc., to expand the data set and improve the model robustness. At the same time, the part position information in the annotation file is adjusted accordingly, and then the annotated and data-enhanced hydraulic pump parts images are divided according to a preset ratio, and the sample training set, test set and validation set are obtained according to the preset ratio of 8:1:1, which are determined as the hydraulic pump parts image data set.
[0070] Step S3: Hydraulic pump parts complete set detection model verification:
[0071] In order to verify whether the detection accuracy and speed of the parts complete set detection model established in step S1 meet the requirements of the industrial site, the hydraulic pump parts complete set detection model is trained and tested. The specific steps are as follows:
[0072] Step S31, model pre-training: load the hydraulic pump parts image data training set established in step S2, and perform pre-training on the hydraulic pump parts complete set detection model established in step S1, using a computer with a GPU of NVIDIA GeForce RTX3090, a CPU of Xeon(R) Platinum 8358P, an operating system of Windows 10, a computer language of Python 3.8, and a deep learning framework of Pytorch1.11.0. 64 images are trained per round, and 8 training processes are used for a total of 150 rounds of training to obtain a pre-training parameter data file.
[0073] Step S32, data set and parameter optimization: Use the pre-trained parameter data file to detect the hydraulic pump parts image test set. After obtaining the preliminary detection results, re-collect and amplify the data set for the types of parts with low accuracy, and readjust the model training parameters. Re-train the hydraulic pump parts complete set detection model established in step S1, and the model training iteration batch is 150 times.
[0074] Step S33, model effect evaluation: load the model parameter file, use the hydraulic pump parts complete set detection model, detect on the hydraulic pump parts image verification set, use the average precision mean mAP@0.5 when the IoU threshold is 0.5 and the average precision mean mAP@0.95 at different IoU thresholds (from 0.5 to 0.95, step size 0.05) as evaluation indicators, which are 96.62 and 89.92 respectively, corresponding to the basic algorithm, respectively, increased by 2.04% and 1.24%, meeting the usage requirements.
[0075] Step S4: Hydraulic pump parts complete set detection model test:
[0076] In order to deploy the model in the supporting workstation and further test the industrial application effect of the hydraulic pump parts complete set detection model, the specific steps are as follows:
[0077] Step S41, build test environment: build a complete set of hydraulic pump parts detection hardware system, the system consists of industrial cameras, industrial computers, conveyor belts, PLCs, buttons, motors, production vehicles, etc. The system simulation diagram is as follows Figure 3 As shown, the actual scene Figure 4 As shown. The PLC reads the camera release button signal and controls the motor operation signal, establishes Ethernet communication with the PLC through the host computer software in the industrial computer, and uses the Opencv visual library to control the industrial camera. The industrial computer and the server use the Fastapi communication method to establish data transmission.
[0078] Step S42, test model effect: Use Winform framework to develop host computer software, establish communication with PLC and control industrial camera through C# programming language at the back end, develop visualization page at the front end to guide workers to perform parts integrity detection. Use Docker technology to publish Fastapi service in Windows Server, start hydraulic pump parts integrity detection model in Python programming language in this service, and wait for detection signal and detection image transmitted by host computer software.
[0079] The completeness inspection process is as follows: first, when the production carrier is transported to the supporting workstation, the supporting operation is carried out normally. When the supporting operation is completed, the photo release button is pressed. When the control signal is read by the host computer, a photo is taken through the industrial camera, and the image to be inspected is transmitted to the server; then the parts completeness inspection of the image is carried out on the server, and the inspection results are fed back to the host computer software. The results are displayed through a visualization window. If the inspection results are correct, the release signal is transmitted to the PLC through the host computer software. The PLC controls the motor to run, and the production carrier is transported to the next workstation. At this point, the parts completeness inspection of this supporting operation is completed.
[0080] The results of parts completeness test are as follows Figure 5 As shown, it is divided into front-end result display and back-end data transmission. Workers can directly see the parts completeness detection results through the front-end page, and can ensure the accuracy of the detection results through manual secondary inspection. During the back-end data transmission process, the server and the host computer software transmit the detection results through Json format files, including part type, number, location, confidence and judgment results.
[0081] It can be seen that the present invention establishes an error-proofing mechanism in the matching operation of the hydraulic pump by collecting images of hydraulic pump parts in the matching operation and using the hydraulic pump parts completeness detection model to infer the completeness results, thereby ensuring that the types, quantities and positions of parts in the matching operation are correct, greatly reducing the problems of missing parts, confusion of parts caused by human factors, and improving production efficiency while ensuring product quality.
[0082] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A complete set detection method for hydraulic pump parts based on improved convolutional neural network, characterized in that: The steps include: Step S1. Establishing a hydraulic pump parts complete set detection model: Based on the basic target detection algorithm network model, an improved convolutional neural network hydraulic pump parts complete set detection model is established, including the following steps: Step S11. Select a basic target detection algorithm: the basic target detection algorithm is the YOLOV8s target detection algorithm, and the network structure includes an input end, feature extraction, feature fusion and a detection head; a hydraulic pump part image is input at the input end and adaptively scaled to a size of 640×640 pixels, and feature maps of three different sizes of 20×20, 40×40 and 80×80 are obtained through a feature extraction network. The feature maps of the three different sizes are passed through a top-down and bottom-up path aggregation network, and feature fusion is performed to obtain a feature map containing high-level strong semantic information and low-level positioning information, and the detection head is used to predict the final result; Step S12. Improve the basic algorithm: improve the data enhancement module in the YOLOV8s target detection algorithm to Mosaic-9: select nine different feature maps and randomly splice them into one image, and collect the data information in the image; Step S13: Establishing an algorithm model: Step S131. Add a convolutional block attention mechanism module: The convolutional block attention mechanism module consists of a channel attention module and a spatial attention module. The channel attention module and the spatial attention module adaptively adjust the importance of different channels and different positions in the feature map by learning the weight of each channel and the weight of each position respectively; the calculation formula of the convolutional block attention mechanism module is as follows: In the formula, the input feature is defined as F∈R C×H×W , the one-dimensional channel attention weight is defined as M C ∈R C×1×1 , the two-dimensional spatial attention weight is defined as M S ∈R 1×H×W , F is used as the input of the channel attention module and M is derived C , and then F and M C The multiplication result F′ is used as the input of the spatial attention module and M is derived. S , and finally F′ and M S Multiply them together to get the refined output feature F″; In the channel attention module, the input feature F is subjected to maximum pooling and average pooling to generate maximum pooling features And average pooling features The input feature map size is changed from C×H×W to C×1×1, and then the number of channels is compressed and expanded to the original number of channels through the shared multi-layer perceptron module, and the channel attention weights are obtained by element-by-element addition. Finally, the attention weights are normalized by the Sigmoid function to obtain M C ; In the spatial attention module, the feature F′ processed by the channel attention module is obtained by maximum pooling and average pooling to obtain the maximum pooling feature And average pooling features The feature map size is changed from C×H×W to 1×H×W, and then the two feature maps are spliced, and then the attention weights are normalized by 7×7 convolution and Sigmoid function to obtain M S ; The above process is summarized into the following formula: M C (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F))) M S (F)=σ(f 7×7 ([AvgPool(F);MaxPool(F)])) Step S132. Add the target detection result processing module: The target detection result processing module defines the input as the detected part type T d , quantity Q d and position L d , in the module with the correct hydraulic pump part type T t , quantity Q t 、Location L t Compare and first determine whether the types and quantities of parts are consistent, and then determine whether the positions of parts are within the allowable error range of A. If everything is correct, the test result is output as correct, otherwise the test result is output as wrong; The calculation formula of the target detection result processing module is as follows: Step S2. Constructing a hydraulic pump parts image dataset: by photographing multiple hydraulic pump parts images in the field of supporting operations, processing the collected hydraulic pump parts images, and producing a hydraulic pump parts image dataset, including the steps of: Step S21. Image acquisition of hydraulic pump parts: set up a shooting site, classify the hydraulic pump complete set detection conditions, including complete parts, incomplete parts and no parts, and collect images of various models of hydraulic pump complete set detection in the three conditions; Step S22. Hydraulic pump parts image annotation: Labelme open source image annotation tool is used to annotate the collected hydraulic pump parts images, and the location and category information of the hydraulic pump parts are stored in Json format files. Then, a python script is used to batch read the Json files and convert them into TXT files containing the category label and the normalized information of the annotation center point X-axis coordinate x, the annotation center point Y-axis coordinate y, the annotation width w, and the annotation height h; Step S23. Data enhancement of hydraulic pump parts images and division of data sets: using a python script program, the annotated hydraulic pump parts images are subjected to data enhancement processing by translation, rotation, scaling, mirroring, cropping and contrast and brightness adjustment. At the same time, the part position information in the annotation file is adjusted, and the annotated and data-enhanced hydraulic pump parts images are divided according to a preset ratio to obtain a sample training set and a test set, which are determined as a hydraulic pump parts image data set; Step S3. Verify the hydraulic pump parts complete set detection model: Use the hydraulic pump parts image data set to train and test the parts complete set detection model, and verify the detection accuracy and speed of the hydraulic pump parts complete set detection model, including the steps of: Step S31. Model pre-training: Load the hydraulic pump parts image data training set established in step S2, and perform pre-training on the hydraulic pump parts complete set detection model established in step S1. The model training iteration batch is 150 times, and a pre-training parameter data file is obtained; Step S32. Dataset and parameter optimization: Use the pre-trained parameter data file to detect the hydraulic pump parts image test set. After obtaining the preliminary detection results, re-collect and expand the data set for the parts with low accuracy, and readjust the model training parameters. Re-train the hydraulic pump parts complete set detection model established in step S1, and the model training iteration batch is 150 times; Step S33. Model effect evaluation; Step S4. Testing the hydraulic pump parts complete set detection model: Building a parts complete set detection hardware system, deploying the hydraulic pump parts complete set detection model in the cloud server, and transmitting data between the industrial computer and the server to achieve back-end parts complete set detection and front-end result display, and completing the test of the parts complete set detection method, including the following steps: Step S41. Build a test environment: Build a complete set of hydraulic pump parts detection hardware system, which consists of an industrial camera, an industrial computer, a conveyor belt, a PLC, a button, a motor, and a production carrier; the PLC reads the camera release button signal and controls the motor operation signal, establishes Ethernet communication with the PLC through the host computer software in the industrial computer, and uses the Opencv visual library to control the industrial camera. The industrial computer and the server use the Fastapi communication method to establish data transmission; Step S42. Test model effect: Use Winform framework to develop host computer software, establish communication with PLC and control industrial camera through C# programming language in the back end, develop visualization page in the front end, publish Fastapi service in Windows Server server using Docker technology, start hydraulic pump parts complete set detection model in the service through Python programming language, and wait for detection signal and detection image transmitted by host computer software.
