A non-ferrous metal forging quality detection method based on image recognition

CN122887830APending Publication Date: 2026-10-09BEIJING BOOTE SHENGRUN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611056343.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-16
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

然而,有色金属锻件表面具有较强的镜面反射特性,高光边界、曝光饱和区域及金属颗粒反射容易形成与微裂纹相近的细长响应,现有模型难以区分反光伪边缘与真实微裂纹,导致误检率增加

Benefits of technology

本发明通过对待检测有色金属锻件进行区域定位和整体亮度校正,在消除光照位置及锻件表面曲率造成的缓慢亮度变化的同时,保留表面微裂纹和局部反光的原始响应。进一步依据亮度响应、饱和响应和局部对比响应生成反光可信度图,使镜面高光边界、曝光饱和区域及金属颗粒反射由普通亮度干扰转化为可量化的像素级反光信息,无需增加多角度相机、多次曝光或偏振成像设备,即可为后续裂纹识别提供与锻件表面位置对应的反光干扰依据,降低检测设备复杂度和重复采集工作量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122887830A_ABST
    Figure CN122887830A_ABST
Patent Text Reader

Abstract

The application discloses a non-ferrous metal forging quality detection method based on image recognition and relates to the technical field of forging quality detection, and comprises the following steps: collecting a positioning forging surface image, generating a detection image after correcting brightness, extracting brightness, saturation and local contrast response, fusing to generate a reflection light credibility map, inputting the detection image and the reflection light credibility map into a CrackFormer model, extracting multi-scale crack features, correcting and scaling attention according to the reflection light credibility, fusing center line continuity to generate a crack region probability map, extracting crack candidate segments, performing reflection light conflict arbitration and broken path completion, and outputting micro-crack regions and quality detection results. The application fuses reflection light credibility constraint and crack center line continuity analysis, realizes accurate detection of non-ferrous metal forging micro-cracks, and has the advantages of low false detection rate, low missed detection rate and high stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of forging quality inspection technology, and in particular to a method for inspecting the quality of non-ferrous metal forgings based on image recognition. Background Technology

[0002] Non-ferrous metal forgings are prone to surface microcracks during forging, trimming, and subsequent handling. Current quality inspection methods often employ industrial cameras to capture images of the forging surface. After region localization, brightness equalization, and image enhancement, convolutional neural networks or encoder-decoder segmentation models are used to extract crack regions. Some solutions improve the identification ability of fine cracks through multi-scale feature fusion, attention weighting, or crack centerline supervision. However, the surface of non-ferrous metal forgings has strong specular reflection characteristics. Highlight boundaries, exposure saturation areas, and metal particle reflections can easily form elongated responses similar to microcracks. Existing models struggle to distinguish between reflective pseudo-edges and real microcracks, leading to an increased false detection rate.

[0003] To address the issue of surface reflection on metals, existing solutions typically employ polarized light sources, multi-angle illumination, multi-exposure image fusion, or highlight area masks to reduce the impact of reflections. However, these methods require increased imaging equipment and more data acquisition cycles, and directly suppressing highlight areas can simultaneously weaken real microcracks located within the reflective region. Other solutions connect fractured crack regions through skeleton extraction, topological loss, morphological closing operations, or minimum cost path analysis; however, these methods are usually independent of reflection interference analysis and are prone to incorrectly connecting adjacent highlight edges, scratches, or isolated linear noise. Current technologies lack a processing mechanism that integrates the reliability of reflections with the continuity of the crack centerline in model attention and subsequent fragment determination, making it difficult to simultaneously address both reflection-induced pseudo-crack suppression and reflection-masked crack recovery.

[0004] Therefore, how to provide a quality inspection method for non-ferrous metal forgings based on image recognition is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] One objective of this invention is to propose a quality inspection method for non-ferrous metal forgings based on image recognition. This invention integrates reflectivity constraints and crack centerline continuity analysis to achieve accurate detection of microcracks in non-ferrous metal forgings, and has the advantages of low false detection rate, low false detection rate and high stability.

[0006] A method for quality inspection of non-ferrous metal forgings based on image recognition according to an embodiment of the present invention includes the following steps: Acquire a surface image of the non-ferrous metal forging to be inspected, perform forging area localization and brightness correction, and generate a surface inspection image of the forging; The brightness response, saturation response, and local contrast response of the surface inspection image of the forging are extracted and fused according to pixel position to generate a reflectivity confidence map; The surface inspection image and reflection confidence map of the forging are input into the reflection confidence-constrained CrackFormer model to extract multi-scale crack features. Based on the reflectivity map, the scaling attention weight is adjusted to suppress the crack response in the reflective region, and the crack centerline continuity fusion is performed on the multi-scale crack features to generate a crack region probability map. Based on the probability map of the crack region, candidate crack segments are extracted. The reflection confidence map and the continuity feature of the crack center line are combined to make a reflection conflict judgment on the candidate crack segments. The path completion is performed on the candidate crack segments that are retained by the judgment and blocked by reflection, and the surface microcrack region and the quality inspection results of non-ferrous metal forgings are generated.

[0007] Optionally, the generation of the forging surface inspection image specifically includes: A surface image of the non-ferrous metal forging to be inspected is acquired at a fixed imaging position, and the surface image covers the surface to be inspected and its surrounding background. The forging region is separated from the surface image, and the image position and extension direction of the non-ferrous metal forging to be detected are corrected according to the forging region to obtain the positioning surface image; The global illumination component and local brightness component in the positioning surface image are separated. The brightness of the forging area is corrected based on the global illumination component, while the local brightness component is retained to generate a forging surface inspection image.

[0008] Optionally, the generation of the reflectivity confidence map specifically includes: The surface inspection image of the forging is converted to the HSV color space. A luminance response representing the brightness of a pixel is generated based on the luminance channel, and a saturation response representing the color decay state is generated based on the saturation channel. The neighborhood brightness difference and brightness gradient are extracted centered on each pixel in the brightness channel to generate a local contrast response that characterizes the local brightness change state. Based on pixel location, brightness response, saturation response and local contrast response are consistently fused to generate an initial reflectivity map. The initial reflectivity map is subjected to isolated response removal and neighborhood smoothing, while retaining pixels within the forging area to generate a reflectivity map.

[0009] Optionally, the consistency fusion is achieved by multiplying the brightness response, saturation response and local contrast response at the same pixel location and taking the cube root of the multiplication result to obtain the reflectivity of the same pixel location. The value of each pixel in the initial reflectivity map represents the degree of confidence of the corresponding position on the forging surface being affected by local reflectivity interference, and does not represent the image saliency, pixel brightness or surface microcrack probability at the corresponding position.

