Search

CN-122023275-A - Component detection method and device, electronic equipment and storage medium

CN122023275ACN 122023275 ACN122023275 ACN 122023275ACN-122023275-A

Abstract

The disclosure provides a component detection method, a device, electronic equipment and a storage medium. The method comprises the steps of obtaining an original image of a component, preprocessing the original image to obtain a target image, carrying out feature extraction processing on the target image by utilizing a convolutional neural network trained in advance to obtain multi-scale features, converting the multi-scale features into a plurality of feature sequences, adding position codes to the plurality of feature sequences to obtain a plurality of coding sequences, carrying out feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, carrying out fusion processing on the plurality of single-head classification results to obtain a fusion classification result, determining a target classification result based on the plurality of single-head classification results and the fusion classification result, and determining a detection result of the component based on the target classification result. Therefore, defects in the components can be automatically identified, and the problem of inaccurate detection results of the components caused by inconsistent manual detection standards is avoided.

Inventors

  • XIE SIYING
  • ZHANG WENRUI
  • REN XIANG
  • LI SHUO
  • LUO JUNJIE
  • HAN TAO
  • SHEN YUBO
  • JIN ZIHENG
  • SHEN XIAOSHUANG
  • ZHANG ZHAO

Assignees

  • 航天科工防御技术研究试验中心

Dates

Publication Date
20260512
Application Date
20260104

Claims (10)

  1. 1. A component inspection method, the method comprising: Acquiring an original image of a component, and preprocessing the original image to obtain a target image; Performing feature extraction processing on the target image by using a pre-trained convolutional neural network to obtain multi-scale features; converting the multi-scale features into a plurality of feature sequences, and adding position codes to the plurality of feature sequences to obtain a plurality of code sequences; performing feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and performing fusion processing on the plurality of single-head classification results to obtain a fusion classification result; and determining a target classification result based on the plurality of single-head classification results and the fusion classification result, and determining a detection result of the component based on the target classification result.
  2. 2. The method of claim 1, wherein preprocessing the original image to obtain a target image comprises: decoding the original image to obtain a decoded image; Performing space transformation on the decoded image to obtain a gray image; Performing size transformation processing on the gray level image to obtain a gray level image with a preset size; Performing enhancement processing on the gray level image with the preset size to obtain an enhanced image; And carrying out standardization processing on the enhanced image to obtain a target image.
  3. 3. The method according to claim 1, wherein the feature extraction processing of the target image using a pre-trained convolutional neural network to obtain multi-scale features comprises: Performing feature extraction processing on the target image by using a first convolutional neural network trained in advance to obtain surface features; performing feature extraction processing on the target image by using a second convolutional neural network trained in advance to obtain shallow features; performing feature extraction processing on the target image by using a third convolutional neural network trained in advance to obtain middle-layer features; Performing feature extraction processing on the target image by using a fourth convolutional neural network trained in advance to obtain deep features; the surface layer feature, the shallow layer feature, the middle layer feature, and the deep layer feature are considered as multi-scale features.
  4. 4. The method of claim 1, wherein converting the multi-scale feature into a plurality of feature sequences, adding position codes to the plurality of feature sequences results in a plurality of code sequences, comprising: Carrying out projection processing on each scale feature in the multi-scale features to obtain each projection feature map; Carrying out feature serialization processing on each projection feature map to obtain each feature sequence; And adding position codes to each characteristic sequence to obtain each code sequence, and determining a plurality of code sequences based on all code sequences of the multi-scale characteristics.
  5. 5. The method of claim 1, wherein the performing feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and performing fusion processing on the plurality of single-head classification results to obtain a fusion classification result, comprises: Determining a query parameter, a key parameter, and a value parameter based on each of the plurality of coding sequences; Determining single-head attention characteristics based on the query parameters, the key parameters and the value parameters, and performing characteristic extraction processing on the coding sequences by utilizing the single-head attention characteristics to obtain a plurality of single-head classification results; and determining a multi-head attention characteristic based on the query parameter, the key parameter and the value parameter, and performing fusion processing on the single-head classification results by utilizing the multi-head attention characteristic to obtain a fusion classification result.
  6. 6. The method of claim 5, wherein performing feature extraction processing on the plurality of coding sequences using the single-head attention feature to obtain a plurality of single-head classification results comprises: restoring each coding sequence into each feature map, and carrying out global average pooling treatment on each feature map by utilizing the single-head attention feature to obtain each global average pooling result; Determining each single-head classification result based on the global average pooling result, and determining a plurality of single-head classification results based on all single-head classification results of the multi-scale features; the step of performing fusion processing on the plurality of single-head classification results by using the multi-head attention features to obtain a fusion classification result comprises the following steps: and carrying out fusion processing on a plurality of global average pooling results by utilizing the multi-head attention characteristic to obtain a fusion pooling result, and determining a fusion classification result based on the fusion pooling result.
  7. 7. The method of claim 1, wherein the determining a target classification result based on the plurality of single-ended classification results and the fusion classification result, and determining a detection result of a component based on the target classification result, comprises: Acquiring a learning weight parameter, and determining a first weight corresponding to each single-head classification result and a second weight corresponding to the fusion classification result based on the learning weight parameter; And carrying out weighted fusion processing on the plurality of single-head classification results and the fusion classification result based on the first weight and the second weight to obtain a target classification result, and determining a detection result of the component based on the target classification result.
  8. 8. A component inspection apparatus, comprising: the preprocessing module is configured to acquire an original image of the component, and preprocess the original image to obtain a target image; The feature extraction module is configured to perform feature extraction processing on the target image by utilizing a pre-trained convolutional neural network to obtain multi-scale features; The feature conversion module is configured to convert the multi-scale features into a plurality of feature sequences, and position codes are added to the plurality of feature sequences to obtain a plurality of code sequences; The fusion processing module is configured to perform feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and perform fusion processing on the plurality of single-head classification results to obtain a fusion classification result; and the device detection module is configured to determine a target classification result based on the plurality of single-head classification results and the fusion classification result and determine a detection result of the component based on the target classification result.
  9. 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and running on the processor, the processor implementing the method of any one of claims 1 to 7 when executing the program.
  10. 10. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1 to 7.

