3.2. LPCF
In cross-modality Re-ID, the multi-layer global self-attention in ViT tends to weaken shallow-layer local discriminative semantics, causing deep features to become less sensitive to clothing textures, fine-grained regions, and occlusion details. Recent studies have attempted to enhance locality preservation and local sensitivity; for example, Ni et al. [
20] exploited part-aware attention to mine local similarity and improve generalization, Zhang et al. [
21] introduced a global–local dual-branch structure to handle occlusions, and Zhou et al. [
22] performed local pairwise graph modeling under cross-modality conditions. However, these methods either rely heavily on predefined regions or fixed-granularity partitions or enhance locality only within a single branch, making it difficult to preserve and fuse local details in a stable and progressive manner across different views and modalities. To address this, we propose LPCF, illustrated in
Figure 3. LPCG first adaptively preserves local and positional cues at the token level; CCIA then performs controllable interpolation between self-attention and cross-branch contextual attention, enabling effective retention of local information while ensuring stability and consistency during cross-branch feature fusion.
Specifically, given infrared and visible images
, we obtain feature maps through patch embedding and flatten them into token sequences
. Prior to feeding the concatenated sequence
(stacked from visible and infrared tokens) into the transformer backbone, we introduce the LPCG module to perform joint recalibration across local, positional, and channel dimensions. This strengthens and preserves local discriminative semantics at an early stage, providing a more stable feature foundation for deeper modeling and subsequent cross-branch fusion. We first apply mean pooling along the token dimension and feed the result into a two-layer MLP to generate the channel weights
:
where
denotes averaging along the token dimension,
is the sigmoid activation function,
represents the ReLU activation, and
,
together with
are learnable linear projection matrices and their associated bias terms. To further model local positional dependencies among tokens, we first aggregate the input feature map along the channel dimension to obtain a single-channel descriptor and subsequently apply a 1D convolution along the token sequence to capture local neighborhood context. The resulting output is passed through a sigmoid activation to generate the token attention weights
, where the 1D convolution extracts local dependencies across token positions and the sigmoid function ensures normalized attention responses:
where
exchanges the two groups of sub-channels along the channel dimension, Conv1 is a 1D convolution with a kernel size of 1 for channel compression, and Conv2 is a 1D convolution with a kernel size of 3 for capturing local dependencies along the token sequence. The two attention weights are then fused via an outer product to form the joint weighting matrix
, which enables fine-grained local modulation across both positional and channel dimensions. Finally, the recalibrated feature
x is obtained through residual-style modulation:
where ⊗ denotes the outer product, ⊙ implemented as element-wise multiplication,
is the hyperbolic tangent activation, and
randomly deactivates a portion of features during training with a fixed probability. The coefficient
is a learnable scalar parameter. After the LPCF module performs joint token–channel recalibration and local positional enhancement, the resulting feature sequence becomes more locally discriminative and cross-modality stable. We then feed the enhanced sequence
into the transformer backbone for cross-layer semantic integration and global modeling. However, as the transformer becomes deeper, shallow-layer semantics tend to be gradually forgotten. To address this issue, we design the CCIA module to enable each block’s self-attention to leverage both the current features and the preserved shallow semantic cues, allowing the attention computation to no longer rely solely on the representation of a single layer. Inspired by the Regional Division (RD) strategy in LAReViT [
14], we partition the patch tokens into three non-overlapping regions corresponding to head, trunk, and leg along the vertical spatial dimension. Notably, LAReViT systematically evaluated different numbers of partitions and demonstrated that a three-part division achieves the best performance, striking a favorable balance between local discrimination and global semantic consistency.
After obtaining the global sequence
, we divide it into three local regions according to the human body structure: the head
, trunk
, and legs
, denoted as
. We then construct a global branch
and three local branches
,
,
, where
the shared class token in the transformer used for aggregating global semantics. The global branch adopts the full positional encoding
, while the local branches extract their corresponding sub-positional encodings
from
according to the patch indices associated with
,
, and
, respectively.
After constructing the four input branches, we feed the global branch
and the three local branches
sequentially into the CCIA blocks, which incorporate cross-layer semantic injection, as illustrated in
Figure 4.
Specifically, for any branch, let the current-layer input be denoted as
and the previous-layer feature as
. Note that in the 0-th block, all branches operate purely with self-attention; thus, we set
. Starting from the block 1 onward, the global branch continues to use
while each of the three local branches sets
to the output of its corresponding branch from the previous layer, thereby injecting cross-layer semantic context. Prior to computing attention, both the current sequence
and its reference feature
are individually normalized using layer normalization.
We then compute the self-attention and cross-branch attention separately:
where the attention operator
denotes the standard multi-head scaled dot-product attention. For any input
X and its reference feature
, we have
When
, the operation corresponds to self-attention, whereas setting
yields cross-branch attention. We then introduce a learnable scalar gate
to control the proportion of cross-branch contextual injection:
To prevent cross-branch injection from disrupting local semantic consistency, we incorporate LayerScale into the residual path:
where
X denotes the output feature after the CCIA module and
are learnable scaling parameters that ensure a smooth transition from local self-attention to cross-branch fusion without requiring additional stabilization strategies. After completing attention mixing and inter-layer residual updating, the global branch and the three local branches are normalized using LayerNorm and BatchNorm1d, respectively, yielding the final cross-layer semantic–enhanced features denoted as
, collectively referred to as the cross-layer semantic–enhanced representations.
Then, to ensure that the extracted person features are identity-discriminative, we apply the cross-entropy loss (
) [
23] and the triplet loss (
) [
24] to supervise the enhanced representations:
In summary, LPCF is designed to enhance the model’s ability to capture local details while performing cross-branch information fusion. It achieves this by using the LPCG module, which focuses on enhancing the model’s sensitivity to local structural and positional information, ensuring that fine-grained details are maintained. The CCIA module then facilitates the controlled interpolation of cross-branch contextual information, allowing for stable interaction between the branches. LPCF improves the model’s understanding of local structures and helps mitigate the loss of shallow features during deep-layer processing. This design ensures both global and local features are integrated effectively, enhancing cross-modality alignment.
3.3. GE-CGA
In cross-modality Re-ID, the substantial differences between visible and infrared imaging mechanisms often lead to class-center shifts and inconsistent geometric structures for the same identity across the two modalities. In feature space, RGB and IR representations may differ not only in absolute position but also in their inter-class distances and decision boundaries, which become distorted across modalities. Recent approaches attempt to achieve cross-modality alignment by constructing shared or intermediate modalities. For example, Yu et al. [
4] introduced a unified modality hub to mitigate distribution discrepancies, while Cheng et al. [
25] employed a cross-modality contrastive memory bank to pull positive pairs closer and push negative pairs apart for improved modality consistency. However, these methods generally focus on bringing the two modalities closer at a global distribution level, aligning center positions or overall shapes without ensuring that the relative distances among different identity classes are preserved. To address this limitation, we propose the GE-CGA module, which explicitly constructs a class-center graph and aligns the pairwise geometric structure of class centers across modalities, thereby preserving inter-class topological relationships. This ensures that the resulting feature space still maintains clear identity boundaries and strong discriminative capability when achieving cross-modality alignment.
We first compute the class centers for the visible and infrared modalities within each batch. Let the global features
be split into visible features
and infrared features
, where
and their corresponding identity labels are denoted by
y. The class centers for the two modalities are then defined as
where
and
denote the sets of visible and infrared samples belonging to identity y, respectively. To ensure numerical stability, we apply
-normalization to all centers, and the centers of the same identity from the two modalities are encouraged to be close to each other:
Subsequently, to further construct a class-center contrastive learning objective, the visible and infrared centers of the same identity are treated as mutual positive pairs in the similarity space, while the centers of different identities are regarded as negative samples. This encourages stronger cross-modality identity discrimination:
where
is the temperature coefficient. In addition, to preserve the relative topological structure among classes across modalities, we align the similarity matrices of the two modality-specific class centers:
where
and
denote the similarity matrices constructed from all class centers in the RGB and IR modalities, respectively. Because the diagonal elements represent self-similarity and are always equal to 1, they do not convey geometric structure information among different classes. Therefore, we constrain only the non-diagonal entries, denoted as
and
. The matrices
and
are formed by stacking all l2-normalized class centers from the two modalities. Finally, the overall GE-CGA loss is defined as
Overall, GE-CGA focuses on the alignment of identity centers across modalities. Rather than directly aligning features, it aligns the pairwise similarity structures between class centers by constraining their geometric relationships on the identity-level relation graph. This approach stabilizes the cross-modality alignment by addressing geometric discrepancies between visible and infrared modalities. GE-CGA allows for the construction of a consistent high-level identity structure across modalities, enhancing the robustness of the model without introducing complex architectures or additional memory requirements. This offers a more efficient and effective way of managing cross-modality differences compared to traditional alignment methods.
3.4. Intra-Modal Prototype Discrepancy Mining Loss (IPDM-Loss)
Although cross-modality alignment can mitigate the distribution discrepancy between visible and infrared features, intra-modality variations caused by illumination changes, pose differences, and occlusions may still lead to intra-class dispersion and blurred inter-class boundaries within a single modality. To address this issue, we propose the IPDM-Loss, which constructs identity prototypes separately for each modality and explicitly enforces samples of the same identity to move closer to their corresponding modality-specific prototype while introducing inter-class separation among prototypes. This yields more compact intra-class structures and clearer inter-class distinctions. Unlike approaches that rely solely on global contrastive learning or center-based constraints, the IPDM-Loss operates independently within each modality, avoiding the risk of cross-modality alignment adversely affecting the internal structure of a single modality. As a result, it promotes tightly clustered intra-class distributions and preserves well-separated identity boundaries within each modality.
To avoid forming positive pairs between a sample and itself during contrastive learning, we construct a self-excluded prototype representation based on the modality-specific identity centers
:
To enhance the compactness of identity representations within each modality, we unify the prototype-level contrastive constraint and the variance reduction constraint into an intra-modality compactness term. We first construct the prototype-level loss as follows:
This term constrains each sample based on relative similarity, encouraging it to be closer to the prototype of its own identity than to other prototypes. This helps to improve discriminative consistency within the modality. In addition, to further compress intra-class distributions and reduce local feature variance, we explicitly minimize the smooth L1 distance [
26] between each sample and its self-excluded class center:
This term provides an absolute geometric contraction constraint, encouraging samples of the same identity to form a more compact distribution within the modality. By increasing the matching score between a sample and its corresponding identity prototype in the prototype-level similarity space, the relative discriminative consistency within each class is enhanced. Meanwhile, further contracts intra-class distributions in the absolute feature space by directly minimizing the distance between each sample and its self-excluded class center. The combination of these two terms simultaneously improves both the discriminability and compactness of intra-modality representations.
In addition, to prevent excessive intra-class compression from blurring inter-class boundaries, we impose a margin-based separation constraint between the centers of different identities:
where K denotes the number of identities within the batch,
controls the minimum separable margin to preserve clear decision boundaries between identities, and
and
represent the mean features of the
k-th and
j-th identities within the modality, respectively. Finally, the overall formulation of IPDM-Loss is provided by