[0010] Optionally, the reflective credibility constraint type CrackFormer model includes an input alignment unit, a 5-stage encoder, a 5-stage decoder, a reflective credibility constraint Scal-AB, a crack centerline continuity fusion unit, and a multi-stage crack fusion layer.

[0011] Optionally, the generation of the multi-scale crack features specifically includes: By adjusting the size of the forging surface detection image and the reflectivity map of the input alignment unit according to the same spatial transformation, the aligned forging surface detection image and the aligned reflectivity map of the pixel position are obtained. The surface inspection image of the aligned forging is encoded step by step by a 5-stage encoder to generate coded crack features at 5 scales in sequence. The alignment reflection confidence map is scaled up to 5 coding scales to generate a multi-scale reflection confidence map corresponding to the coded crack feature pixel positions at the 5 scales. The spatial resolution of the encoded crack features is restored step by step by the pooling index through a 5-stage decoder, and the decoded crack features at 5 scales are generated in sequence. By mapping the encoded crack features and decoded crack features of the same scale, multi-scale crack features are formed.

[0012] Optionally, the generation of the crack region probability map specifically includes: Scal-AB generates scaling attention weights based on the corresponding coded crack features by constraining each reflectivity level, and generates crack centerline responses based on the corresponding decoded crack features. The direction extension state and cross-scale coincidence state of each crack centerline response are extracted by the crack centerline continuity fusion unit to generate crack centerline continuity features at 5 scales. Based on pixel location, reflectivity suppression weights are generated using reflectivity confidence maps and crack centerline continuity features of the same scale. The reflectivity suppression weights are then used to correct the scaling attention weights, resulting in reflectivity correction scaling attention weights. The corresponding decoded crack features are weighted pixel by pixel using the reflection correction scaling attention weight, and residual fusion is performed with the decoded crack features before weighting to generate reflection constraint crack features at 5 scales. Based on the continuity characteristics of the crack centerline, the crack centerline continuity fusion is performed on the reflective constrained crack features at five scales, and a crack region probability map is generated through a multi-stage crack fusion layer.

[0013] Optionally, the generation of the surface microcrack region and the quality inspection results of the non-ferrous metal forging specifically includes: The initial crack region is extracted based on the crack region probability map. The centerline of the initial crack region is extracted and segmented to generate crack candidate segments. Each crack candidate segment is mapped to the reflectivity map and the continuity feature of the crack centerline, and a reflectivity conflict state is generated based on the reflectivity coverage state and the continuity state of the centerline. Based on the reflection conflict state, the candidate crack segments are judged, the real crack segments are retained and the reflective false crack segments are eliminated; The actual crack segments that are blocked by reflection are determined based on the endpoint positions and extension directions of the actual crack segments, and the completion path is searched between the corresponding endpoints to generate the reflection-blocked completion segments. By merging real crack segments and reflective shading completion segments, a surface microcrack region is generated, and the quality inspection results of non-ferrous metal forgings are generated based on the surface microcrack region.

[0014] The beneficial effects of this invention are: This invention achieves regional positioning and overall brightness correction of the non-ferrous metal forging under inspection. While eliminating slow brightness changes caused by illumination position and surface curvature, it preserves the original responses of surface microcracks and localized reflections. Furthermore, based on the brightness response, saturation response, and local contrast response, a reflection confidence map is generated. This transforms ordinary brightness interference such as specular highlight boundaries, exposure saturation areas, and metal particle reflections into quantifiable pixel-level reflection information. This eliminates the need for multi-angle cameras, multiple exposures, or polarization imaging equipment, providing a basis for subsequent crack identification based on reflection interference corresponding to the forging surface location, thus reducing the complexity of inspection equipment and the workload of repetitive data acquisition.

[0015] This invention introduces reflectivity input and crack centerline continuity processing into the CrackFormer model. It utilizes reflectivity and crack centerline continuity features to generate reflectivity suppression weights, and adjusts the scaling attention weights accordingly. For linear responses with high reflectivity and lacking directional extension and cross-scale overlap support, the model reduces their crack response. For real microcracks located in highly reflective regions but with continuous extension features, the model reduces reflectivity suppression and retains weak crack features through residual fusion. This avoids the missed detection of real cracks caused by existing specular masks that completely delete reflective regions, while reducing false detections of specular boundaries being identified as surface microcracks, thus improving the completeness and stability of crack region localization under complex reflective conditions.

[0016] This invention further utilizes reflectivity and crack centerline continuity in crack candidate segment determination, distinguishing between reflective pseudo-crack segments and genuine crack segments. It performs minimum-cost path completion only on fracture segments with consistent endpoint directions, reflective coverage, and continuity support. This method avoids the erroneous merging of adjacent scratches, highlight edges, or independent cracks by ordinary morphological joining, and can recover discontinuous microcracks formed by localized reflective obstruction. This results in a more complete surface microcrack region, crack length, and crack width, providing a reliable basis for the qualification judgment, defect location, and subsequent quality traceability of non-ferrous metal forgings. Attached Figure Description

[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a non-ferrous metal forging quality inspection method based on image recognition proposed in this invention; Figure 2 This is a flowchart of the reflective collaborative gating process for a non-ferrous metal forging quality inspection method based on image recognition proposed in this invention. Detailed Implementation

[0018] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0019] refer to Figures 1-2 A method for quality inspection of non-ferrous metal forgings based on image recognition includes the following steps: Acquire a surface image of the non-ferrous metal forging to be inspected, perform forging area localization and brightness correction, and generate a surface inspection image of the forging; The brightness response, saturation response, and local contrast response of the surface inspection image of the forging are extracted and fused according to pixel position to generate a reflectivity confidence map; The surface inspection image and reflection confidence map of the forging are input into the reflection confidence-constrained CrackFormer model to extract multi-scale crack features. Based on the reflectivity map, the scaling attention weight is adjusted to suppress the crack response in the reflective region, and the crack centerline continuity fusion is performed on the multi-scale crack features to generate a crack region probability map. Based on the probability map of the crack region, candidate crack segments are extracted. The reflection confidence map and the continuity feature of the crack center line are combined to make a reflection conflict judgment on the candidate crack segments. The path completion is performed on the candidate crack segments that are retained by the judgment and blocked by reflection, and the surface microcrack region and the quality inspection results of non-ferrous metal forgings are generated.

