Dense star field cosmic ray identification method and system fusing multi-scale linear attention

By introducing a multi-scale linear attention module and an efficient multi-scale attention module, combined with the loss function of dynamic weight adjustment, the problem of identification of cosmic rays and real celestial bodies in a single frame image is solved, and the accuracy and robustness of cosmic ray detection in dense star fields are improved.

CN120472219APending Publication Date: 2025-08-12KUNMING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510569076.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

The prior art is difficult to effectively distinguish cosmic rays from real celestial bodies in a single frame image, especially in dense star fields, which makes it difficult for the model to capture the global structure and local details of cosmic rays at the same time, and there is a problem of category imbalance that causes a decrease in detection accuracy.

Method used

The fusion of multi-scale linear attention module (MLA), efficient multi-scale attention module (EMA) and large-core select sub-block (LSKblock) are used to improve the recognition ability of the model in complex astronomical contexts.

Benefits of technology

The accuracy and robustness of cosmic ray recognition are improved in single-frame images, especially in high-density galaxies, maintaining high detection accuracy, reducing false positive rates, and meeting the high-precision data processing needs of modern astronomical observations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120472219A_ABST
    Figure CN120472219A_ABST
Patent Text Reader

Abstract

The invention discloses a dense star field cosmic ray identification method fusing multi-scale linear attention. The method comprises the following steps: acquiring a to-be-detected dense star field image and a trained dense star field cosmic ray identification model; to-be-detected dense star field image data are input into the encoding stage and processed in the encoding stage, and output subjected to maximum pooling operation in the encoding stage is obtained; taking the output subjected to the maximum pooling operation in the coding stage as the input of the neck stage, and processing in the neck stage to obtain the output of the neck stage; the output of the neck stage is used as the input of the transpose convolution operation of the decoding stage and the input of the multi-head self-attention mechanism, and the output of the transpose convolution operation, the output of the multi-head self-attention mechanism and the output of the LSK module in the coding stage are spliced to be used as the input of the first convolution block operation of the decoding stage; and the classification mask result of the to-be-detected dense star field image is output after the processing of a second first convolution block and a second convolution block in the decoding stage. According to the method, high detection precision can be kept in a high-density galaxy region, and the robustness of the method in a complex observation scene is highlighted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a dense star field cosmic ray recognition method and system integrating multi-scale linear attention, belonging to the field of image processing based on computer vision. Background Art

[0002] Cosmic rays are high-energy charged particles from outer space, mainly composed of protons and helium nuclei. When they strike astronomical detectors (such as the Hubble Space Telescope and the James Webb Space Telescope), they form bright noise in the image, appearing as randomly distributed bright spots or stripes. This noise not only interferes with the accuracy of astronomical observation data, but also affects subsequent scientific tasks such as astrometry and spectral analysis. Especially in dense star fields (such as galaxy clusters and star-dense regions), the morphology of cosmic rays is highly similar to the edge features of real celestial bodies (such as stars and galaxies), making it difficult for traditional methods to effectively distinguish them, resulting in false detections or missed detections, and reduced data quality.

[0003] At present, the identification of cosmic rays in astronomical images mainly relies on multi-frame image synthesis and single-frame image analysis. The multi-frame method uses the median superposition or super-resolution reconstruction of multiple observations to eliminate cosmic rays, but this method requires multiple repeated observations, which is not only time-consuming but also cannot be applied to single-exposure scenarios such as transient celestial bodies. The single-frame method is mainly based on traditional image processing (such as edge detection and morphological filtering) or deep learning (such as convolutional neural networks). Traditional algorithms rely on manually designed features and are difficult to adapt to complex astronomical backgrounds. Although existing deep learning models can automatically learn cosmic ray features, they still have two major bottlenecks in dense star fields. First, it is difficult for the model to simultaneously capture the global structure and local details of cosmic rays, resulting in an increase in the misjudgment rate in high-density areas. Second, the extremely low proportion of cosmic ray pixels (usually less than 1%) leads to category imbalance during training. The model is prone to bias towards background prediction, which reduces detection accuracy.

[0004] In recent years, several improved deep learning methods (such as U-Net variants and attention mechanisms) have been introduced to the task of cosmic ray recognition, but they still suffer from problems such as low computational efficiency and insufficient modeling of long-range dependencies. For example, some models use global attention mechanisms to enhance feature associations, but this is computationally expensive and difficult to apply to high-resolution astronomical images. Other models attempt to enlarge the convolution kernel to enhance the receptive field, but lack the ability to dynamically adapt to features of different scales, resulting in performance degradation in complex star fields. Furthermore, most existing loss functions use fixed weights and cannot be adjusted adaptively, making model optimization difficult in cases of extreme class imbalance, affecting the final detection effect. Therefore, there is an urgent need for an efficient, robust, and adaptable cosmic ray recognition method for dense star fields that can accurately distinguish cosmic rays from real celestial objects in a single frame while also taking into account computational efficiency to meet the high-precision data processing requirements of modern astronomical observations.

[0005] In view of this, the present invention is proposed. Summary of the Invention

[0006] The present invention provides a dense star field cosmic ray recognition method integrating multi-scale linear attention, which is used to construct a dense star field cosmic ray recognition model. The model realizes efficient collaborative modeling of global context and local texture features by introducing a multi-scale linear attention (MLA) module, an efficient multi-scale attention (EMA) module and a large kernel selector block (LSKblock), effectively improving the model's recognition ability of CR structures under complex astronomical backgrounds; further, a binary cross entropy loss function (GRD-BCE) based on Gaussian residual response and dynamic weight adjustment is designed to effectively alleviate the class imbalance problem by adaptively adjusting the gradient weight of negative samples, further optimizing the performance of the model on single-frame data.

