# TIG-DETR: Enhancing Texture Preservation and Information Interaction for Target Detection
## 3 Materials and Methods
### Instance Based Advanced Guidance Module  
The Transformer used in our TIG-DETR detector follows the structure of Shifted Window-based Self-Attention in SWIN-T. It replaces the multi-headed self-attentive module in DETR with W-MSA and SW-MSA in an alternating manner. The main goal was to reduce the computational complexity of the Transformer part in DETR, enhance the detection performance of small object instances, and speed up the model convergence. However, the limitation of interaction between windows in Shifted Window-based Self-Attention  
Figure 4: Schematic representation of Feature-wise Attention. affects the detection performance of large object instances. To address this, we introduced a new module called Instance-Based Advanced Guidance Module (IAM) before the encoder. This module allows the model to perceive the instances in the image before performing local self-attention, compensating for the degraded detection performance of large object instances caused by the window interaction limitation. Specifically, as shown in Figure 5, the images from different stages in the backbone underwent a scale-invariant downsampling process to achieve a consistent channel dimension. They were then resized to the final output size. Afterwards, they were fused with the output image at multiple scales, enabling the fused feature map to combine information from different scales and enhance the texture information of the image. After undergoing an LFA, the fused feature map, originally of size \(w\times h\times C\), was divided into \(M^{2}\) patches. In Figure 5, we used M = 2 as an example. These patches were fused together through concatenation, resulting in a patch of size \((h/M)\times(w/M)\times CM^{2}\). The different colors within the fused patches represent the channel information of the patches at different locations. Each pixel within the fused patch contains positional information from the patches at different locations, allowing the model to extract global features, contextual relationships, and better perceive objects of varying sizes. The fused patch was then passed through the multi-headed self-attentive module and the output patch was used to reconstruct the original feature map. We believe that this method is advantageous for improving Shifted Window-based Self-Attention, as it enables the feature map to capture instances before window attention. Despite a slight increase in computational complexity compared to Shifted Window-based Self-Attention, we have successfully implemented this approach. The details are as follows:  
\[\Omega(MSA)=4 hwC^{2}+2(hw)^{2}C \tag{4}\] \[\Omega(W-MSA)=4 hwC^{2}+2N^{2}hwC\] (5) \[\Omega(IAM)=4 hwC^{2}M^{2}+2(h/M)^{2}(w/M)^{2}C. \tag{6}\]  
In the equation, \(N\) represents the edge length of the shifted window. It is observed that the computational complexity of the global MSA increases quadratically with _hw_. Figure 5: Schematic diagram of Instance-Based Advanced Guidance Module. When \(N\) remains constant, the computational complexity of W-MSA becomes linear. In our IAM, with \(M\) fixed, the computational complexity of \(2(h/M)^{2}(w/M)^{2}C\) in this part is much smaller than \(2(hw)^{2}C\). However, \(4 hwC^{2}M^{2}\) for \(4 hwC^{2}\) is only a linear increase, much smaller than the difference between the computation of \(2(h/M)^{2}(w/M)^{2}C\) and \(2(hw)^{2}C\). Consequently, the computational complexity of IAM is still significantly lower compared to the global MSA. By performing the mentioned operations, we enhanced the textural information of the image and establish associations among individual pixel points within the image prior to applying movable window attention to the entire image. This allows the model to perceive instances in the image before the finer self-attention operation, thereby improving its ability to detect large object instances. A feedforward network (FFN) was employed after the IAM module. We presented the generalized Instance-Based Advanced Guidance Module, which can be applied to various backbone networks without the need for FPNs.