[0020] In this embodiment, the generation of the forging surface inspection image specifically includes: A surface image of the non-ferrous metal forging to be inspected is acquired at a fixed imaging position, and the surface image covers the surface to be inspected and its surrounding background. During the data acquisition, the non-ferrous metal forging to be inspected is placed on a dark gray bearing surface and photographed by a color area array industrial camera set above the surface to be inspected. The surface to be inspected is illuminated by a diffuse light source, and the industrial camera outputs an 8-bit RGB image with a resolution of 2448×2048 pixels. The exposure time is adjusted so that the percentage of pixels in the forging area that reach the maximum brightness value does not exceed 5%, and the image response of surface micro-cracks and local reflections is preserved. The forging region is separated from the surface image, and the image position and extension direction of the non-ferrous metal forging to be detected are corrected according to the forging region to obtain the positioning surface image; The correction includes performing pixel difference between the surface image and the pre-acquired peripheral background image, binarizing the difference result and performing connected component analysis, selecting the connected component with the largest area as the forging region, rotating the surface image according to the principal axis direction of the forging region so that the principal axis direction of the forging region is consistent with the horizontal direction of the image, and then cropping it by extending it outward by 32 pixels along the outer boundary of the forging region to obtain the positioning surface image. The global illumination component and local brightness component in the positioning surface image are separated. The brightness of the forging area is corrected according to the global illumination component, while the local brightness component is retained to generate a forging surface detection image. The forging surface inspection image is obtained by extracting the brightness channel of the positioning surface image, performing low-pass filtering to obtain the overall illumination component that changes slowly with the lighting position and the curvature of the forging surface, subtracting the brightness channel from the overall illumination component to obtain the local brightness component, equalizing the overall illumination component according to the median brightness of the overall illumination component in the forging area, and then superimposing the local brightness component onto the equalized overall illumination component to correct the overall illumination difference and keep the local reflective response unchanged, thus generating the forging surface inspection image.

[0021] In this embodiment, the generation of the reflectivity map specifically includes: The surface inspection image of the forging is converted to the HSV color space. A luminance response representing the brightness of a pixel is generated based on the luminance channel, and a saturation response representing the color decay state is generated based on the saturation channel. The pixel value range of both the luminance and saturation channels is 0 to 255. The luminance response is generated by segmenting and normalizing the luminance channel, setting the position of the luminance channel pixel value not higher than 160 to 0, setting the position of the luminance channel pixel value not lower than 240 to 1, and linearly mapping the position of the luminance channel pixel value between 160 and 240 to 0 to 1 in the direction of increasing pixel value. The saturation response is generated by reversing and segmenting and normalizing the saturation channel, setting the position of the saturation channel pixel value not higher than 20 to 1, setting the position of the saturation channel pixel value not lower than 100 to 0, and linearly mapping the position of the saturation channel pixel value between 20 and 100 to 1 to 0 in the direction of increasing pixel value. The neighborhood brightness difference and brightness gradient are extracted centered on each pixel in the brightness channel to generate a local contrast response that characterizes the local brightness change state. The local contrast response is achieved by setting a 31×31 pixel local neighborhood centered on each pixel in the luminance channel, calculating the positive difference between the luminance of the central pixel and the weighted average luminance of the local neighborhood, and calculating the luminance gradient magnitude of the central pixel through horizontal and vertical differences; positions with a positive difference of no more than 8 are set to 0, positions with a positive difference of no less than 32 are set to 1, and positions with a positive difference between 8 and 32 are linearly mapped to 0 to 1; positions with a luminance gradient magnitude of no more than 12 are set to 0, positions with a luminance gradient magnitude of no less than 48 are set to 1, and positions with a luminance gradient magnitude between 12 and 48 are linearly mapped to 0 to 1; comparing the two mapping results at the same pixel position, the one with the larger value is selected as the local contrast response, so that both the local bright area and its bright boundary form a local luminance abrupt change response; Based on pixel location, brightness response, saturation response and local contrast response are consistently fused to generate an initial reflectivity map. The initial reflectivity map is subjected to isolated response removal and neighborhood smoothing, while retaining pixels within the forging area to generate a reflectivity map. The isolated response removal is achieved by performing a 5×5 pixel median filter on the initial reflectivity map, replacing the center value of the window with the median value within each filter window, and removing isolated bright responses caused by sensor noise, metal particle reflection, and single-point exposure saturation. The neighborhood smoothing is achieved by performing a 9×9 pixel Gaussian filter on the initial reflectivity map after isolated response removal, so that the reflectivity of adjacent pixels in the same reflectivity area changes continuously. Then, the pixel values ​​outside the forging area are set to 0, and the pixel values ​​within the forging area are normalized to 0 to 1, generating a reflectivity map corresponding to the pixel position of the detected image on the forging surface.

[0022] In this embodiment, the consistency fusion is achieved by multiplying the brightness response, saturation response and local contrast response of the same pixel position and taking the cube root of the multiplication result to obtain the reflectivity of the same pixel position. The value of each pixel in the initial reflectivity map represents the degree of confidence of the corresponding position on the forging surface being affected by local reflectivity interference, and does not represent the image saliency, pixel brightness or surface microcrack probability of the corresponding position. Among them, pixels that simultaneously exhibit high brightness, color decay, and local brightness abrupt changes receive higher reflectivity, while pixels lacking any of these reflectivity characteristics receive lower reflectivity.