[0007] The technical solution of the present invention is:

[0008] According to a first aspect of the present invention, a method for identifying cosmic rays in a dense star field by integrating multi-scale linear attention is provided, comprising the following steps:

[0009] S1. Obtain a dense star field image to be detected and a trained dense star field cosmic ray recognition model; the dense star field cosmic ray recognition model adopts an architecture based on an encoding stage, a neck stage, a multi-head self-attention mechanism, and a decoding stage, wherein the encoder stage includes two first convolution blocks connected in sequence, an LSK module, and a maximum pooling operation; the neck stage includes two first convolution block operations connected in sequence, an MLA module; the decoding stage includes a transposed convolution operation, two first convolution block operations, and a second convolution block connected in sequence;

[0010] S2. Input the dense star field image data to be detected into the encoding stage, and process it in sequence through two first convolution blocks, an LSK module, and a maximum pooling operation in the encoding stage to obtain the output of the maximum pooling operation in the encoding stage; use the output of the maximum pooling operation in the encoding stage as the input of the neck stage, and process it in sequence through two first convolution block operations and an MLA module in the neck stage to obtain the output of the neck stage; use the output of the neck stage as the input of the transposed convolution operation and the multi-head self-attention mechanism in the decoding stage, and splice the output of the transposed convolution operation, the output of the multi-head self-attention mechanism, and the output of the LSK module in the encoding stage as the input of the first first convolution block operation in the decoding stage, and then output the classification mask result of the dense star field image to be detected after processing by the second first convolution block and the second convolution block in the decoding stage.

[0011] Furthermore, the first convolution block includes a depth-separable convolution operation, ReLU, and EMA modules; and the second convolution block adopts a two-dimensional convolution operation.

[0012] Furthermore, the acquiring of the dense star field image to be detected and the trained dense star field cosmic ray recognition model is specifically as follows:

[0013] Obtain multi-band dense star field image data and construct training and test sets;

[0014] The dense star field cosmic ray recognition model is trained and verified based on the training set to obtain a trained dense star field cosmic ray recognition model;

[0015] The test set is used as the dense star field image to be detected and input into the trained dense star field cosmic ray recognition model to obtain the classification mask result.

[0016] Furthermore, the loss function of the dense star field cosmic ray identification model is a binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment, which is improved from the binary cross entropy loss function. Specifically,

[0017] Given an input image I, we first use a Gaussian convolution kernel Perform background estimation, the expression is:

[0018]

[0019] Among them, B g Represents the Gaussian convolution kernel The background estimation image obtained by performing convolution operation on the input image I;

[0020] Then calculate the absolute residual map R = |IB g |, and then normalize the absolute residual map:

[0021]

[0022] Among them, R n represents the normalized absolute residual map, ∈ is a very small constant used to prevent zero division errors; max(R) represents the maximum value in the absolute residual map R;

[0023] For each batch normalized absolute residual map Calculate its MAD value:

[0024]

[0025] in, Represents the normalized absolute residual map R of the i-th batch n ;

[0026] Convert the MAD value to a standard deviation estimate σ r ; Based on σ rDefine a dynamic threshold interval [floor, ceil], where:

[0027] floor=max(0,σ r )

[0028]

[0029] Perform double threshold truncation on the normalized absolute residual map:

[0030]

[0031] In the formula, clip() represents the clip function; Represents the absolute residual graph after normalization of the i-th batch The result obtained by using the clip function and performing a double threshold truncation operation based on the lower threshold floor and the upper threshold ceil;

[0032] right Perform zero mean and Gaussian filtering:

[0033]

[0034] in, Express Perform zero mean operation, Represents the Gaussian convolution kernel right Perform convolution operation; mean() represents the mean function;

[0035] The weight matrix is obtained by normalization and dynamic range constraint:

[0036]

[0037] in, represents the weight matrix obtained after normalization and dynamic range constraint; α represents the balance coefficient;

[0038] Finally, the binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment is Defined as:

[0039]

[0040] Among them, y j is the true label of the jth valid pixel, p j is the predicted probability of the jth valid pixel, and N is the number of valid pixels.

[0041] According to a second aspect of the present invention, a dense star field cosmic ray identification system integrating multi-scale linear attention is provided, comprising a module of any one of the above-mentioned dense star field cosmic ray identification methods integrating multi-scale linear attention.

[0042] According to a third aspect of the present invention, a processor is provided, which is used to perform operations, including executing any one of the above-mentioned dense star field cosmic ray identification methods integrating multi-scale linear attention.

[0043] The beneficial effects of the present invention are as follows: at the model architecture design level, the present invention adds a multi-scale linear attention (MLA) module to the original Unet model, captures long-range dependencies through the collaborative design of convolutions of different scales and depth-separable convolutions, and realizes the collaborative perception of global context and local features. In addition, an efficient multi-scale attention (EMA) module is introduced, which optimizes cross-space interactions by feature grouping and a dual-branch architecture, and captures local details of CR in combination with adaptive spatial gating weights. Finally, a large kernel selector block (LSKblock) is used to expand the receptive field range through feature fusion of multi-scale convolution kernels, and the ability of context-aware CR is enhanced in conjunction with a dual-path pooling strategy. At the algorithm optimization level, in response to the extremely unbalanced distribution characteristics of CRs and background objects in single-frame astronomical data, the present invention proposes a binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment to further improve model performance. Furthermore, experimental results show that the model of the present invention exhibits good performance in the F435W, F606W and F814W band data of the Hubble Space Telescope ACS-WFC. Under strict false positive rate (FPR) constraints (0.5% and 0.05%), the model achieves improved detection performance compared to the classic deepCR method. Ablation experiments verify the effectiveness of each module and the GRD-BCE loss function. Furthermore, residual analysis shows that the proposed model maintains high detection accuracy in high-density galaxy regions, with a significantly lower proportion of non-zero residuals than the baseline method, highlighting its robustness in complex observation scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 This is a model structure diagram of the present invention;

