3.2. ECM
Infrared small-target detection requires sufficient local contextual information to distinguish weak target responses from surrounding structured clutter. Enlarging the local observation range is therefore beneficial, while directly increasing the spatial kernel size of standard convolution may introduce additional parameters and computational overhead. In ECM, we employ a 7 × 7 depthwise convolution followed by pointwise channel projection to provide broader local contextual modeling at relatively low computational cost. The emphasis of ECM is not on the kernel size itself, but on efficiently incorporating broader local context into a residual feature-transformation block for weak-target preservation. Its structure is shown in
Figure 2.
As shown in
Figure 1, the encoder of PTPN consists of four consecutive stages. Each stage first reduces the spatial resolution through a stride-2 residual downsampling block (Stride-2 Res Block), followed by two cascaded ECM blocks for feature extraction. The four stages produce encoded features
, with spatial resolutions of
,
,
, and
, respectively. These features are subsequently fed into the MTCA module. The following describes the forward propagation of a single ECM block. For simplicity, the batch dimension is omitted, and the input feature of the module is denoted by
, where
,
, and
represent the feature height, width, and channel number of the current encoding stage, respectively, and
corresponds to the feature channel number
of the
-th encoding stage defined above. When the generic notation
,
, and
are used to describe an operation within the
-th encoder stage, it corresponds to the stage-specific dimensions
,
, and
, respectively; i.e.,
,
, and
.
First, ECM applies layer normalization to the input feature
and extracts contextual information over an enlarged local spatial neighborhood through a
depthwise separable convolution. The convolution output is fused with the original input via a residual connection to obtain enhanced contextual features
:
where
denotes layer normalization, and
denotes a depthwise separable convolution composed of a
depthwise convolution followed by a
pointwise convolution. The residual connection keeps the input response available for subsequent feature transformation.
Subsequently, the contextual feature is fed into two parallel feature transformation branches. The main branch expands the channel dimension from
to
through linear projection to increase the representational capacity for subsequent nonlinear transformation. The auxiliary branch first performs channel-wise transformation using a
depthwise separable convolution and then maps features from
to
via up-projection, providing a lightweight complementary transformation path for the main branch:
where
denotes linear channel projection implemented by a
convolution, and
denotes a lightweight channel transformation composed of a
depthwise separable convolution. Both branches maintain identical spatial resolution and output dimensionality, enabling subsequent element-wise fusion.
After obtaining the two-branch features, ECM applies GELU non-linear activation to the main branch output and adds it to the auxiliary branch output. The fused representation is then projected back to the original channel dimension (C) through a linear mapping:
where
denotes the Gaussian Error Linear Unit activation function. The channel expansion and nonlinear transformation enhance feature expressiveness, while the auxiliary branch provides an additional lightweight transformation path that reduces information loss caused by a single transformation stream. Finally, channel compression restores dimensional consistency with the input, ensuring stable feature propagation within the module.
Finally, ECM applies a GELU activation followed by a
depthwise separable channel transformation to the compressed feature
. The transformed feature is then fused with the contextual feature
through a second residual connection to produce the module output
:
This residual connection reintegrates the transformed features obtained through channel expansion, fusion, and compression into the contextual representation, helping preserve the target–background relationships extracted in the preceding stage while facilitating gradient propagation. Since has the same spatial resolution and channel dimension as , multiple ECM blocks can be stacked sequentially within the same encoding stage without requiring additional feature alignment operations.
From the perspective of computational efficiency, for a standard convolution with both input and output channel numbers equal to , the number of parameters is (excluding the bias term), and the computational complexity is proportional to . In contrast, the depthwise separable convolution in Equation (4) consists of a depthwise convolution with parameters and a pointwise convolution with parameters, resulting in a total of parameters and a computational complexity proportional to . Compared with a standard convolution using the same spatial kernel size, this depthwise-separable implementation substantially reduces the parameter count and computational overhead, making broader-context convolutional operators more practical for repeated deployment across multiple encoder stages. It should be noted that the above comparison considers only the convolutional operator in ECM and excludes the additional overhead introduced by channel expansion, linear projection, and the auxiliary branch.
Overall, ECM follows a context extraction-complementary transformation-residual refinement pipeline. The block is not intended to simply replace a standard convolution with a cheaper operator; rather, it enlarges the local observation range while preserving the response path of small targets. Therefore, the encoded multi-scale features contain both contextual separability and fine spatial evidence, which are required by the subsequent MTCA module.
3.3. MTCA
Conventional FPN-like structures usually exchange information between adjacent scales through addition or concatenation. Such fixed fusion may not be sufficient for small infrared targets, because shallow layers contain location-sensitive but noisy responses, whereas deep layers contain stronger semantics but weaker spatial detail. To enable more selective cross-scale communication, we introduce the Multi-scale Target Cross-Attention (MTCA) module, as illustrated in
Figure 3.
MTCA receives four-level features generated by the ECM encoder, denoted as , where , and , , and denote the height, width, and channel dimension of the -th stage feature, respectively. The spatial dimensions satisfy and for . Since features at different scales differ in both spatial resolution and channel dimension, directly flattening them into token sequences would produce much longer sequences for high-resolution features, which not only substantially increases the computational cost of cross-scale attention but also leads to imbalanced computation among different scales. To overcome this issue, MTCA first constructs multi-scale token representations with unified quantity and embedding dimension through scale-adaptive patch embedding. Cross-scale information retrieval and feature reconstruction are then performed at a unified token granularity. Specifically, the module consists of three stages: scale-aligned token embedding, asymmetric cross-scale attention, and feed-forward refinement with feature restoration.
For the
-th scale, MTCA partitions the feature map
into non-overlapping patches with side length
, and projects each patch into a
-dimensional token space through a scale-specific embedding function
. The patch sizes for the four scales are set to
, respectively. After scale-adaptive patch embedding, the stage-specific spatial dimensions
are mapped to the unified dimensions
, where
and
. Meanwhile, the stage-specific channel dimension
is projected to the common embedding dimension
; therefore, each scale produces
tokens with the same embedding dimension. The corresponding token
representation is given by:
where
denotes the scale-specific patch embedding operation. We assume that the height and width of the input image are divisible by 32, which can be readily satisfied in practice through zero padding when necessary. Since the feature resolution and patch size decrease proportionally across the four scales,
,
, and
are identical for all four feature levels, while their original stage-specific channel dimensions
are projected to the common embedding dimension
. From a geometric perspective, the tokens at different scales each correspond to approximately a
region in the input image, enabling direct comparison of multi-scale features at a consistent spatial granularity. It should be noted that this region only represents the geometric coverage of each patch in the input coordinate space rather than the actual receptive field of the network features. Fine-grained localization information is still preserved by the residual connections in the encoder and the subsequent STFPN.
After obtaining the scale-aligned token representations, MTCA applies layer normalization to each scale and concatenates tokens along the token dimension to form a global multi-scale context sequence. Unlike standard self-attention that treats all tokens as a single sequence, MTCA preserves scale-specific queries while constructing shared keys and values from the concatenated multi-scale sequence. Let the multi-head attention contain
heads, with each head dimension
. Then, for the
-th scale and the
-th attention head, the queries, keys, and values are formulated as:
where
,
, and
.
denotes the scale-specific query projection matrix, while
are shared key and value projection matrices across different scales. The scale-specific query design allows each level to formulate distinct information retrieval requirements according to its feature distribution, while the shared key–value sequence provides candidate contextual information from all scales.
For the
-th attention head, cross-scale relevance is first computed between the current-scale queries and the global key sequence, followed by weighted aggregation over the value sequence. The outputs of all attention heads are concatenated and linearly projected to obtain the cross-scale attention representation of the
-th scale:
where
,
, and
is the output projection matrix. In this work, the number of attention heads is set to
. No explicit absolute or relative positional encoding is employed in MTCA. Instead, spatial correspondence across different scales is established during the preceding scale-adaptive patch embedding. Since the feature resolutions and patch sizes decrease proportionally across the four scales, all feature levels are mapped to token grids with identical spatial dimensions and the same number of tokens
. Therefore, cross-scale attention is performed at a unified spatial granularity, with the attention weights determined by feature-content similarity.
Through this asymmetric query–global key design, each scale updates its own token representation while selectively retrieving complementary information from all scales. Shallow queries can access deeper contextual semantics to reduce background clutter, while deep queries can leverage fine-grained spatial cues from shallow features, thereby improving cross-scale consistency and preserving weak target responses in complex scenes.
The cross-scale attention output is first fused with the original token representation of the corresponding scale through a residual connection, followed by layer normalization to stabilize feature distributions. A scale-specific feed-forward network is then employed to further perform nonlinear feature transformation:
The
adopts a bottleneck architecture consisting of channel expansion, local token transformation, and channel compression:
where
and
denote channel expansion and channel compression, respectively,
is the channel expansion ratio, and
denotes the GELU activation function.
reshapes the token sequence into a two-dimensional feature map, performs depthwise convolution, and then flattens it back into a token sequence, thereby introducing local spatial inductive bias to complement the cross-scale interaction performed by the attention module. Independent feed-forward network parameters are adopted for different scales to better accommodate their distinct feature distributions.
Finally, MTCA restores the cross-scale enhanced tokens to two-dimensional feature maps of the corresponding resolutions through the scale-specific inverse patch embedding function
. Specifically, each token is first projected into a patch representation with dimension
, followed by a Fold operation for spatial reconstruction. The reconstructed feature is then fused with the original encoder feature through a residual connection:
The reconstruction branch injects cross-scale contextual information into the original encoded features, while the residual connection with preserves the intrinsic spatial responses of the current scale. Consequently, MTCA transforms the encoded feature set into the cross-scale enhanced feature set , while maintaining the original spatial resolutions and channel configurations of the four-level feature pyramid, enabling seamless input to the subsequent STFPN.
For each scale, the query sequence contains N tokens, whereas the global key–value sequence contains 4N tokens. Therefore, the dominant computational complexity of single-scale attention is , and the total complexity over the four scales is . This asymptotic complexity is equivalent to that of applying a single global self-attention operation over 4N tokens. Hence, the primary objective of the asymmetric query–key architecture is not to reduce the theoretical quadratic complexity under the same token budget but to preserve independent information retrieval and feature update pathways for each scale. In practice, the computational cost of MTCA is mainly controlled by the scale-adaptive patch embedding, which compresses the token sequence length of high-resolution features. Additional computation arises from the query, key, value, output projection, and feed-forward network operations.
Overall, MTCA enables scale-specific retrieval of complementary information from the shared multi-scale context while preserving the hierarchical feature structure, providing cross-scale enhanced representations for the subsequent STFPN.
3.4. STFPN
Although MTCA enhances cross-scale interaction, weak targets may still be suppressed during hierarchical propagation. To further strengthen target responses, a Small-Target Feature Pyramid Network (STFPN) is designed.
Given the cross-scale enhanced feature set produced by MTCA
, where
, STFPN first projects features at different scales into a unified channel dimension
through a channel adjustment module and then introduces a Target Enhancement Module (TEM) to strengthen weak target responses at each scale, yielding the initial target-enhanced pyramid features:
where
denotes the channel adjustment operation consisting of a
convolution, batch normalization, and ReLU activation.
represents the initial target-enhanced pyramid feature before entering the bidirectional fusion pathways. Through this step, features from different scales are first projected into a common channel space, while preliminary enhancement of weak target responses is performed before cross-scale propagation.
TEM serves as the fundamental enhancement unit in STFPN, and its architecture is illustrated in
Figure 4. Given an input feature map
, TEM extracts statistical descriptors along the height, width, and channel dimensions to generate direction-aware attention weights. Specifically, TEM performs average pooling along the width dimension while preserving the height dimension to obtain the height descriptor
; average pooling along the height dimension while preserving the width dimension to obtain the width descriptor
; and global average pooling over both spatial dimensions to obtain the channel descriptor
:
where
denotes average pooling along the width dimension,
denotes average pooling along the height dimension, and
denotes global average pooling over both spatial dimensions.
Since
,
, and
have different spatial shapes, TEM first transforms the width descriptor into the same coordinate sequence format as the height descriptor before concatenation, while treating the channel descriptor as a global coordinate token with sequence length one. The three descriptors are then concatenated along the coordinate dimension and passed through a shared feature transformation, after which they are split back into three direction-specific intermediate representations:
where
transforms
into
, the concatenated feature
,
denotes concatenation along the coordinate dimension;
splits the sequence according to lengths
,
, and 1, respectively; and
denotes the nonlinear activation function. After splitting,
,
, and
.
Subsequently, the three intermediate representations are independently projected and activated by the Sigmoid function to generate attention weights along the height, width, and channel directions:
where
,
, and
denote direction-specific linear mappings.
restores the width-direction attention to the shape
. Consequently,
,
, and
. These three attention maps are multiplied with the input feature through broadcasting to obtain the output of TEM:
where
denotes element-wise multiplication. Compared with attention mechanisms that model only channel statistics, TEM simultaneously preserves statistical information along both the height and width directions, enabling it to enhance weak target responses while effectively suppressing background responses aggregated along specific spatial directions.
After obtaining the initial target-enhanced pyramid features
, STFPN constructs a bidirectional fusion architecture to facilitate interaction between deep contextual semantics and shallow spatial details. First, a top-down pathway is built from the deepest level, progressively upsampling low-resolution semantic features to higher-resolution layers and fusing them with the target-enhanced features at the corresponding scales:
where
denotes the upsampling operation that adjusts the feature map at the
-th level to the spatial resolution of the
-th level.
represents the fused feature generated by the top-down pathway. This pathway propagates large-scale contextual information from deeper layers to shallower layers, thereby improving the separability between small targets and complex backgrounds.
Subsequently, STFPN constructs a bottom-up detail feedback pathway to progressively propagate high-resolution spatial details into deeper semantic features, compensating for the small-target localization cues that may be lost during top-down propagation:
where
denotes the downsampling operation for matching the spatial resolutions between adjacent feature levels.
denotes the bidirectionally fused feature generated by the bottom-up pathway. Through this pathway, the rich spatial localization cues preserved in shallow layers are progressively fed back into deeper semantic representations, enabling weak target responses to maintain stronger localization consistency across different scales.
To further obtain high-resolution features suitable for pixel-wise prediction, STFPN constructs a segmentation refinement branch based on
. Since the bottom-up pathway has already aggregated fine-grained spatial details into deeper features, the segmentation refinement branch starts from the deepest bidirectionally fused feature and performs another top-down propagation, allowing deep semantic information to be realigned with high-resolution responses before prediction:
where
denotes the output feature of the segmentation refinement branch at the
-th scale. This branch further propagates deep contextual information to the highest-resolution feature maps while further enhancing local details and target localization responses prior to the final pixel-wise prediction.
Finally, STFPN feeds the highest-resolution bidirectionally fused feature
and the segmentation refinement feature
into two lightweight prediction heads to generate the foreground/background binary classification logits for the two branches:
where
and
are lightweight prediction heads consisting of a
convolution followed by an upsampling operation. Both branches perform pixel-wise foreground/background binary classification rather than additional target category prediction. The bidirectional fusion branch
primarily exploits the multi-scale contextual information aggregated by the bidirectional fusion pathway, whereas the segmentation refinement branch
further enhances high-resolution spatial details through the refinement pathway. During training, both prediction branches are jointly supervised. During inference, the foreground probabilities from the two branches are fused according to Equation (2) to obtain the final detection probability map.
In summary, STFPN converts the MTCA-enhanced feature set into target-preserving prediction features through channel alignment, TEM-based response enhancement, top-down semantic propagation, bottom-up detail feedback, and segmentation refinement. Compared with a standard pyramid decoder, STFPN emphasizes weak-target responses before and during feature propagation, which helps reduce missed detections caused by repeated downsampling and multi-level fusion.
From an interaction perspective, ECM, MTCA, and STFPN operate sequentially and complementarily. ECM provides context-enriched multi-level representations, MTCA selectively retrieves complementary information from the shared multi-scale context, and STFPN further aggregates and propagates the interacted features through bidirectional pyramid fusion and refinement. Together, they form a progressive context modeling–cross-scale interaction–target-preserving aggregation pathway that preserves weak target responses while integrating semantic and localization information across scales.
3.5. PCL
Conventional data-driven loss functions mainly constrain the consistency between prediction results and pixel-wise annotations but do not explicitly exploit the physical characteristics of small infrared target imaging. Under conditions of low signal-to-noise ratio, complex background clutter, or local high-intensity interference, the network may produce false responses that are inconsistent with infrared imaging characteristics. To address this issue, this paper proposes a Physics-Constrained Loss (PCL), which regularizes the prediction from three complementary perspectives: point spread function consistency, relative intensity consistency within target regions, and signal-to-noise-ratio-aware constraints. PCL serves as a physics-inspired regularization term in addition to the conventional data-driven supervision. It should be noted that PCL is involved only during training and does not modify the network architecture or computational pipeline during inference.
According to the dual-branch prediction mechanism described in
Section 3.1, PTPN outputs foreground probability maps from the bidirectional-fusion branch and the segmentation-refinement branch, denoted by
, where
. This notation is a simplified form of
and
introduced in
Section 3.1. Given the binary ground-truth mask
and the normalized infrared intensity image
, both branches are supervised by the data-driven loss and the physics-constrained loss. The overall training objective is defined as:
where
denotes the data-driven loss for the
-th prediction branch,
denotes the corresponding physics-constrained loss, and
is the weighting coefficient of PCL. For simplicity, the following derivations use the foreground probability map
from a single prediction branch as an example, while the actual training loss is obtained by summing the losses of both branches.
The data-driven supervision consists of the Focal Loss and the Soft
Loss, jointly constraining pixel-wise foreground/background classification accuracy and target localization quality:
where
and
denote the weighting coefficients of the two loss terms, respectively. Since small infrared targets occupy only a tiny fraction of the image, resulting in severe foreground–background class imbalance, Focal Loss is adopted to alleviate the dominance of easy background pixels during optimization:
where
denotes the set of image pixels,
denotes the pixel index,
is the foreground/background balancing coefficient,
is the focusing parameter, and
is a small constant introduced to avoid numerical instability in logarithmic and division operations. The Soft
Loss is defined as:
which directly optimizes the overlap between the predicted region and the ground-truth target region, thereby improving the pixel-level localization quality of infrared small target detection.
The proposed PCL consists of three complementary components: a point spread function consistency loss, a target-region relative intensity consistency loss, and a signal-to-noise-ratio-aware loss:
where
,
, and
denote the weighting coefficients of the three components, respectively.
First, after passing through an optical imaging system, an infrared small target is generally not represented as an ideal isolated point but is spatially spread by the point spread function (PSF). To encourage the predicted probability map to exhibit a local response pattern consistent with the imaging process, we approximate the PSF using a normalized Gaussian kernel
and convolve the ground-truth mask to obtain a soft target response:
where
denotes the convolution operator,
normalizes the convolution result into the range
, and
controls the spatial spread of the soft target response. In practice,
is treated as a hyperparameter related to the typical target size and imaging blur, whose value is specified in
Section 4 and analyzed in the ablation study. This loss encourages the prediction to form a smooth local spreading response within the target region while suppressing undesired scattered responses far from the target.
Second, infrared small targets are typically characterized by local radiative intensity anomalies. Strictly speaking, if reliable radiometric calibration, sensor response parameters, target temperature, and imaging wavelength are available, an absolute radiometric consistency constraint can be derived from the physical imaging model. However, commonly used infrared small target detection datasets provide only image intensities and pixel-level annotations, without such absolute physical quantities. Therefore, instead of relying on unavailable radiometric information, we adopt normalized grayscale intensity as a computable surrogate of the relative infrared response. The resulting constraint captures the physical prior that infrared small targets should exhibit local intensity anomalies, requiring the predicted foreground region to maintain a relative intensity distribution consistent with the ground-truth target region. Specifically, the weighted average intensity of the predicted foreground and the average intensity of the ground truth target are defined as:
and the target-region relative intensity consistency loss is formulated as:
This term encourages the average infrared response within the predicted foreground region to be consistent with that of the ground-truth target region, thereby suppressing background or texture responses whose intensity distributions deviate from those of true targets. If future datasets provide reliable radiometric calibration and sensor parameters, Equation (30) can be naturally extended to a more refined absolute radiometric consistency constraint.
Finally, the reliability of infrared small target detection is closely related to the target-to-background signal-to-noise ratio (SNR). To address scenarios with common local background interference, we introduce a differentiable SNR-aware constraint that encourages the predicted foreground to correspond to regions with higher target–background separability. Since Equation (29) has already defined the weighted average intensity of the predicted foreground region as
, we directly let:
where
and
denote the weighted average intensities of the predicted target region and the predicted background region, respectively. The standard deviation of the background intensity is defined as:
which leads to the soft signal-to-noise ratio associated with the prediction:
This image-domain SNR measures target–background separability by normalizing the difference between the predicted target and local-background intensities by the standard deviation of the background response. Such target-to-background separability is particularly relevant to infrared small-target detection under low-SNR and complex-background conditions [
2]. A larger value indicates that the predicted target is more distinguishable from local background fluctuations.
The SNR-aware loss adopts a hinge formulation:
where
denotes the minimum desired target–background separability threshold. In practice,
is treated as a regularization hyperparameter, whose value is selected by grid search on the validation set as described in
Section 4.1. It should be noted that the SNR in Equation (33) is an image-domain approximation derived from normalized grayscale statistics rather than a radiometrically calibrated sensor SNR. Therefore,
serves as a practical criterion for the proposed SNR-aware regularization rather than a universal physical SNR threshold for infrared sensors. This loss encourages the predicted foreground region to exhibit sufficient intensity contrast relative to local background fluctuations, thereby reducing the risk of confusing low-contrast background textures with infrared small targets.
In summary, the data-driven loss constrains foreground/background classification and regional overlap from the perspective of annotation supervision, whereas PCL regularizes the prediction from three complementary physical perspectives: point spread characteristics, relative intensity consistency of target regions, and target–background signal-to-noise ratio. The combination of these two types of supervision enables the network to learn statistical patterns from the training data while suppressing prediction responses that are inconsistent with infrared imaging characteristics. The weighting coefficients
,
,
,
,
, and
, together with the hyperparameters
and
, are specified in the experimental settings presented in
Section 4.