[0023] In this embodiment, the reflective credibility constraint type CrackFormer model includes an input alignment unit, a 5-stage encoder, a 5-stage decoder, a reflective credibility constraint Scal-AB, a crack centerline continuity fusion unit, and a multi-stage crack fusion layer. In the reflected light confidence constraint type CrackFormer model, the input alignment unit is connected to a 5-stage encoder, the 5-stage encoder is sequentially connected to a 5-stage decoder, and a reflected light confidence constraint Scal-AB is set between each encoding stage and its corresponding decoding stage. The 5-stage decoder is sequentially connected to the crack centerline continuity fusion unit and the multi-stage crack fusion layer. Compared to the original CrackFormer model, the reflected light confidence constraint type CrackFormer model adds reflected light confidence input and crack centerline response extraction to each Scal-AB, and adds a crack centerline continuity fusion unit after the 5-stage decoder. The input alignment unit synchronously adjusts the size and position of the forging surface detection image and the reflected light confidence map, and the 5-stage encoder generates an encoding sequence that gradually changes from the local edge to the crack semantics. The five-stage decoder recovers the spatial location of cracks based on pooling indexes and generates decoded crack features. The reflectivity confidence constraint Scal-AB generates reflectivity suppression weights based on reflectivity confidence and crack centerline continuity features, and adjusts the scaling attention weights accordingly to suppress linear responses with high reflectivity and lack of continuity support, while retaining surface microcrack responses with high reflectivity but continuity support. The crack centerline continuity fusion unit enhances the reflectivity constraint crack features based on the directional extension state and cross-scale overlap state of the crack centerline response at each scale. The multi-stage crack fusion layer restores the reflectivity constraint crack features at the five scales to the same spatial size and fuses them to generate a crack region probability map, thereby reducing false detections caused by specular highlight boundaries and exposure saturation areas, and reducing missed detections caused by the synchronous weakening of real surface microcracks in the reflective area. The reflectivity-constrained CrackFormer model is trained using training images of non-ferrous metal forging surfaces. These training images include images without surface microcracks, images of surface microcracks in non-reflective areas, images of surface microcracks in reflective areas, and images without surface microcracks containing specular false edges. Pixel-by-pixel annotations are performed on the surface microcrack pixels in the training images to generate crack region labels. Skeleton refinement is then performed on the crack region labels to obtain crack centerline labels with a width of 1 pixel. A reflectivity map is generated for each training image. The training images, reflectivity maps, crack region labels, and crack centerline labels undergo the same rotation, flip, scaling, and cropping operations for spatial enhancement. Brightness and contrast adjustments are applied only to the training images, and the reflectivity map is recalculated after adjustments. The training samples are divided into training and validation parts in an 8:2 ratio, using a batch size of 4 and an initial learning rate of 0. The AdamW optimizer with a value of .0001 updates the model parameters. The training loss consists of crack region loss, crack centerline loss, and cross-scale continuity loss. The crack region loss is obtained by adding the class-balanced binary cross-entropy loss and the Dice loss. The crack centerline loss is obtained by adding the binary cross-entropy loss between the predicted crack centerline response and the crack centerline label and the centerline coincidence loss. The cross-scale continuity loss is obtained by comparing the pixel differences of the crack centerline responses of adjacent scales after they are restored to the same spatial size. The three losses are added together with weights of 0.6, 0.25, and 0.15 to form the total training loss. After each round of training, the total training loss of the validation part is calculated. Training stops when the total training loss of the validation part does not decrease for 10 consecutive rounds, and the model parameters with the lowest total training loss of the validation part are selected as the parameters of the reflective confidence-constrained CrackFormer model.

[0024] In this embodiment, the generation of the multi-scale crack features specifically includes: By adjusting the size of the forging surface detection image and the reflectivity map of the input alignment unit according to the same spatial transformation, the aligned forging surface detection image and the aligned reflectivity map of the pixel position are obtained. The input alignment unit scales and crops the forging surface detection image to 1536×1280 pixels according to the original aspect ratio, and uses bilinear interpolation to determine the image pixel value; it processes the reflection confidence map according to the same scaling ratio and cropping position, and uses area interpolation to determine the reflection confidence, so that the pixels in the aligned reflection confidence map correspond to the same forging surface position in the aligned forging surface detection image. The surface inspection image of the aligned forging is encoded step by step by a 5-stage encoder to generate coded crack features at 5 scales in sequence. The number of channels in the 5-stage encoder is 64, 128, 256, 512 and 512 respectively. Each encoding stage is set with 2, 2, 3, 3 and 3 Self-ABs respectively. Each Self-AB generates query features, key features and value features through 1×1 convolution. The value features are aggregated according to the similarity between the query features and key features, and relative position embedding and input residual are superimposed. After each encoding stage, 2×2 max pooling is used to reduce the width and height of the feature map to half, while retaining the pooling index of the largest response pixel. The alignment reflection confidence map is scaled up to 5 coding scales to generate a multi-scale reflection confidence map corresponding to the coded crack feature pixel positions at the 5 scales. The progressive scaling takes the aligned reflectivity map as the first-scale reflectivity map and performs four consecutive scaling operations using average pooling with a window size of 2×2 pixels and a stride of 2 to obtain reflectivity maps for the second to fifth scales. Each average pooling operation uses the average reflectivity within the corresponding window as the scaled pixel value, so that the spatial size of the multi-scale reflectivity map is consistent with the coded crack features of the five scales, and the pixel value is kept between 0 and 1. The spatial resolution of the encoded crack features is restored step by step by the pooling index through a 5-stage decoder, and the decoded crack features at 5 scales are generated in sequence. The number of channels in the 5-stage decoder is 512, 512, 256, 128 and 64 respectively. Each decoding stage is set with 3, 3, 3, 2 and 2 Self-ABs respectively. Each decoding stage performs max unpooling based on the pooling index retained by the corresponding encoding stage, restores the output of the previous decoding stage to the spatial size of the corresponding encoded crack feature, and then extracts the restored linear edge features and crack extension features through Self-AB, and passes the current decoded crack feature to the next decoding stage. By mapping the encoded crack features and decoded crack features of the same scale, multi-scale crack features are formed. The correspondence is performed according to five coding scales, so that the spatial details of the forging surface in the encoded crack features, the crack semantics in the decoded crack features, and the reflectivity are established according to the same pixel position to form multi-scale crack features.