[0045] Figure 2 There are three types of observation fields: extragalactic fields, globular clusters, and resolved galaxies, and the astronomical source density is arranged from low to high;

[0046] Figure 3 This is a comparison chart of the receiver operating characteristic curves of the model proposed in the present invention in the F435W / F606W / F814W bands;

[0047] Figure 4This is a visualization comparison chart of the residuals of the model proposed in this invention in the F435W / F606W / F814W bands. DETAILED DESCRIPTION

[0048] To make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other in any way.

[0049] The invention will be further described below with reference to the accompanying drawings and embodiments, but the content of the present invention is not limited to the scope of the drawings.

[0050] Example 1: Figure 1-4 As shown, according to a first aspect of an embodiment of the present invention, a method for identifying cosmic rays in a dense star field by integrating multi-scale linear attention is provided, comprising the following steps:

[0051] S1. Obtain a dense star field image to be detected and a trained dense star field cosmic ray recognition model; the dense star field cosmic ray recognition model adopts an architecture based on an encoding stage, a neck stage, a multi-head self-attention mechanism, and a decoding stage. The encoder stage includes two first convolution blocks connected in sequence, an LSK module, and a maximum pooling operation; the neck stage includes two first convolution block operations connected in sequence, an MLA module; the decoding stage includes a transposed convolution operation, two first convolution block operations, and a second convolution block connected in sequence; the specific structure is as follows Figure 1 As shown;

[0052] S2. Input the dense star field image data to be detected into the encoding stage, and process it in sequence through two first convolution blocks, an LSK module, and a maximum pooling operation in the encoding stage to obtain the output of the maximum pooling operation in the encoding stage; use the output of the maximum pooling operation in the encoding stage as the input of the neck stage, and process it in sequence through two first convolution block operations and an MLA module in the neck stage to obtain the output of the neck stage; use the output of the neck stage as the input of the transposed convolution operation and the multi-head self-attention mechanism in the decoding stage, and splice the output of the transposed convolution operation, the output of the multi-head self-attention mechanism, and the output of the LSK module in the encoding stage as the input of the first first convolution block operation in the decoding stage, and then output the classification mask result of the dense star field image to be detected after processing by the second first convolution block and the second convolution block in the decoding stage.

[0053] Furthermore, the first convolution block includes a depth-separable convolution operation, a ReLU function, and an EMA module; and the second convolution block adopts a two-dimensional convolution operation.

[0054] The step of obtaining the dense star field image to be detected and the trained dense star field cosmic ray recognition model is as follows:

[0055] Obtain multi-band dense star field image data and construct training and test sets;

[0056] The dense star field cosmic ray recognition model is trained and verified based on the training set to obtain a trained dense star field cosmic ray recognition model;

[0057] The test set is used as the dense star field image to be detected and input into the trained dense star field cosmic ray recognition model to obtain the classification mask result.

[0058] Furthermore, the loss function of the dense star field cosmic ray identification model is a binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment, which is improved from the binary cross entropy loss function BCE loss. The specific formula is as follows:

[0059] Given an input image First, a Gaussian convolution kernel with standard deviation σ = 2 and kernel size 5×5 is used. Perform background estimation, which can be expressed as:

[0060]

[0061] Among them, B g Represents the Gaussian convolution kernel The background estimation image obtained by convolution operation on the input image I, represents the dimensional form of image I in real space, where B represents the batch size (i.e., the number of images processed at a time), 1 represents the number of image channels (here, a single-channel image), H is the image height, W is the image width, and * represents a two-dimensional convolution operation. The discretization of the Gaussian kernel is obtained by discrete sampling of a radially symmetric two-dimensional Gaussian function. The weight of the coordinate (x, y) within the kernel is calculated as:

[0062]

[0063] After normalization, we ensure This ensures the smoothness of background estimation.

[0064] Then calculate the absolute residual map R = |IB g |, the residual reflects the degree of deviation of pixel intensity from the local background, which quantifies the difference between each pixel in the input image I and the background estimate B after smoothing. gTo avoid numerical scale issues caused by differences in lighting conditions, the absolute residual map is normalized:

[0065]

[0066] Among them, R n Represents the normalized absolute residual map, ∈=10 -6 is a very small constant used to prevent zero division errors; max(R) represents the maximum value in the absolute residual graph R. Normalized residual graph R n The values are constrained to be in the range [0,1], where high-value areas correspond to potential foreground targets and low-value areas represent background noise. The dynamic weight generation mechanism is the key to improving the robustness of the model. The traditional multi-frame median method suppresses noise through time dimension statistics, but in a single-frame scenario, it is necessary to establish statistical characteristics of the spatial dimension. To this end, the present invention introduces a robust standard deviation estimation based on the median absolute deviation (MAD); for each batch of absolute residual maps Calculate its MAD value:

[0067]

[0068] in, Represents the normalized residual graph R of the i-th batch n ;

[0069] Convert the MAD to a standard deviation estimate using the factor 1.4826:

[0070] σ r =1.4826·MAD

[0071] Where, σ r represents the standard deviation estimate;