Description

Component detection method and device, electronic equipment and storage medium Technical Field The disclosure relates to the technical field of device testing, and in particular relates to a component detection method, a device, electronic equipment and a storage medium. Background The appearance detection of the components is used as a first firm defense line for the detection of the components, and plays an important role in improving the reliability of products. At present, the appearance detection of the components is mainly carried out manually, and the problem that the detection result of the components is inaccurate due to inconsistent manual detection standards exists. In view of this, how to avoid inaccurate detection results of components caused by inconsistent manual detection standards is a technical problem to be solved. Disclosure of Invention In view of the above, the disclosure is directed to a method, an apparatus, an electronic device, and a storage medium for detecting components, which are used for solving or partially solving the above technical problems. Based on the above object, a first aspect of the present disclosure proposes a component detection method, the method comprising: Acquiring an original image of a component, and preprocessing the original image to obtain a target image; Performing feature extraction processing on the target image by using a pre-trained convolutional neural network to obtain multi-scale features; converting the multi-scale features into a plurality of feature sequences, and adding position codes to the plurality of feature sequences to obtain a plurality of code sequences; performing feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and performing fusion processing on the plurality of single-head classification results to obtain a fusion classification result; and determining a target classification result based on the plurality of single-head classification results and the fusion classification result, and determining a detection result of the component based on the target classification result. Based on the same inventive concept, a second aspect of the present disclosure provides a component detection apparatus, including: the preprocessing module is configured to acquire an original image of the component, and preprocess the original image to obtain a target image; The feature extraction module is configured to perform feature extraction processing on the target image by utilizing a pre-trained convolutional neural network to obtain multi-scale features; The feature conversion module is configured to convert the multi-scale features into a plurality of feature sequences, and position codes are added to the plurality of feature sequences to obtain a plurality of code sequences; The fusion processing module is configured to perform feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and perform fusion processing on the plurality of single-head classification results to obtain a fusion classification result; and the device detection module is configured to determine a target classification result based on the plurality of single-head classification results and the fusion classification result and determine a detection result of the component based on the target classification result. Based on the same inventive concept, a third aspect of the present disclosure proposes an electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, the processor implementing the method as described above when executing the computer program. Based on the same inventive concept, a fourth aspect of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method as described above. From the above, it can be seen that the present disclosure provides a method, an apparatus, an electronic device and a storage medium for detecting components. And acquiring an original image of the component, and preprocessing the original image to obtain a target image. And performing feature extraction processing on the target image by utilizing the pre-trained convolutional neural network to obtain multi-scale features, so that the obtained multi-scale features are more comprehensive and accurate. Converting the multi-scale features into a plurality of feature sequences, and adding position codes to the plurality of feature sequences to obtain a plurality of code sequences. And carrying out feature extraction processing on the plurality of coding sequences to obtain a plurality of single-head classification results, and carrying out fusion processing on the plurality of single-head classification results to obtain a fusion classification result, wherein the plurality of single-head c