[0025] In this embodiment, the generation of the crack region probability map specifically includes: Scal-AB generates scaling attention weights based on the corresponding coded crack features by constraining each reflectivity level, and generates crack centerline responses based on the corresponding decoded crack features. The scaling attention weights are generated by sequentially inputting the corresponding encoded crack features into a 3×3 convolutional layer, a batch normalization layer, and a Sigmoid layer. The output spatial size is consistent with the corresponding encoded crack features and takes values ​​from 0 to 1. The crack centerline response is generated by inputting the corresponding decoded crack features into a 3×3 deep convolutional layer to extract the linear response, then compressing it into a single channel through a 1×1 convolutional layer and normalizing it through a Sigmoid layer, so that the corresponding scaling attention weights and crack centerline responses are obtained at the five scales respectively. The direction extension state and cross-scale coincidence state of each crack centerline response are extracted by the crack centerline continuity fusion unit to generate crack centerline continuity features at 5 scales. The directional extension state is calculated by using a horizontal linear window, a vertical linear window, and two diagonal linear windows of 5 pixels in length to calculate the average response within each crack centerline response. The maximum value of the four average responses at the same pixel position is selected to generate the directional continuity response. The crack centerline response of the adjacent next scale is restored to the current scale using bilinear interpolation. The directional continuity response of the current scale is multiplied pixel by pixel with the restored crack centerline response, and the square root is taken to generate the crack centerline continuity feature of the current scale. The crack centerline continuity feature of the 5th scale is directly generated from the corresponding directional continuity response. Based on pixel location, reflectivity suppression weights are generated using reflectivity confidence maps of the same scale and crack centerline continuity features. The reflectivity suppression weights are then used to correct the scaling attention weights, resulting in reflectivity correction scaling attention weights. The reflection suppression weight is generated by first calculating 1 minus the crack centerline continuity feature, and then multiplying the result by the reflection confidence map at the same scale pixel by pixel. The reflection correction scaling attention weight is generated by calculating 1 minus the reflection suppression weight, and then multiplying the result by the scaling attention weight pixel by pixel. When the reflection confidence at the same pixel position increases and the crack centerline continuity feature decreases, the reflection suppression weight increases and the reflection correction scaling attention weight decreases. When the reflection confidence increases and the crack centerline continuity feature increases simultaneously, the reflection suppression weight decreases, and the crack response with cross-scale directional extension is preserved. When the reflection confidence decreases, the reflection correction scaling attention weight approaches the corresponding scaling attention weight. The corresponding decoded crack features are weighted pixel by pixel using the reflection correction scaling attention weight, and residual fusion is performed with the decoded crack features before weighting to generate reflection constraint crack features at 5 scales. The pixel-by-pixel weighting includes copying the single-channel reflective correction scaling attention weight to all channels of the corresponding decoded crack feature and multiplying it with the feature value in each channel; then adding the weighted decoded crack feature at a ratio of 80% to the unweighted decoded crack feature at a ratio of 20% pixel by pixel, so that the response with high reflective confidence and lack of crack centerline continuity support is suppressed, while weak crack features in the reflective area are retained, resulting in a reflective constrained crack feature with the same number of channels and spatial size as the corresponding decoded crack feature; Based on the continuity characteristics of the crack centerline, the crack centerline continuity fusion is performed on the reflective constrained crack features at five scales, and a crack region probability map is generated through a multi-stage crack fusion layer. The crack centerline continuity fusion includes converting each reflective constraint crack feature into 64 channels through a 1×1 convolutional layer, restoring it to the spatial size of the first scale using bilinear interpolation, simultaneously restoring the corresponding crack centerline continuity feature to the first scale, multiplying it pixel-by-pixel with the reflective constraint crack feature, and then adding the multiplication result to the corresponding reflective constraint crack feature. The multi-stage crack fusion layer stitches the fusion results of the 5 scales into 320-channel features according to the channel direction, compresses them into 64 channels through a 3×3 convolutional layer, compresses them into a single channel through a 1×1 convolutional layer, and normalizes them through a Sigmoid layer to generate a crack region probability map where each pixel value is between 0 and 1.

[0026] In this embodiment, the generation of the surface microcrack region and the quality inspection results of the non-ferrous metal forging specifically includes: The initial crack region is extracted based on the crack region probability map. The centerline of the initial crack region is extracted and segmented to generate crack candidate segments. The initial crack region is defined by identifying pixels with a value of not less than 0.65 in the crack region probability map as high-confidence crack pixels and pixels with a value of not less than 0.35 and less than 0.65 as low-confidence crack pixels. Starting from the high-confidence crack pixels, a search is performed on the low-confidence crack pixels connected to them according to the 8-neighborhood, and the searched pixels are merged to generate the crack region. The initial crack region is then refined by skeletonization to obtain a crack centerline with a width of 1 pixel. The position on the crack centerline with only 1 adjacent centerline pixel is defined as the endpoint, the position with at least 3 adjacent centerline pixels is defined as the bifurcation point, and the direction turning point is defined as the direction turning point. The initial crack region is then segmented along the endpoint, bifurcation point, and direction turning point to generate crack candidate segments. Each crack candidate segment is mapped to the reflectivity map and the continuity feature of the crack centerline, and a reflectivity conflict state is generated based on the reflectivity coverage state and the continuity state of the centerline. The reflective coverage state is generated by statistically analyzing the proportion of pixels with a reflective confidence of not less than 0.6 in the crack candidate segment to the total number of pixels in the crack candidate segment. When the proportion is not less than 50%, it is determined to be a high reflective state; when it is less than 50%, it is determined to be a low reflective state. The centerline continuity state is generated by calculating the average value of the continuity feature of the crack centerline corresponding to the crack candidate segment. When the average value is not less than 0.55, it is determined to be a high continuity state; when it is less than 0.55, it is determined to be a low continuity state. The reflective coverage state and the centerline continuity state are combined to generate a high reflective high continuity state, a high reflective low continuity state, a low reflective high continuity state, or a low reflective low continuity state. Based on the reflection conflict state, the candidate crack segments are judged, the real crack segments are retained and the reflective false crack segments are eliminated; The determination process identifies and removes candidate crack segments in a high-reflectivity, low-continuity state as reflective pseudo-crack segments, while retaining candidate crack segments in either a high-reflectivity, high-continuity state or a low-reflectivity, high-continuity state as genuine crack segments. For candidate crack segments in a low-reflectivity, low-continuity state, the average probability of the corresponding crack region, the crack centerline length, and the ratio of crack length to average crack width are calculated. When the average probability of the crack region is not less than 0.7, the crack centerline length is not less than 8 pixels, and the ratio of crack length to average crack width is not less than 4, the corresponding candidate crack segment is identified as a genuine crack segment, and the rest are identified as reflective pseudo-crack segments and removed. The actual crack segments that are blocked by reflection are determined based on the endpoint positions and extension directions of the actual crack segments, and the completion path is searched between the corresponding endpoints to generate the reflection-blocked completion segments. The real crack segments blocked by reflection are determined by comparing the endpoints of the real crack segments pairwise. When the straight-line distance between the two endpoints does not exceed 12 pixels, the angle between the extension directions of the two endpoints does not exceed 25°, and the proportion of pixels with a reflection confidence of not less than 0.6 within 4 pixels on each side of the line connecting the two endpoints is not less than 50%, the corresponding two real crack segments are determined as real crack segments blocked by reflection. In the search area formed by 4 pixels on each side of the line connecting the two endpoints, the path is completed by searching the 8-neighborhood. The result of subtracting the crack region probability from 1 is added to the result of multiplying the reflection confidence by 1 and subtracting the crack centerline continuity feature, which is used as the path cost of each pixel. The path with the minimum cumulative path cost is selected. When the average crack region probability of the path is not less than 0.25, the average crack centerline continuity feature is not less than 0.55, and the path length does not exceed 1.5 times the straight-line distance between the two endpoints, the path is expanded according to the average crack width of the two real crack segments to generate a reflection-blocked completed segment. Merge real crack segments and reflective shading completion segments to generate surface microcrack regions, and generate non-ferrous metal forging quality inspection results based on surface microcrack regions; The surface microcrack region is generated by merging real crack segments with corresponding reflective interruption completion segments according to pixel position. Centerline extraction and Euclidean distance transformation are performed on each surface microcrack region. The distance between adjacent pixels on the crack centerline is accumulated to obtain the crack length. The distance from the crack centerline pixel to the nearest region boundary is multiplied by 2 to obtain the crack width at the corresponding position. The maximum value is selected as the maximum crack width. When no surface microcrack region is generated, the non-ferrous metal forging to be tested is judged as having passed the surface microcrack detection. When any surface microcrack region is generated, the non-ferrous metal forging to be tested is judged as a forging with surface microcrack defects. The surface microcrack region, reflective interruption completion segment, number of cracks, crack length, and maximum crack width are output.