[0072] This coefficient is derived from the normal distribution characteristics, so that σ r When the data follows a Gaussian distribution, it is consistent with the sample standard deviation. r Define a dynamic threshold interval [floor, ceil], where:

[0073] floor=max(0,σ r )

[0074]

[0075] Perform double threshold truncation on the residual map:

[0076]

[0077] In the formula, clip() represents the clip function, which is used to limit the value to the specified interval; Represents the residual graph after normalization of the i-th batch Use the clip function to perform a double-threshold truncation operation based on floor (lower threshold) and ceil (upper threshold);

[0078] This operation can effectively suppress r To further enhance the spatial continuity of the weight matrix, Perform zero mean and Gaussian filtering:

[0079]

[0080] in, Express Perform zero mean operation, Represents the Gaussian convolution kernel right Perform convolution operation; mean() represents the mean function, which is used to calculate The average value of each element in ; the Gaussian filter parameters are consistent with the background estimation stage to ensure a smooth transition of weight changes. Finally, the weight matrix is obtained through normalization and dynamic range constraint:

[0081]

[0082] in, represents the weight matrix obtained after normalization and dynamic range constraint; α represents the balance coefficient;

[0083] The weight matrix is designed to balance class imbalance and training stability. Finally, this binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment is Defined as the formula:

[0084]

[0085] Among them, y j is the true label of the jth valid pixel, p j is the predicted probability of the jth valid pixel, and N is the number of valid pixels (excluding the ignored areas).

[0086] The update strategy of the balance coefficient α is designed as a piecewise function:

[0087]

[0088] Where α(t) is α; t represents the current training cycle, T max is a preset upper limit of the transition period (in the embodiment of the present invention, it is set to 100).

[0089] Applying the above technical solution, we can see that this design disables negative sample weighting in the early stages of training (t≤1), which is equivalent to the standard cross-entropy loss and avoids the introduction of bias when the weight matrix is not fully optimized. As training progresses, α linearly increases to 1.0, gradually increasing the penalty for negative samples, alleviating the gradient imbalance problem caused by sparse CR pixels and allowing the model to learn clear boundaries for CR.

[0090] In terms of implementation details and optimization, in order to ensure numerical stability, a truncation constraint is imposed on the predicted probability output by the network:

[0091] p←clip(p,∈1,1-∈1)

[0092] Where p is the result obtained after truncation constraint on the predicted probability of the network output, ∈1=10 -7 , to prevent gradient explosion or vanishing phenomenon in logarithmic operation. Gaussian filtering in the weight matrix generation process is implemented by separated convolution, which decomposes the two-dimensional convolution into two-step one-dimensional convolution in the horizontal and vertical directions, and the computational complexity is reduced from O(k 2 ) is reduced to O(2k), where k=5 is the convolution kernel size. Although weight calculations need to be processed sample by sample to maintain statistical independence, the vectorized operations of the PyTorch framework and the torch.no_grad() context management enable intra-batch parallel processing, avoiding the computational overhead of explicit loops. The effectiveness of the binary cross entropy loss (i.e., GRD-BCE loss) based on Gaussian residual response and dynamic weight adjustment proposed in the present invention on ACS-WFC data is verified in Table 2 of Example 2.

[0093] According to a second aspect of an embodiment of the present invention, a system for identifying cosmic rays in a dense star field by integrating multi-scale linear attention is provided, comprising a module of any of the above-described methods for identifying cosmic rays in a dense star field by integrating multi-scale linear attention. Specifically, the system comprises:

[0094] An acquisition module is used to acquire a dense star field image to be detected and a trained dense star field cosmic ray recognition model; the dense star field cosmic ray recognition model adopts an architecture based on an encoding stage, a neck stage, a multi-head self-attention mechanism, and a decoding stage. The encoder stage includes two first convolution blocks connected in sequence, an LSK module, and a maximum pooling operation; the neck stage includes two first convolution block operations connected in sequence, an MLA module; and the decoding stage includes a transposed convolution operation, two first convolution block operations, and a second convolution block connected in sequence.

[0095] The recognition module is used to input the dense star field image data to be detected into the encoding stage, and process it in sequence through two first convolution blocks, an LSK module, and a maximum pooling operation in the encoding stage to obtain the output of the maximum pooling operation in the encoding stage; use the output of the maximum pooling operation in the encoding stage as the input of the neck stage, and process it in sequence through two first convolution block operations and an MLA module in the neck stage to obtain the output of the neck stage; use the output of the neck stage as the input of the transposed convolution operation and the input of the multi-head self-attention mechanism in the decoding stage, splice the output of the transposed convolution operation, the output of the multi-head self-attention mechanism, and the output of the LSK module in the encoding stage as the input of the first first convolution block operation in the decoding stage, and then output the classification mask result of the dense star field image to be detected after processing by the second first convolution block and the second convolution block in the decoding stage.

[0096] For the parts of the modules not described in detail above, please refer to other contents of this embodiment.

[0097] According to a third aspect of an embodiment of the present invention, a processor is provided, the processor being configured to execute operations, the operations comprising executing any one of the above-described methods for identifying cosmic rays in a dense star field by integrating multi-scale linear attention. Specifically, the processor is configured to obtain a dense star field image to be detected and a trained dense star field cosmic ray identification model; input the dense star field image data to be detected into an encoding stage, sequentially processing the image data through two first convolution blocks, an LSK module, and a maximum pooling operation in the encoding stage to obtain an output of the maximum pooling operation in the encoding stage; using the output of the maximum pooling operation in the encoding stage as input to a neck stage, sequentially processing the image data through two first convolution blocks and an MLA module in the neck stage to obtain an output of the neck stage; using the output of the neck stage as input to a transposed convolution operation and a multi-head self-attention mechanism in a decoding stage; concatenating the output of the transposed convolution operation, the output of the multi-head self-attention mechanism, and the output of the encoding stage through the LSK module as input to a first first convolution block operation in the decoding stage; and outputting a classification mask result of the dense star field image to be detected after processing the image data through a second first convolution block and a second convolution block in the decoding stage.