[0027] Example 1: To verify the feasibility of this invention in practice, it was applied to the surface quality inspection of aluminum alloy ring forgings and copper alloy disc forgings in a non-ferrous metal forging production workshop. After machining and cleaning, the forgings were conveyed to a fixed imaging position by a conveyor device. The surface to be inspected had turning marks, oxide spots, metal particle reflections, and local specular highlights. Traditional inspection processes use ordinary encoder-decoder segmentation networks to extract microcracks. In areas of strong reflection, the edges of the highlights are easily identified as cracks, and the actual cracks are easily interrupted due to local exposure saturation. In a sample of aluminum alloy ring forgings, an arc-shaped microcrack with a length of 18.7 mm was found during manual review, of which 6.2 mm was located within the highlight zone. Traditional inspection processes output three separate crack regions, and two false cracks were generated at adjacent highlight edges, failing to accurately restore the continuous morphology of the crack.

[0028] A color area array industrial camera is positioned above the inspection location, outputting an 8-bit RGB image with a resolution of 2448×2048 pixels. A diffuse light source illuminates the surface to be inspected, with the forging placed on a dark gray support surface. By adjusting the exposure time, the percentage of pixels reaching maximum brightness within the forging area is maintained between 1.8% and 4.7%. Pixel difference analysis is performed between the acquired image and the surrounding background image. The forging area is then obtained through connected component analysis and rotated and cropped according to the principal axis direction of the forging area. The brightness channel is low-pass filtered to separate the overall illumination component and the local brightness component. The overall illumination component is balanced according to the median brightness of the forging area, while the local brightness components are re-superimposed to correct for the slow brightness changes caused by the light source position and the curvature of the forging, while preserving the edges of microcracks and local reflective responses.

[0029] A total of 3260 images of non-ferrous metal forging surfaces were collected during the training phase. These included 1436 images without surface microcracks, 782 images with surface microcracks in non-reflective areas, 641 images with surface microcracks in reflective areas, and 401 images containing specular false edges but without surface microcracks. Two inspectors labeled the surface microcracks pixel-by-pixel; areas with differing opinions were reviewed by a third inspector to obtain crack region labels. The crack region labels were then refined using a skeleton to generate crack centerline labels with a width of one pixel. A reflectivity confidence map was generated for each training image based on brightness response, saturation response, and local contrast response. The training images, reflectivity confidence maps, crack region labels, and crack centerline labels underwent the same spatial enhancement using rotation, flipping, scaling, and cropping. Training samples were divided in an 8:2 ratio with a batch size of 4, and the initial learning rate of the AdamW optimizer was set to 0.0001. The training loss consists of crack region loss, crack centerline loss, and cross-scale continuity loss, with weights of 0.6, 0.25, and 0.15 respectively. Training was stopped when the total training loss for the validation part did not decrease for 10 consecutive rounds. The lowest validation loss was finally achieved in the 73rd round, and the model parameters for that round were retained.

[0030] During inspection, the surface inspection image of the forging and the reflectivity map are input into the reflectivity-constrained CrackFormer model. The reflectivity map is scaled to five encoding scales, maintaining pixel position consistency with the corresponding encoded and decoded crack features. Each reflectivity-constrained Scal-AB generates scaling attention weights and crack centerline responses. The crack centerline continuity fusion unit extracts directional extension states in horizontal, vertical, and two diagonal directions, and combines them with crack centerline responses from adjacent scales to generate crack centerline continuity features. When the reflectivity is high and the crack centerline continuity is low at a certain location, the reflectivity correction scaling attention weight is reduced; when both reflectivity and crack centerline continuity are high, the reflectivity suppression is reduced, preserving microcracks with continuous extension patterns located in the highlight area. The weighted decoded crack features are residually fused with the original decoded crack features at a ratio of 20% and 80% to avoid completely eliminating weak crack responses in the reflective area.

[0031] After performing dual-threshold extraction and skeleton refinement on the crack region probability map output by the model, candidate crack segments are obtained. Each candidate crack segment is mapped to the reflectivity map and the crack centerline continuity feature. High reflectivity and low continuity segments are identified as reflectivity pseudo-crack segments, while high reflectivity and high continuity segments and low reflectivity and high continuity segments are retained as real crack segments. For real crack segments with endpoint distances not exceeding 12 pixels, endpoint extension direction angles not exceeding 25 degrees, and continuous reflectivity coverage between endpoints, the completion path with the minimum cumulative path cost is searched within a 4-pixel range on both sides of the endpoint connection line. When the average crack region probability of the path is not less than 0.25, the average crack centerline continuity feature is not less than 0.55, and the path length does not exceed 1.5 times the straight-line distance between endpoints, a reflectivity occlusion completion segment is generated and merged with the real crack segments on both sides to form a continuous surface micro-crack region.

[0032] In independent testing, 620 images of the forging surface were used, including 268 images of surface microcracks, 354 images of areas with obvious reflective surfaces, and 117 images of actual microcracks within the reflective areas. The original CrackFormer achieved a pixel-level precision of 84.6%, a recall of 81.9%, an intersection-over-union (IoU) ratio of 72.8%, and a false crack detection rate of 13.7% in reflective areas. Using a direct masking method for reflective areas improved the precision to 88.1%, but reduced the recall rate of actual microcracks in reflective areas to 74.3%. With this invention, the pixel-level precision reached 92.4%, the recall reached 90.8%, the IoU ratio reached 84.7%, the false crack detection rate in reflective areas decreased to 5.2%, and the recall rate of actual microcracks in reflective areas reached 88.9%. Manual verification of 63 cracks blocked by reflective surfaces showed that ordinary morphological closing operations correctly connected 44 cracks and generated 9 incorrect connections, while this invention correctly completed 55 cracks and generated only 3 incorrect connections. The average error of crack length relative to manual measurement results was reduced from 2.84 mm in the original CrackFormer to 1.07 mm, and the average error of maximum crack width was reduced from 0.31 mm to 0.14 mm. The test results show that this invention can simultaneously reduce false detections of highlight false edges and missed detections of real microcracks in reflective areas, and improve the integrity and dimensional accuracy of discontinuous cracks, without increasing the number of multi-angle cameras or multiple exposures.

[0033] Table 1. Comparison of the overall performance of different crack detection methods on the reflective non-ferrous metal forging test set.

[0034] This experiment used 620 independent test images collected from a non-ferrous metal forging workshop. Among these, 268 images contained surface microcracks, 354 images contained obvious reflective areas, and 117 images contained actual microcracks within the reflective areas. The completion effect of 63 microcracks partially obscured by localized reflections was evaluated. All detection methods used the same training set division, image size, and testing equipment. Pixel-level precision, pixel-level recall, and mean intersection-over-union (CIU) were calculated based on pixel-by-pixel annotation results. The correct completion rate and incorrect connection rate of microcracks obscured by reflections were calculated based on manual verification results. Crack length and maximum crack width were compared using manual measurements.

[0035] Table 1 shows that U-Net and DeepLabv3+ can identify surface microcracks with relatively clear outlines, but their ability to preserve features in slender, low-contrast, and reflective areas is insufficient. U-Net's average cross-union ratio is 62.8%, and the false crack detection rate in reflective areas reaches 20.6%, indicating that specular highlight boundaries and metal particle reflections are easily identified as cracks. After DeepLabv3+ expands its receptive field through dilated convolution, its pixel-level recall rate increases to 79.3%, but the recall rate for true microcracks in reflective areas remains at 72.6%, indicating that expanding the receptive field cannot directly solve the problem of confusion between highlight responses and microcrack responses.

[0036] After extracting multi-scale linear features using Self-AB and Scal-AB, CrackFormer achieves pixel-level precision and recall of 85.0% and 82.8%, respectively, with an average intersection-over-union (IoU) ratio of 72.6%. Its ability to identify continuous cracks and fine cracks outperforms U-Net and DeepLabv3+. However, the original CrackFormer does not incorporate spatial distribution information of reflective interference; the false crack detection rate in reflective areas remains at 13.7%, while the recall rate for real micro-cracks in reflective areas is 79.1%. This indicates that the original scaling attention can suppress some non-crack textures, but it cannot determine whether high-response linear features originate from real cracks or highlight boundaries.

[0037] The combination of CrackFormer and highlight region masking directly weakens the reflective position from the crack response, reducing the false crack detection rate in the reflective region to 8.4% and increasing the pixel-level precision to 88.1%. However, this method also weakens real microcracks in the reflective region, resulting in a pixel-level recall rate of 78.5% and a recall rate of only 74.3% for real microcracks in the reflective region, lower than the original CrackFormer's 79.1%. This result indicates that while uniform suppression based solely on highlight position can reduce false detections, it expands crack breakpoints located in the highlight region, failing to simultaneously suppress reflective false edges and preserve real microcracks.

[0038] The reflection confidence-constrained CrackFormer method achieves a pixel-level precision of 92.4%, a pixel-level recall of 90.8%, and an average intersection-over-union (AOU) of 84.7%. Compared to the original CrackFormer, this represents a 7.4 percentage point improvement in pixel-level precision, an 8.0 percentage point improvement in pixel-level recall, and a 12.1 percentage point improvement in AOU. This performance improvement is primarily attributed to the synergistic correction of the scaling attention weights by reflection confidence and crack centerline continuity features. When reflection confidence is high while crack centerline continuity is low, the linear response generated by the highlight boundary is suppressed. When both reflection confidence and crack centerline continuity are high, the crack centerline continuity feature reduces the amount of reflection suppression, allowing true microcracks passing through the reflection area to be preserved. Residual fusion is performed between the weighted decoded crack features and the original decoded crack features to further prevent the complete elimination of weak crack responses.

[0039] In the specific index of reflective areas, the false crack detection rate of the reflective confidence-constrained CrackFormer method was 5.2%, a decrease of 8.5 percentage points compared to the original CrackFormer, and a decrease of 3.2 percentage points compared to the combination of CrackFormer and highlight area mask. The recall rate of real microcracks in reflective areas was 88.9%, an improvement of 9.8 percentage points compared to the original CrackFormer, and an improvement of 14.6 percentage points compared to the combination of CrackFormer and highlight area mask. The simultaneous improvement in both false detection rate and recall rate indicates that this method does not obtain results by expanding or shrinking a uniform segmentation threshold, but rather by applying differentiated processing to different pixel locations based on the degree of reflective interference and evidence of crack continuity.

[0040] Among 63 microcracks blocked by reflective light, the CrackFormer method with reflective reliability constraints correctly completed 55 cracks, achieving a correct completion rate of 87.3% for cracks blocked by reflective light, and incorrectly connected 3 cracks, resulting in an incorrect connection rate of 4.8%. After combining the original CrackFormer with regular crack segment connections, the correct completion rate for cracks blocked by reflective light reached 69.8%, while the incorrect connection rate was 14.3%. This method filters the segments to be completed based on endpoint distance, endpoint extension direction, reflective coverage state, and crack centerline continuity, and searches for the completion path with the minimum cumulative path cost within a defined region, avoiding incorrect connections between adjacent scratches, highlight edges, or independent cracks based solely on spatial distance.

[0041] In crack size measurement, the average error of crack length using this method is 1.07 mm, a 62.3% reduction compared to the original CrackFormer's 2.84 mm. The average error of maximum crack width is reduced from 0.31 mm to 0.14 mm. The reduction in size error is due to the elimination of specular crack fragments by reflective conflict resolution, and the restoration of the continuous centerline of the true crack by reflective occlusion path completion. This prevents the crack length from being segmented due to local fractures and reduces the overestimation of width caused by specular region expansion. The inference time per image increases from 74.6 ms in the original CrackFormer to 83.7 ms, an increase of 9.1 ms. This increase is mainly due to reflective confidence scaling, crack centerline continuity calculation, and path search, but it still meets the processing requirements for continuous detection scenarios.