[0098] Example 2: The following describes the specific implementation process of the present invention in combination with experimental data:

[0099] A dense star field cosmic ray recognition method integrating multi-scale linear attention includes:

[0100] Step S1: Obtain benchmark data for cosmic ray detection in dense star fields and construct training and test sets. The dataset used in the experiment comes from the public benchmark data constructed by the deepCR-ACS / WFC framework. This dataset is observed using filters in three bands: F435W, F606W, and F814W. Each filter contains three types of observation fields: extragalactic fields, globular clusters, and resolved galaxies. The astronomical source density is arranged from low to high. Figure 2 Shown are three types of observation field images from the F435W filter. The experimental test set focuses on the extreme observation environment of high-density star fields, specifically selecting all data from sub-images of resolved galaxy regions. The experiment follows a rigorous preprocessing process to eliminate instrumental noise interference: the original image is trimmed of a 128-pixel border region to suppress detector artifacts, and low signal-to-noise ratio images with exposure times under 100 seconds are excluded. Finally, the active area is cut into 256×256 pixel sub-images to ensure spatial consistency and balanced signal-to-noise ratio of the input data. The total training set contains 25,200 sub-images, divided into three groups based on the filter: F435W (7,980 images), F606W (8,820 images), and F814W (8,400 images). The test set designed by this invention focuses on the extreme observation environment of high-density star fields, specifically selecting 2,520 sub-images of resolved galaxy regions (F435W: 420 images; F606W: 1,050 images; F814W: 1,050 images).

[0101] Step S2: Construct a dense star field cosmic ray recognition model based on the encoding stage, neck stage, decoding stage and multi-head self-attention mechanism architecture;

[0102] The images in the dense star field cosmic ray detection benchmark database constructed in step S1 are sent to the dense star field cosmic ray recognition model in a size of 1×256×256.

[0103] The innovative features of this dense star field cosmic ray recognition model are: First, an efficient multi-scale attention module (EMA module) is introduced in the first convolutional block to enhance the ability to extract cosmic ray CR features. Second, a large selective kernel block (LSK block) is added after the second first convolutional block in the encoder stage to achieve hierarchical fusion of multi-scale spatial features. Through a dynamic weight adjustment mechanism, it effectively coordinates the joint modeling of local CR detail features and global context information, improving the context-aware CR capability. Third, a multi-scale linear attention module (MLA operation) is introduced after the second first convolutional block in the neck stage to expand the model's global receptive field in dense star fields and further improve the model's multi-scale feature extraction capabilities. Fourth, a multi-head self-attention mechanism is integrated to establish cross-scale feature correlations, effectively amplifying cosmic ray-related features and suppressing background interference.

[0104] The EMA module specifically performs the following operations:

[0105] Given an input feature map EMA first divides it into G groups of sub-features along the channel dimension, that is, X=[X0,X1,…,X G-1 ],in C, H, and W represent the number of channels, height, and width, respectively. By reshaping the grouped features to the batch dimension (B represents the batch size), the module optimizes computational efficiency while maintaining channel integrity. This reorganization strategy allows each group of sub-features to independently learn spatial semantic distribution, while enhancing feature diversity through subsequent cross-group interactions. The module contains two parallel branches: a 1×1 convolution branch captures global channel dependencies, and a 3×3 convolution branch extracts local multi-scale features. For the 1×1 branch, dual-path spatial pooling is used to encode global information: horizontal pooling along the height direction generates vertical position encoding. Vertical pooling along the width direction generates horizontal position encoding After splicing, the two layers are connected through a shared 1×1 convolution to achieve cross-channel interaction:

[0106] H 1×1 =σ(Conv 1×1 (Concat(z H ,z W )))

[0107] The 3×3 branch enhances the local receptive field by expanding the convolution kernel:

[0108] H 3×3 =Conv 3×3 (X′)

[0109] Among them, σ represents the Sigmoid activation function, Convk×k is a k×k convolution operation. To establish pixel-level dependencies, the module introduces a cross-branch interaction mechanism based on matrix dot product. First, global average pooling (GAP) is performed on the channel dimension of the two groups of branch outputs to generate a spatial weight matrix:

[0110] Q 1×1 =Softmax(GAP(H 1×1 )0

[0111] K 3×3 =Softmax(GAP(H 3×3 ))

[0112] Feature cross fusion is achieved through matrix multiplication:

[0113]

[0114] The final output uses a gating mechanism to enhance salient features:

[0115] Y = GroupNorm(X⊙σ(W))

[0116] Where ⊙ represents element-by-element multiplication, and GroupNorm is a group normalization operation. This design allows the module to simultaneously model short-range local features and long-range global dependencies while avoiding channel dimensionality reduction, while maintaining computational efficiency through lightweight matrix operations. The effectiveness of this module in the dense star field CR detection task is demonstrated in the ablation experiments in Table 1.

[0117] The LSK module specifically performs the following operations:

[0118] The LSK module adopts a dual-branch parallel processing architecture. Input features First, primary features are generated through 5×5 depth-wise separable convolution A1 is then input into a 7×7 depthwise separable convolution with a dilation rate of 3 to generate secondary features with a large receptive field.

[0119] A1=DepthwiseConv 5×5 (X)

[0120]

[0121] Then, A1 and A2 are projected to space, and splice along the channel dimension to obtain a joint feature map In order to establish cross-scale spatial correlation, a feature aggregation module is designed to c Perform spatial statistical information extraction:

[0122]

[0123] After concatenating the average pooling and maximum pooling features along the channel dimension, the spatial correlation model is performed through a 7×7 convolutional layer to generate a spatial weight distribution map. This process is normalized by the Sigmoid function:

[0124] S=σ(Conv 7×7 ([A avg ; A max ]))

[0125] Among them, σ(·) represents the Sigmoid activation function, and [·;·] represents the channel splicing operation. Finally, the dual-branch features are adaptively combined through the dynamic weight fusion mechanism and gated modulated with the original input features:

[0126] A fuse =S (0) ⊙A1+S (1) ⊙A2Y=X⊙Conv 1×1 (A fuse )

[0127] Where ⊙ represents an element-by-element multiplication operation. This design dynamically adjusts the contribution of features at different scales through learnable spatial weights, enabling the network to adaptively focus on key anatomical regions. The effectiveness of this module is demonstrated in the experimental analysis in Table 1.

[0128] The MLA module specifically performs the following operations:

[0129] Given an input feature map The module first maps the input features into three independent subspaces (Query, Key, Value) through linear transformation (1×1 convolution), where the channel dimension is the product of the total number of heads (heads) and the single head feature dimension (dim). The Q / K / V features of adjacent spatial positions are locally aggregated through depthwise separable convolution with different kernel sizes. Specifically, the input feature map X is first divided into n subspaces along the channel dimension. s Groups (n s is the number of scales), the number of channels in each group is C / n s Each group applies a depth-wise separable convolution of corresponding scale s:

[0130] F s =DWConv s×s (X s ),s∈{3,5}

[0131] in, For the sub-feature map after input grouping, DWConv s×sDenotes the depth convolution with kernel size s. Next, the depth convolution result F of each group is s Apply 1×1 projection in the form of group convolution to expand the number of channels to 3D. The number of groups in the group convolution is n s , each group independently processes the corresponding F s :

[0132]

[0133] Among them, the projection weight W s,proj Only applies to channels within the group, with a total parameter value of n s ×C×3d. Finally, the QKV of each group s Splicing along the channel dimension to obtain the final multi-scale fusion features:

[0134]

[0135] In the attention calculation stage, this paper adopts ReLU linear attention to replace the traditional Softmax attention mechanism. The calculation process can be decomposed into three steps: first, ReLU nonlinear activation is applied to Q and K respectively, and feature correlation is established through matrix multiplication; then, the associative property of matrix multiplication is used to reduce the computational complexity from downgraded to Finally, the normalization operation is performed to maintain the feature stability. Specifically, given the input feature After expansion, the QKV feature with dimensions of B×3d×H×W is obtained, which is decomposed into independent Q, K, and V components through rearrangement operation. The feature correlation calculation can be expressed as:

[0136]

[0137] Finally, the multiple branches are aggregated and the attention outputs from different scales are connected before the final projection. The projection layer uses channel-level connections and then linearly fuses multi-scale features through 1×1 convolution:

[0138] Y=Linear(Concat(O0,O3,O5))

[0139] Among them, the output of only the ReLU and linear attention calculation path is O0, the output of the 3×3 convolution path is O3, and the output of the 5×5 convolution path is O5. 1×1 Represents a 1×1 convolution operation, Concat represents a concatenation operation along the channel dimension, and Y is the final output feature after multi-scale feature fusion.

[0140] Through deep convolution operations and linear attention complexity, this design achieves simultaneous modeling of global context and local details while maintaining hardware efficiency, further improving the model's multi-scale feature extraction capabilities. Table 1 shows that its F1 / F2 scores are 0.37% / 0.43% higher than the baseline.

[0141] Step S3: Output a pixel-level classification mask (1 represents a CR pixel, 0 represents a non-CR pixel) through the model of the present invention; calculate the true positive rate (TPR) and false positive rate (FPR) of the detection result based on the real mask, and further use the precision rate, recall rate, F1 score, and F2 score evaluation indicators to measure the cosmic ray detection performance of this method. Specifically:

[0142] For the output of deep neural networks, the receiver operating characteristic (ROC) curve is used as a basic evaluation tool to systematically analyze the dynamic balance between the true positive rate (TPR) and the false positive rate (FPR) under different discrimination thresholds. Its mathematical representation is:

[0143]

[0144] Where TP represents correctly identified cosmic ray pixels, FN represents missed cosmic ray pixels, FP represents misclassified non-cosmic ray pixels, and TN represents correctly rejected non-cosmic ray pixels. Ideally, for a fixed FPR, the network should provide the highest possible TPR.

[0145] Since cosmic ray recognition is essentially an image segmentation task, this paper uses common evaluation indicators in the field of image segmentation: precision, recall, F1 score, and F2 score to evaluate the model. The calculation formula is as follows:

[0146]

[0147] Among them, the precision quantifies the proportion of real cosmic ray pixels in the model prediction results, directly reflecting the reliability of the detection results; the recall rate characterizes the completeness of the model's coverage of the actual cosmic ray region. The two together constitute the basic dimensions of performance evaluation. F1-score, as the harmonic average of precision and recall, achieves a balanced evaluation of detection accuracy and coverage breadth. The present invention further introduces the F2-score indicator, which enhances the sensitivity of the assessment of weak signal capture capabilities by increasing the weight of the recall rate. This multi-indicator collaborative verification mechanism not only guarantees the comprehensive performance of the model in conventional scenarios, but also realizes the targeted optimization of key indicators based on domain-specific needs, ultimately forming an evaluation system that takes into account both versatility and specificity.

[0148] The specific application can be as follows:

[0149] To verify the effectiveness of each module in the model architecture, we first conducted systematic ablation experiments on the new model on the deepCR baseline model, as shown in Table 1. It should be noted that there is an inherent trade-off between precision and recall, and the F1 score (harmonic mean) and F2 score (weighted recall) can more comprehensively evaluate the model's overall performance in class imbalance scenarios.

[0150] Table 1: Performance comparison of module ablation experiments based on deepCR baseline.

[0151] model precision recall f1_score f2_score deepCR 81.43 77.26 79.29 78.42 deepCR+MLA 81.07 78.3 79.66 78.85 deepCR+LSK 81.51 78.8 80.13 79.33 deepCR+EMA 78.72 79.12 78.92 78.52 deepCR+MLA+LSK 81.73 79.33 80.52 79.8 deepCR+MLA+EMA 81.54 79.49 80.5 79.89 deepCR+LSK+EMA 80.86 80.26 80.56 80.37 deepCR+MLA+LSK+EMA 81.63 80.56 81.09 80.82

[0152] When the MLA module is introduced alone, the model achieves improvements of 1.04%, 0.37%, and 0.43% in recall, F1, and F2 scores, respectively. This demonstrates the positive impact of the multi-scale linear attention mechanism on global context modeling in dense star fields. Further incorporating the LSKblock module (deepCR+MLA+LSK), the model's perception of CR structure is significantly enhanced, with recall increasing by 2.07 percentage points (from 77.26% to 79.33%) compared to the baseline model. This demonstrates the effectiveness of large kernel convolutions in capturing long-range dependencies in dense star fields by expanding the receptive field. When the three modules are combined synergistically (deepCR+MLA+LSK+EMA), the model achieves state-of-the-art recall, F1, and F2 scores of 80.56%, 81.09%, and 80.82%, respectively, representing improvements of 3.30%, 1.80%, and 2.40% over the baseline model. Ablation experiments demonstrate the effectiveness of each module in the new model.

[0153] Furthermore, the performance of deepCR and the model of the present invention is compared using the standard binary cross entropy loss (BCE) and the binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment (GRD-BCE), respectively. The comparison results are shown in Table 2.

[0154] Table 2:

[0155] LOSS precision recall f1_score f2_score deepCR(BCE) 81.43 77.26 79.29 78.42 deepCR(GRD-BCE) 81.81 78.03 79.88 79.07 ourmodel(BCE) 81.63 80.56 81.09 80.82 ourmodel(GRD-BCE) 82.05 80.93 81.49 81.25

[0156] In the above, the present invention further analyzes the contribution of the binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment (GRD-BCE). The experimental data are shown in Table 2. Under the same model architecture, the model using GRD-BCE loss has improved recall, F1 and F2 scores compared to the traditional BCE loss. This improvement can be attributed to the adaptive suppression of background noise gradients by the Gaussian residual response mechanism, which reduces the risk of false detection of celestial object edges. In addition, the complete model after joint optimization (Our model (GRD-BCE), that is, the model proposed in this invention uses the binary cross entropy loss function (GRD-BCE) based on Gaussian residual response and dynamic weight adjustment) has the best performance in all indicators, verifying the synergistic advantages of the dynamic loss function and the multi-scale feature extraction network.

[0157] Furthermore, in order to evaluate the actual performance advantages of the model in astronomical observation scenarios, the present invention uses the receiver operating characteristic curve (ROC curve) to evaluate and compare the new model. Since Zhang & Bloom have proven that deepCR is superior to lacosmic, the present invention will not display the ROC curve of lacosmic. Since cosmic rays may affect adjacent pixels due to charge diffusion in CCD, and the expansion operation can conservatively cover the physical diffusion range of CR, in order to more comprehensively measure the performance of the model, the present invention uniformly performs expansion operations on the output masks of the two models. The ROC curve plots the relationship between the true positive rate (i.e., the proportion of correctly identified CR artifact pixels) and the false positive rate (i.e., the proportion of pixels misjudged as CR) by adjusting the threshold parameters of a given model. The results are shown as follows: Figure 3 As shown in Table 3 (deepCR represents the ROC curve obtained by using the deepCR model without performing the expansion operation, deepCR+ represents the ROC curve obtained by using the deepCR model with the expansion operation, our model represents the ROC curve obtained by using the model of the present invention without performing the expansion operation, and our model+ represents the ROC curve obtained by using the model of the present invention with the expansion operation); for the deepCR and the present invention models in the F435W / F606W / F814W band data, the comparison results of the false positive rate of 0.05% and the true positive rate (TPR, %) at the threshold of 0.5% are shown in Table 3.

[0158] Table 3:

[0159]

[0160]

[0161] Through the above, the present invention compares the ROC curve of the new model with deepCR on the ACS / WFC three-band data, as well as the detection sensitivity under strict FPR constraints, such as Figure 3 As shown in Table 3. Figure 3 The curves show that different models have different abilities to distinguish resolved galaxies under different filters, but the blue curve representing the new model is always higher than the red curve representing deepCR. Combined with Table 3, we can see that the new model achieves higher TPRs at the same FPR under multiple filters, regardless of whether or not the dilation operation is performed. At an FPR of 0.05%, the integrated global model of the present invention shows TPRs of 77.13%, 66.76%, and 70.09% in these filter images, respectively, which are 0.67%, 1.97%, and 3.08% higher than the original deepCR model, respectively, indicating that it has better ability to distinguish true CR in dense star fields.

[0162] Furthermore, the deepCR labeling results and the labeling results of the model of the present invention are compared with the real labels in different bands, providing the following Figure 4 The intuitive performance proof effect diagram shown in the figure ( Figure 4 The first column is three original images from different filters, the second column is the true label of the cosmic ray, the third column is the difference between the deepCR model and the true label, the fourth column is the difference between the model of the present invention and the true label, and the fifth column is the proportion of the wrong pixels predicted by the model of the present invention and the deepCR model in the total pixels). Figure 4 It can be seen that compared to deepCR, the proposed model exhibits smaller non-zero residual pixels (Non-Zero Residual Pixels). In the F435W band, the non-zero residual ratio of the difference map predicted by the proposed model is only 0.28%, a 60% reduction compared to deepCR (0.70%). Notably, in the high-density galaxy core region of the F606W band, the non-zero residual ratio between the model and the true CR mask remains at 0.43%, a 36.8% reduction compared to deepCR, demonstrating that the proposed model can better distinguish CR structures in complex backgrounds.

[0163] It should be noted that Figure 3 , Table 3 and Figure 4 The loss functions used in the models involved are all the GRD-BCE loss functions proposed in this invention.

[0164] The specific embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in this field without departing from the scope of the present invention.

Claims

1. A dense star field cosmic ray recognition method integrating multi-scale linear attention, characterized by: The following steps are involved: S1. Obtain a dense star field image to be detected and a trained dense star field cosmic ray recognition model; the dense star field cosmic ray recognition model adopts an architecture based on an encoding stage, a neck stage, a multi-head self-attention mechanism, and a decoding stage, wherein the encoder stage includes two first convolution blocks connected in sequence, an LSK module, and a maximum pooling operation; the neck stage includes two first convolution block operations connected in sequence, an MLA module; the decoding stage includes a transposed convolution operation, two first convolution block operations, and a second convolution block connected in sequence; S2, inputting the dense star field image data to be detected into the encoding stage, processing it in sequence through two first convolution blocks, LSK module, and maximum pooling operation in the encoding stage to obtain the output of the maximum pooling operation in the encoding stage; The output of the maximum pooling operation in the encoding stage is used as the input of the neck stage. In the neck stage, it is processed by two first convolution blocks and the MLA module in sequence to obtain the output of the neck stage; The output of the neck stage is used as the input of the transposed convolution operation in the decoding stage and the input of the multi-head self-attention mechanism. The output of the transposed convolution operation, the output of the multi-head self-attention mechanism, and the output of the LSK module in the encoding stage are concatenated as the input of the first convolution block operation in the decoding stage. After processing by the second first convolution block and the second convolution block in the decoding stage, the classification mask result of the dense star field image to be detected is output.

2. The dense star field cosmic ray identification method integrating multi-scale linear attention according to claim 1 is characterized in that: The first convolution block includes a depth-separable convolution operation, ReLU, and EMA modules; the second convolution block adopts a two-dimensional convolution operation.

3. The dense star field cosmic ray identification method integrating multi-scale linear attention according to claim 1 is characterized in that: The step of obtaining the dense star field image to be detected and the trained dense star field cosmic ray recognition model is as follows: Obtain multi-band dense star field image data and construct training and test sets; The dense star field cosmic ray recognition model is trained and verified based on the training set to obtain a trained dense star field cosmic ray recognition model; The test set is used as the dense star field image to be detected and input into the trained dense star field cosmic ray recognition model to obtain the classification mask result.

4. The dense star field cosmic ray identification method integrating multi-scale linear attention according to claim 1 is characterized in that: The loss function of the dense star field cosmic ray identification model is a binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment, which is improved from the binary cross entropy loss function. The specific details are as follows: Given an input image I, we first use a Gaussian convolution kernel Perform background estimation, the expression is: Among them, B g Represents the Gaussian convolution kernel The background estimation image obtained by performing convolution operation on the input image I; Then calculate the absolute residual map R = |IB g |, and then normalize the absolute residual map: Among them, R n represents the normalized absolute residual map, ∈ is a very small constant used to prevent zero division errors; max(R) represents the maximum value in the absolute residual map R; For each batch normalized absolute residual map Calculate its MAD value: in, Represents the normalized absolute residual map R of the i-th batch n ; Convert the MAD value to a standard deviation estimate σ r ; Based on σ r Define a dynamic threshold interval [floor, ceil], where: Perform double threshold truncation on the normalized absolute residual map: In the formula, clip() represents the clip function; Represents the absolute residual graph after normalization of the i-th batch The result obtained by using the clip function and performing a double threshold truncation operation based on the lower threshold floor and the upper threshold ceil; right Perform zero mean and Gaussian filtering: in, Express Perform zero mean operation, Represents the Gaussian convolution kernel right Perform convolution operation; mean() represents the mean function; The weight matrix is obtained by normalization and dynamic range constraint: in, represents the weight matrix obtained after normalization and dynamic range constraint; α represents the balance coefficient; Finally, the binary cross entropy loss function based on Gaussian residual response and dynamic weight adjustment is Defined as: Among them, y j is the true label of the jth valid pixel, p j is the predicted probability of the jth valid pixel, and N is the number of valid pixels.

5. A dense star field cosmic ray recognition system integrating multi-scale linear attention, characterized by: A module comprising the dense star field cosmic ray identification method integrating multi-scale linear attention as described in any one of claims 1-4.

6. A processor, characterized in that: The processor is used to perform operations, including executing the dense star field cosmic ray identification method integrating multi-scale linear attention as described in any one of claims 1-4.