[0042] Comprehensive experimental results show that the reflectivity-constrained CrackFormer method can, while maintaining detection efficiency, incorporate reflectivity and crack centerline continuity into multi-scale attention correction, crack candidate segment determination, and reflectivity obstruction path completion. This reduces false crack detection caused by specular highlights, exposure saturation boundaries, and metal particle reflections, while preserving real microcracks with continuous extension characteristics within the reflective area. It also improves the accuracy of discontinuous crack recovery and crack size measurement, making it suitable for surface quality inspection of non-ferrous metal forgings with strong reflectivity, complex textures, and fine crack characteristics.

[0043] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for quality inspection of non-ferrous metal forgings based on image recognition, characterized in that, Includes the following steps: Acquire a surface image of the non-ferrous metal forging to be inspected, perform forging area localization and brightness correction, and generate a surface inspection image of the forging; The brightness response, saturation response, and local contrast response of the surface inspection image of the forging are extracted and fused according to pixel position to generate a reflectivity confidence map; The surface inspection image and reflection confidence map of the forging are input into the reflection confidence-constrained CrackFormer model to extract multi-scale crack features. Based on the reflectivity map, the scaling attention weight is adjusted to suppress the crack response in the reflective region, and the crack centerline continuity fusion is performed on the multi-scale crack features to generate a crack region probability map. Based on the probability map of the crack region, candidate crack segments are extracted. The reflection confidence map and the continuity feature of the crack center line are combined to make a reflection conflict judgment on the candidate crack segments. The path completion is performed on the candidate crack segments that are retained by the judgment and blocked by reflection, and the surface microcrack region and the quality inspection results of non-ferrous metal forgings are generated.

2. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The generation of the surface inspection image of the forging specifically includes: A surface image of the non-ferrous metal forging to be inspected is acquired at a fixed imaging position, and the surface image covers the surface to be inspected and its surrounding background. The forging region is separated from the surface image, and the image position and extension direction of the non-ferrous metal forging to be detected are corrected according to the forging region to obtain the positioning surface image; The global illumination component and local brightness component in the positioning surface image are separated. The brightness of the forging area is corrected based on the global illumination component, while the local brightness component is retained to generate a forging surface inspection image.

3. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The generation of the reflectivity map specifically includes: The surface inspection image of the forging is converted to the HSV color space. A luminance response representing the brightness of a pixel is generated based on the luminance channel, and a saturation response representing the color decay state is generated based on the saturation channel. The neighborhood brightness difference and brightness gradient are extracted centered on each pixel in the brightness channel to generate a local contrast response that characterizes the local brightness change state. Based on pixel location, brightness response, saturation response and local contrast response are consistently fused to generate an initial reflectivity map. The initial reflectivity map is subjected to isolated response removal and neighborhood smoothing, while retaining pixels within the forging area to generate a reflectivity map.

4. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 3, characterized in that, The consistency fusion multiplies the brightness response, saturation response, and local contrast response at the same pixel location, and takes the cube root of the multiplication result to obtain the reflectivity of the same pixel location. The value of each pixel in the initial reflectivity map represents the degree of confidence of the corresponding position on the forging surface being affected by local reflectivity interference, and does not represent the image saliency, pixel brightness, or probability of surface microcracks at the corresponding position.

5. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The reflective credibility constraint type CrackFormer model includes an input alignment unit, a 5-stage encoder, a 5-stage decoder, a reflective credibility constraint Scal-AB, a crack centerline continuity fusion unit, and a multi-stage crack fusion layer.

6. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The generation of the multi-scale crack features specifically includes: By adjusting the size of the forging surface detection image and the reflectivity map of the input alignment unit according to the same spatial transformation, the aligned forging surface detection image and the aligned reflectivity map of the pixel position are obtained. The surface inspection image of the aligned forging is encoded step by step by a 5-stage encoder to generate coded crack features at 5 scales in sequence. The alignment reflection confidence map is scaled up to 5 coding scales to generate a multi-scale reflection confidence map corresponding to the coded crack feature pixel positions at the 5 scales. The spatial resolution of the encoded crack features is restored step by step by the pooling index through a 5-stage decoder, and the decoded crack features at 5 scales are generated in sequence. By mapping the encoded crack features and decoded crack features of the same scale, multi-scale crack features are formed.

7. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The generation of the crack region probability map specifically includes: Scal-AB generates scaling attention weights based on the corresponding coded crack features by constraining each reflectivity level, and generates crack centerline responses based on the corresponding decoded crack features. The direction extension state and cross-scale coincidence state of each crack centerline response are extracted by the crack centerline continuity fusion unit to generate crack centerline continuity features at 5 scales. Based on pixel location, reflectivity suppression weights are generated using reflectivity confidence maps and crack centerline continuity features of the same scale. The reflectivity suppression weights are then used to correct the scaling attention weights, resulting in reflectivity correction scaling attention weights. The corresponding decoded crack features are weighted pixel by pixel using the reflection correction scaling attention weight, and residual fusion is performed with the decoded crack features before weighting to generate reflection constraint crack features at 5 scales. Based on the continuity characteristics of the crack centerline, the crack centerline continuity fusion is performed on the reflective constrained crack features at five scales, and a crack region probability map is generated through a multi-stage crack fusion layer.

8. The method for quality inspection of non-ferrous metal forgings based on image recognition according to claim 1, characterized in that, The generation of the surface microcrack region and the quality inspection results of non-ferrous metal forgings specifically includes: The initial crack region is extracted based on the crack region probability map. The centerline of the initial crack region is extracted and segmented to generate crack candidate segments. Each crack candidate segment is mapped to the reflectivity map and the continuity feature of the crack centerline, and a reflectivity conflict state is generated based on the reflectivity coverage state and the continuity state of the centerline. Based on the reflection conflict state, the candidate crack segments are judged, the real crack segments are retained and the reflective false crack segments are eliminated; The actual crack segments that are blocked by reflection are determined based on the endpoint positions and extension directions of the actual crack segments, and the completion path is searched between the corresponding endpoints to generate the reflection-blocked completion segments. By merging real crack segments and reflective shading completion segments, a surface microcrack region is generated, and the quality inspection results of non-ferrous metal forgings are generated based on the surface microcrack region.