summaries: This paper presented a Dual-stream Network for image classification. It combines the representation of local and global pattern features by using self-attention and convolution together. It also proposed an Intrascale Propagation module to process two different resolutions in each block.  In addition, it also introduced such block to FPN to demonstrate the benefit. This paper proposes Dual-stream Network (DS-Net) for visual recognition. The two streams correspond to high-resolution convolutions for local features and low-resolution vision transformers for global patterns. The paper proposes an intra-scale propagation module to process the two streams and an inter-scale alignment module to fuse them into one. For object detection, it designs a Dual-stream FPN (DS-FPN) that adds dual-stream blocks to every feature pyramid. The proposed DS-Net achieves good results for image classification, object detection, and instance segmentation. This paper proposes a hybrid convolution+transformer model for 2d images. To summarize the model, it is broken up into 4 stages that operate at successively higher resolutions much like a typical Resnet.  At each stage, there are two parallel paths, one that apples a depthwise convolution at high resolution (capturing local effects), and one that applies a standard a multi-headed attention at coarse (capturing global effects) resolution.  These paths are fused by a final attention module which allows for local to attend to global and vice versa.  Another contribution is the DS-FPN (which simply slots one of the above “dual stream” modules into the lateral paths of a typical FPN). Experiments show strong performance on both image classification for ImageNet and detection/segmentation for COCO (relative to competing Transformer-only models like Deit).  The authors propose a new architecture for visual recognition. Like standard convolutional architectures, the representation is structured in a multi-scale hierarchy, with deeper layers being coarser and more abstract. At every level of the hierarchy, a coarse, global representation is appended and simultaneously processed with the more fine-grained, local one. Local features are processed with depth-wise convolutions, and global ones with multi-head self-attention. In addition to this separate processing of local and global features, they are co-processed by cross-attending between local and global features.   In addition to this recognition backbone, the authors adapt Feature Pyramid Networks in a similar spirit. Whereas FPN's use dense convolutions to fuse an intermediate representation with a coarser one, the authors instead use the proposed "Dual-Stream" block, combining local depth-wise convolutions, global self-attention, and local/global cross-attention.   The authors evaluate the recognition backbone for classification on ImageNet and detection and instance segmentation on COCO, reporting large gains over standard convolutional architectures such as ResNet, and reasonable gains over more recent transformer-based ones.
abstractText: Transformers with remarkable global representation capacities achieve competitive results for visual tasks, but fail to consider high-level local pattern information in input images. In this paper, we present a generic Dual-stream Network (DS-Net) to fully explore the representation capacity of local and global pattern features for image classification. Our DS-Net can simultaneously calculate fine-grained and integrated features and efficiently fuse them. Specifically, we propose an Intra-scale Propagation module to process two different resolutions in each block and an Inter-Scale Alignment module to perform information interaction across features at dual scales. Besides, we also design a Dual-stream FPN (DS-FPN) to further enhance contextual information for downstream dense predictions. Without bells and whistles, the proposed DS-Net outperforms DeiT-Small by 2.4% in terms of top-1 accuracy on ImageNet-1k and achieves state-of-the-art performance over other Vision Transformers and ResNets. For object detection and instance segmentation, DS-Net-Small respectively outperforms ResNet-50 by 6.4% and 5.5 % in terms of mAP on MSCOCO 2017, and surpasses the previous state-of-the-art scheme, which significantly demonstrates its potential to be a general backbone in vision tasks. The code will be released soon.
authors.name: Mingyuan Mao
authors.name: Peng Gao
authors.name: Renrui Zhang
authors.name: Honghui Zheng
authors.name: Teli Ma
authors.name: Yan Peng
authors.name: Errui Ding
authors.name: Baochang Zhang
authors.name: Shumin Han
references.authors: T.B. Brown B. Mann N. Ryder M. Subbiah J. Kaplan P. Dhariwal A. Neelakantan P. Shyam G. Sastry A. Askell
references.title: et al
references.venue: Language models are few-shot learners. arXiv preprint arXiv:2005.14165
references.authors: Z. Cai N. Vasconcelos
references.title: Cascade r-cnn: Delving into high quality object detection
references.venue: IEEE CVPR, pages 6154–6162
references.authors: N. Carion F. Massa G. Synnaeve N. Usunier A. Kirillov S. Zagoruyko
references.title: End-to-end object detection with transformers
references.venue: arXiv:2005.12872
references.authors: C.-F. Chen Q. Fan R. Panda
references.title: Crossvit: Cross-attention multi-scale vision transformer for image classification
references.venue: arXiv:2103.14899
references.authors: F. Chollet
references.title: Xception: Deep learning with depthwise separable convolutions
references.venue: arXiv:1610.02357
references.authors: X. Chu Z. Tian Y. Wang B. Zhang H. Ren
references.title: and X
references.venue: W. et al. Twins: Revisiting the design of spatial attention in vision transformers. arXiv:2103.00112
references.authors: X. Chu Z. Tian B. Zhang X. Wang X. Wei H. Xia
references.title: Conditional positional encodings for vision transformers
references.venue: IEEE CVPR
references.authors: J. Deng W. Dong R. Socher L.-J. Li K. Li L. Fei-Fei
references.title: Imagenet: A large-scale hierarchical image database
references.venue: IEEE CVPR, pages 248–255
references.authors: J. Devlin M.-W. Chang K. Lee K. Toutanova
references.title: Bert: Pre-training of deep bidirectional transformers for language understanding
references.venue: arXiv preprint arXiv:1810.04805
references.authors: A. Dosovitskiy L. Beyer A. Kolesnikov D. Weissenborn X. Zhai
references.title: and T
references.venue: U. et al. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR
references.authors: K. Duan S. Bai L. Xie H. Qi Q. Huang Q. Tian
references.title: Centernet: Object detection with keypoint triplets
references.venue: IEEE CVPR
references.authors: P. Gao S. Geng R. Zhang T. Ma R. Fang Y. Zhang H. Li Y. Qiao
references.title: Clip-adapter: Better vision-language models with feature adapters
references.venue: arXiv preprint arXiv:2110.04544
references.authors: P. Gao Z. Jiang H. You P. Lu S.C.H. Hoi X. Wang H. Li
references.title: Dynamic fusion with intra- and inter-modality attention flow for visual question answering
references.venue: IEEE CVPR, pages 6632–6641
references.authors: P. Gao J. Lu H. Li R. Mottaghi A. Kembhavi
references.title: Container: Context aggregation network
references.venue: arXiv preprint arXiv:2106.01401
references.authors: P. Gao M. Zheng X. Wang J. Dai H. Li
references.title: Fast convergence of detr with spatially modulated co-attention
references.venue: arXiv preprint arXiv:2101.07448
references.authors: K. Han A. Xiao E. Wu J. Guo C. Xu Y. Wang
references.title: Transformer in transformer
references.venue: arXiv:2103.00112
references.authors: K. He G. Gkioxari P. Dollár R.B. Girshick
references.title: Mask R-CNN
references.venue: IEEE ICCV, pages 2980–2988
references.authors: K. He X. Zhang S. Ren J. Sun
references.title: Deep residual learning for image recognition
references.venue: IEEE CVPR, pages 770–778
references.authors: A.G. Howard M. Zhu B. Chen D. Kalenichenko W. Wang T. Weyand M. Andreetto H. Adam
references.title: Mobilenets: Efficient convolutional neural networks for mobile vision applications
references.venue: arXiv:1704.04861
references.authors: J. Hu L. Shen G. Sun
references.title: Squeeze-and-excitation networks
references.venue: IEEE CVPR)
references.authors: H. Law J. Deng
references.title: Cornernet: Detecting objects as paired keypoints
references.venue: ECCV, pages 765–781
references.authors: Y. Lecun L. Bottou Y. Bengio P. Haffner
references.title: Gradient-based learning applied to document recognition
references.venue: Proceedings of the IEEE, 86(11):2278–2324
references.authors: T. Lin P. Dollár R.B. Girshick K. He B. Hariharan S.J. Belongie
references.title: Feature pyramid networks for object detection
references.venue: IEEE CVPR, pages 936–944
references.authors: T. Lin P. Goyal R.B. Girshick K. He P. Dollár
references.title: Focal loss for dense object detection
references.venue: IEEE ICCV, pages 2999–3007
references.authors: T.-Y. Lin M. Maire S.J. Belongie L.D. Bourdev R.B. Girshick J. Hays P. Perona D. Ramanan P. Dollár C.L. Zitnick
references.title: Microsoft coco: Common objects in context
references.venue: ECCV, pages 740–755
references.authors: W. Liu D. Anguelov D. Erhan C. Szegedy S.E. Reed C. Fu A.C. Berg
references.title: SSD: single shot multibox detector
references.venue: ECCV, pages 21–37
references.authors: Z. Liu Y. Lin Y. Cao H. Hu Y. Wei
references.title: and Z
references.venue: Z. et al. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv:2103.14030
references.authors: J. Long E. Shelhamer T. Darrell
references.title: Image segmentation fully convolutional networks for semantic segmentation
references.venue: IEEE CVPR
references.authors: J. Lu D. Batra D. Parikh S. Lee
references.title: Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks
references.venue: arXiv preprint arXiv:1908.02265
references.authors: M. Mao Y. Tian B. Zhang Q. Ye W. Liu G. Guo D. Doermann
references.title: iffDetector: Inferenceaware feature filtering for object detection
references.venue: arXiv preprint arXiv:2006.12708
references.authors: J. Pang K. Chen J. Shi H. Feng W. Ouyang D. Lin
references.title: Libra r-cnn: Towards balanced learning for object detection
references.venue: IEEE CVPR
references.authors: G. Peng H. You Z. Zhang X. Wang H. Li
references.title: Multi-modality latent interaction network for visual question answering
references.venue: IEEE ICCV, pages 5824–5834
references.authors: Z. Peng W. Huang S. Gu L. Xie Y. Wang J. Jiao Q. Ye
references.title: Conformer: Local features coupling global representations for visual recognition
references.venue: arXiv:2105.03889
references.authors: A. Radford K. Narasimhan T. Salimans I. Sutskever
references.title: Improving language understanding by generative pre-training
references.authors: I. Radosavovic R.P. Kosaraju R. Girshick K. He P. Dollár
references.title: Designing network design spaces
references.venue: IEEE CVPR
references.authors: J. Redmon S.K. Divvala R.B. Girshick A. Farhadi
references.title: You only look once: Unified
references.venue: real-time object detection. In IEEE CVPR, pages 779–788
references.authors: S. Ren K. He R.B. Girshick J. Sun
references.title: Faster R-CNN: towards real-time object detection with region proposal networks
references.venue: NeurIPS, pages 91–99
references.authors: K. Simonyan A. Zisserman
references.title: Very deep convolutional networks for large-scale image recognition
references.venue: arXiv:1409.1556
references.authors: C. Szegedy W. Liu Y. Jia P. Sermanet S. Reed D. Anguelov D. Erhan V. Vanhoucke A. Rabinovich
references.title: Going deeper with convolutions
references.venue: IEEE CVPR, pages 1–9
references.authors: H. Tan M. Bansal
references.title: Lxmert: Learning cross-modality encoder representations from transformers
references.venue: arXiv preprint arXiv:1908.07490
references.authors: M. Tan Q. Le
references.title: Efficientnet: Rethinking model scaling for convolutional neural networks
references.venue: ICML
references.authors: H. Touvron M. Cord M. Douze F. Massa A. Sablayrolles H. Jégou
references.title: Training data-efficient image transformers and distillation through attention
references.venue: arXiv:2012.12877
references.authors: A. Vaswani N. Shazeer N. Parmar J. Uszkoreit L. Jones
references.title: and A
references.venue: N. G. et al. Attention is all you need. In NeurIPS
references.authors: H. Wang Y. Zhu H. Adam A. Yuille L.-C. Chen
references.title: MaX-DeepLab: End-to-end panoptic segmentation with mask transformers
references.venue: IEEE CVPR
references.authors: W. Wang E. Xie X. Li D.-P. Fan K. Song
references.title: and D
references.venue: L. et al. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv:2102.12122
references.authors: H. Wu B. Xiao N. Codella M. Liu X. Dai
references.title: and L
references.venue: Y. et al. Cvt: Introducing convolutions to vision transformers. arXiv:2103.15808
references.authors: H. Yan Z. Li W. Li C. Wang M. Wu
references.title: and C
references.venue: Zhang. Contnet: Why not use convolution and transformer at the same time? arXiv:2104.13497
references.authors: L. Yuan Y. Chen T. Wang W. Yu Y. Shi
references.title: and Z
references.venue: J. et al. Tokens-to-token vit: Training vision transformers from scratch on imagenet. arXiv:2101.11986
references.authors: D. Zhang H. Zhang J. Tang M. Wang X. Hua Q. Sun
references.title: Feature pyramid transformer
references.venue: ECCV
references.authors: Q. Zhang Y. Yang
references.title: Rest: An efficient transformer for visual recognition
references.venue: arXiv preprint arXiv:2105.13677
references.authors: X. Zhang F. Wan C. Liu R. Ji Q. Ye
references.title: FreeAnchor: Learning to match anchors for visual object detection
references.venue: NeurIPS
references.authors: X. Zhang X. Zhou M. Lin J. Sun
references.title: Shufflenet: An extremely efficient convolutional neural network for mobile devices
references.venue: IEEE CVPR, pages 6848–6856
references.authors: Z. Zhao K. Samel B. Chen L. Song
references.title: Proto: Program-guided transformer for programguided tasks
references.venue: arXiv preprint arXiv:2110.00804
references.authors: S. Zheng J. Lu H. Zhao X. Zhu Z. Luo
references.title: and Y
references.venue: W. et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. In IEEE CVPR
references.authors: D. Zhou B. Kang X. Jin L. Yang X. Lian
references.title: and Z
references.venue: J. et al. Deepvit: Towards deeper vision transformer. In IEEE CVPR
references.authors: Z. Zhu M. Xu S. Bai T. Huang X. Bai
references.title: Asymmetric non-local neural networks for semantic segmentation
references.venue: IEEE ICCV, pages 593–602
sections.heading: 1 Introduction
sections.text: In recent years, convolutional neural networks (CNNs) have dominated various vision tasks including but not limited to image recognition [22, 18, 38, 39, 5, 19, 41, 20, 52], object detection [37, 2, 26, 36, 24, 51, 30, 21, 11] and segmentation [17, 28], thanks to their unprecedented representation capacity. However, limited receptive fields of convolutions inevitably neglect the global patterns in images, which might be crucial during inference. For example, it is more likely a chair than a elephant nearby a table. Such object-level information cannot be fully explored by local convolutions, that hampers further improvement of CNNs. Motivated by the success of Transformer architecture [43] in Natural Language Processing (NLP) [9, 34, 1] and Multi-modality Fusion [29, 40, 12], researchers are trying to apply Transformer to vision tasks and have obtained promising results. In [10, 55, 48, 4, 7, 45, 46, 27, 3, 54, 14, 15, 44, 53], many novel architectures and optimizing strategies are proposed and achieve comparable or even better performance than CNNs, emphasizing the significance of extracting global features in vision tasks.
  Inspired by the verified efficacy of CNN and Transformer, many concurrent works, such as ContNet [47] a CvT [46], attempt to introduce convolutions to vision transformers in different manners, hoping to combine both advantages. In CvT [46], linear projection of self-attention block in the Transformer module are replaced with convolutional projection. In contrast, ContNet[47] performs
  35th Conference on Neural Information Processing Systems (NeurIPS 2021)
  convolution on different token maps to build mutual connections, which is similar to Swin Transformer [27].
  Attention maps
  (a) (b)Input image
  Feature maps
  (c) (d)
  Deit DS-Net Deit DS-Net
  However, some drawbacks of existing models still remain to be solved. Firstly, works mentioned above either perform convolution and attention mechanisms sequentially, or just replace linear projection with convolutional projection in attention mechanisms, which may not be the most ideal design. Additionally, the conflicting properties of such two operations, convolution for local patterns but attention for global patterns, might cause ambiguity during training, which prevents their merits from merging to the maximum extent. Furthermore, self-attention can capture long-range information via the built-in all-pair interaction in theory, but it is quite possible that attentions might be confused and disturbed by neighboring details in high resolution feature maps, fail to build up object-level global patterns(see Fig. 1(a)). Finally, the computation cost of self-attention is unaffordable due to the quadratic computation complexity of sequence length. Although PVT [45] and APNB [56] downsample the key-query features to improve the efficiency of self-attention operator, they both abandon fine-graind local details of the image, which greatly impairs their performance.
  In this paper, we address the these issues by introducing a Dual-stream Network (DS-Net). Instead of single stream architecture as previous works, our DS-Net adopts Dual-stream Blocks (DS-Blocks), which generates two feature maps with different resolutions, and retains both local and global information of the image via two parallel branches. We propose a Intra-scale Propagation module here to process two feature maps. Specifically, high-resolution features are used to extract fine-grained local patterns with depth-wise convolution, while low-resolution features are expected to summarize long-range global patterns. Considering low-resolution features themselves contain more integrated information, it would be much more easier for self-attention mechanism to capture object-level patterns rather than overwhelmed by trivial details (see Fig. 1(b)). Such dual-stream architecture disentangles local and global representations, which helps maximize both their merits, and thus generates better representations compared to DeiT baseline (see (c) and (e) in Fig. 1). Besides, low-resolution feature maps for self-attention dramatically reduce the memory cost and computation complexity. After parallelly processing dual streams, we present Inter-scale Alignment module based on co-attention mechanism at the end of DS-Blocks. This is because local details and global patterns capture different perspectives of the image, which are misaligned not only in pixel positions but also in semantics. Hence, this module is designed for modeling complex cross-scale relations and adaptively fuse local and global patterns.
  Besides, we apply our DS-Blocks to Feature Pyramid Networks for further feature refinement, named DS-FPN. In this way, multi-level features are capable of extracting contextual information from both local and global views, improving performance of downstream tasks. This demonstrates that our Dual Stream design could be utilized as a plug-in building block not only for image recognition, but for many other vision tasks.
  The contributions of this work are concluded as follows:
  1. We present a novel Dual-Stream Network, named DS-Net, which retains both local and global features in DS-Block. The independent propagation maximize the advantages of convolution and self-attention, thus eliminating the conflicts during training.
  2. We propose Intra-scale Propagation and Inter-Scale Alignment mechanism to achieve effective information flows within and between features of different resolutions, thus generating better representations of the image.
  3. We introduce Dual-stream Feature Pyramid Network (DS-FPN) to enhance contextual information for downstream dense tasks and achieves better performance with little extra costs.
  4. Without bells and whistles, the proposed DS-Net outperforms DeiT baseline by significant margins in terms of top-1 accuracy on ImageNet-1k and achieves state-of-the-art performance over other Vision Transformers and CNN-based networks on image classification and downstream tasks, including object detection and instance segmentation.
sections.heading: 2 Related work
sections.text: Vision Transformers. Motivated by the great success of Transformer in natural language processing, researchers are trying to apply Transformer architecture to Computer Vision tasks. Unlike mainstream CNN-based models, Transformer is capable of capturing long-distance visual relations by its selfattention module and provides the paradigm without image-specific inductive bias. ViT [10] views 16 × 16 image patches as token sequence and predicts classification via a unique class token, which shows promising results. Subsequently, many works, such as DeiT [42] and PVT [45] achieve further improvement on ViT, making it more efficient and applicable in downstream tasks. ResT [50] proposed a efficient transformer model. Besides, models based on Transformer also give leading performance in many other vision tasks such as object tracking and video analysis.
  Local and Global Features in Transformers. Despite the Transformer’s superiority upon extracting global representations, image-level self-attention is unable to capture fine-grained details. To tackle this issue, previous works assert to obtain the local information at the same time and then fuse features of the two scales. TNT [16] proposes intra-patch self-attention block to model local structures and aggregates them with global patch embeddings. Swin Transformer [27] extracts local features within each partitioned window and fuses them by self-attention in successive shifted windows. Similarly, shifted windows are replaced by convolutions in ContNet [47]. Following such design of local windows, Twins [6] uses inter-window attention to aggregate global features. Swin Transformer and Twins both give advanced performance, but still rely on local-window self-attention to capture fine-level features, which works intuitively worse than CNN. Besides, Swin’s shifted windows are complex for device optimization and Twins [6] recurrently local and global attentions would constrain each other’s representation learning.
  Equip Transformers with Convolution. Compared to self-attention mechanism, CNN has its unique advantages of local modeling and translation invariance. Therefore, some existing transformers explore the hybrid architecture to incorporate both merits for better visual representation. T2T [48] progressively aggregate neighboring tokens to one token to capture local structure information, similar to convolution operation. Followingly, CvT [46] designs Convolutional Token Embedding and Convolutional Transformer Block for capturing more precise local spatial context. CPVT [7] utilizes one convolutional layer to dynamically generate positional encodings, adaptive for varying image scales. Conformer [33] combines transformer with an independent CNN network for specializing local features and flows information via lateral connections. Nonetheless, none of the aforementioned models maximizes the potential of the hybrid architecture. They either use CNN for marginal operations to boost Transformer, e.g., tokens generation in CvT [46] and positional encodings in CPVT [7], or view CNN as a relatively separate branch, like Conformer.
  Different from previous works, in proposed DS-Blocks, we treat self-attention and convolution as dual resolution processing paths via Intra-scale Propagation module, where the former aims to extract local fine-grained details, and the latter focus on exploring features from a global view. On top of that, their information is reasonably fused by Inter-scale Alignment module based on co-attention, which addresses the issue of feature misalignment. By this design, the local and global patterns could be simultaneously extracted and the capability of CNN is fully exerted in Transformer architecture.
sections.heading: 3 Method
sections.heading: 3.1 Dual-scale Representations
sections.text: The overall pipeline of our proposed DS-Net is shown in Fig. 2. Motivated by stage-wise design in previous networks like ResNet [18], we set 4 stages in the architecture, whose down-sampling factors
  are 4, 8, 16, 32, respectively. Within each stage, Dual-stream Blocks (DS-Blocks) are adopted to generate and combine dual-scale representations.
  Our key idea is to keep local features in a relatively high resolution to reserve local details, while represent global features with a lower resolution (1/32 of the image size) to retain global patterns. Specifically, in each DS-block, we split the input feature map into two parts at the channel dimension. One is for extracting local features, denoted as fl, the other is for summarizing global features, denoted as fg. Notably, we keep the size of fg unchanged in all stages across the network by downsampling it with a proper factor, W32 × H 32 × Ci 2 , where W and H represents the width and height of the input image, and Ci represents the channel number of input features in current stage. Aided by the high resolution of fl, the local patterns could be much reserved for subsequent extraction, but thanks to the low resolution of fg , the exploration of non-local and object-level information is greatly benefited.
sections.heading: 3.2 Intra-scale Propagation
sections.text: Local and global features are representations of one image from two totally different views. The former focuses on fine-grained details, essential for tiny-object detection and pixel-level localization, while the latter aims at modeling object-level relations between long-range parts. Therefore, given dual-scale features fl and fg , we perform Intra-scale Propagation module to parallelly process them.
  Local representation. For high-resolution fl with the size of Wi ×Hi × Cl, where Cl equals Ci2 , we perform 3×3 depth-wise convolution to extract local features as follows and obtain fL:
  fL(i, j) = M,N∑ m,n W (m,n)⊙ fl(i+m, j + n), (1)
  where W (m,n), (m,n) ∈ (−1, 0, 1) represents the convolution filters, W (m,n) and fl(i, j) are both Ci 2 dimensional vectors, ⊙ denotes element-wise product. By the power of depth-wise convolution, fL is able to contain fine-grained local details of the input image.
  Global representation. For low-resolution representation fg with the fixed size of W32 × H 32 × Ci 2 as illustrated in Section 3.1, we first flatten fg to a sequence with the length of lg , the product of W32 and
  H 32 , in which each element is a Ci 2 dimensional vector. By doing this, each vector in the sequence is treated as a visual token without spatial information. Here, the dependencies between different token pairs are unrelated with their spatial positions in the feature map, which is totally different with the convolution. Then, we summarize the global information and model the object-level coupling relation via self-attention mechanism:
  fQ = fgWQ, fK = fgWK , fV = fgWV , (2)
  where WQ, WK , WV denote matrixes to generate queries, keys and values respectively. By calculating the similarity between fQ and fV , we obtain attention weights for aggregating information from different locations of fg. Finally, we calculate the weighted sum of attention weights and fV , thus obtaining integrated features:
  fG = softmax( fQf T K√ d )fV , (3)
  where d equals Ci 2
  N , N denotes the number of attention head that we set to 1, 2, 5, 8 for 4 stages respectively in DS-Net.
  Our dual-stream architecture disentangles fine-grained and integrated features in two pathways, which significantly eliminates the ambiguity during training. Additionally, the Intra-scale Propagation module processes feature maps with dual resolutions by two domain-specifically effective mechanisms separately, extracting local and global features to the maximum extent.
sections.heading: 3.3 Inter-scale Alignment
sections.text: A delicate fusion of dual-scale representations is vital for the success of DS-Net, since they capture two different perspectives of one image. To address this, a naive idea is to upsample the low-resolution representation using bilinear interpolation, and then fuse the dual-scale representations via 1 by 1 convolution after simply concatenating them position-wisely. Such naive fusion is not convincing enough. Furthermore, by visualizing the feature maps of dual-scale features, we observe that global features in low resolutions and local features in high-resolutions are actually misaligned (see (b) and (d) in Fig. 1. Therefore, considering the relation of two representations are not explicitly explored, it is unpersuasive to pre-define a fixed strategy to fuse them, such as concatenation, element-wise addition or production. Enlightened by [13, 32], we propose a novel co-attention-based Interscale Alignment module, whose scheme of Inter-scale Alignment module is shown in Fig. 2. This module aims to capture the mutual correlations between each local-global token pair, and propagate information bidirectionally in a learnable and dynamic manner. Such mechanism prompts local features to adaptively explore their relations with global information, enabling themselves to be more representative and informative, and vice versa.
  Given extracted local features fL with the size of Wi ×Hi × Ci2 and global features fG with the size of lg × Ci2 , we first flatten fL to a sequence with the length of ll, the product of Wi and Hi, in which each element is a Ci2 dimensional vector. fL and fG are now in the same format but with different length. Then we perform co-attention on two sequences as follows:
  QL = fLW l Q, KL = fLW l K , VL = fLW l V , QG = fGW g Q, KG = fGW g K , VG = fGW g V ,
  (4)
  where the sizes of W are all Ci2 × dim, and the dim is a hyper-parameter. Thus we have the transformed features of local and global representations. Then we calculate the similarities between every pair of fL and fA to obtain the corresponding attention weights:
  WG→L = softmax( QLK T G√
  d ), WL→G = softmax(
  QGK T L√
  d ). (5)
  The size of WG→L and WL→G are ll × lg and lg × ll respectively. The non-linear function softmax is performed at the last dimension. WG→L reflects the importance of different tokens in global features to the local tokens. Likewise, global features can also extract useful information from local features via WL→G. Instead of fixed fusion strategy that might bring constraints, what and how the
  information transfers are automatically determined by features themselves here. We can then obtain hybrid features as:
  hL = WG→LVG, hG = WL→GVL, (6)
  where the size of hL and hG are ll×dim and lg×dim respectively. Then we add a 1 × 1 convolution layer after hybrid features to further fuse the channels and reshape them to Wi × Hi × Ci2 and W 32 × H 32 × Ci 2 .
  Such a bidirectional information flow is able to identify cross-scale relations between local and global tokens, by which dual-scale features are highly aligned and coupled with each other. After this, we could safely upsample low-resolution representation hG, concatenate it with high-resolution hL and perform 1 by 1 convolution for channel-wise dual-scale information fusion. At the end of the last block in stage 4, we add a fully-connected layer as the classifier to conduct classification.
sections.heading: 3.4 Dual-stream Feature Pyramid Networks
sections.text: Introducing contextual information into Feature Pyramid Networks(FPN) [23] has been explored by [49, 31]. However, previous methods often cause large extra memory and computation costs, due to their complicated architectures and utilized high resolution feature maps. Besides, Non-local contexts would miss local details, which is disastrous for tiny object detection and segmentation. Here, we apply our Dual-stream design into FPN, named Dual-stream Feature Pyramid Networks(DS-FPN), by simply adding DS-Blocks to every feature pyramid scale. In this way, DS-FPN is able to better attain non-local patterns and local details with marginal increased costs at all scales, which further enhance the performance of subsequent object detection and segmentation heads. This shows our DS-Net can not only serve as a backbone but also a general plug-in building block in many other vision architectures.
  Similar to FPN [23], we take image features from various scales from the backbone as input, and output corresponding refined feature maps of fixed channels number by a top-down aggregation methods. Our structure is composed of bottom-up pathways, Dual-stream lateral connections, and top-down pathways. The bottom-up and top-down pathways follow the design of FPN, but lateral connection here adopts DS-Block to process features in dual scales via Intra-scale Propagation and Inter-scale Alignment. See Fig. 3.
sections.heading: 4 Experiments
sections.text: In this section, we first provide three ablation studies to explore the optimal structure of DS-Net and interpret the necessity of dual-stream design. Then we give the experimental results of image classification and downstream tasks including object detection and instance segmentation. Specifically, We use ImageNet-1K [8] for classification and MSCOCO 2017 [25] for object detection and instance segmentation. All experiments are conducted on 8 V100 GPUs and the throughput is tested on 1 V100 GPU. As the number of blocks we set in different stages in the architecture (see Fig. 2) is flexible, we conduct experiments on 3 models with different parameter size, denoted as DS-Net-T (Tiny), DS-Net-S (Small) and DS-Net-B (Big), which have comparable parameters with ResNet-18, ResNet-50 and ResNet-101 respectively. The detailed setup is shown in Table 1.
sections.heading: 4.1 Ablation Study
sections.heading: 4.1.1 Ratio of Local to Global Features
sections.text: Settings. As described in Section 3.1, we split the features into two parts in channel dimension as local and global representations, which are later processed by convolution and self-attention, respectively. We conduct an experiment to explore a appropriate partition ratio. We use α to denote the proportion of channel number of fg (global features) to the total channel number. When α equals 0, only depth-wise convolution is performed, and when α equals 1, only self-attention is performed. Noting that in this experiment, we choose DS-Net-T as the testing model, which simply concatenates fL and fA at the end of each block, without Inter-scale Alignment module.
  Results. The results in Table 2 indicates that when α equals 0.5, DS-Net-T achieves the highest accuracy on ImageNet-1k validation set, which, to some extent, implies that local and global information play equally important roles for visual representations. Thus, in the following experiments, we equally split features into two parts at the channel dimension to obtain dual-scale representations.
sections.heading: 4.1.2 None is Dispensable in DS-Block
sections.text: Settings. Here, we illustrate that every component within DS-Block plays a vital role in the prediction, including either pathway of Intra-scale Propagation and bidirectional co-attention of Inter-scale Alignment. In Table 3, we respectively remove one of the four modules in every block of DS-Net-T∗ (DS-Net∗ represents the corresponding DS-Net version with Inter-scale Alignment module), while remain the others the same. Therein, w/o fL denotes that fl split at the beginning is directly fed to Inter-scale Alignment Module without exploring local features, and w/o G → L denotes that co-attention from global features to local features is not implemented, analogous to w/o fG and w/o L → G. The version w/o L ↔ G removes the entire co-attention, which equals DS-Net-T.
  Results. As shown in Table 3, any absence of the components in DS-Block deteriorates the performance. Compared to extracting local and global features simultaneously, the model’s representation capacity is constrained with either fL or fG. Surprisingly, the unilateral co-attention of w/o G → L and w/o G → L performs worse than removing any fusion strategy, because implementing G → L would confuse the original local features fL, and only by L → G could the missing local features be complemented. This further demonstrates the importance of the designed Inter-scale Alignment module.
sections.heading: 4.2 Image Classification
sections.text: Settings. Image classification experiments are performed on ImageNet-1K [8], comprising 1.28M training images and 50K validation images of 1000 classes. For fair comparison with other works, we follow the training settings in DeiT. We train our model for 300 epochs by AdamW optimizer. The initial learning rate is set to 1e-3 and scheduled by the cosine strategy.
  Results. We report the results in Table 4, where DS-Net and DS-Net∗ denote our proposed networks with and without Inter-scale Alignment module respectively. For DS-Net, only concatenation operation is used to fuse the local and global features. DS-Net∗ is the version with Inter-scale Alignment module. With comparable parameters and complexity, our proposed DS-Net consistently outperforms the DeiT [42] baseline by significant margins, which is, specifically, 6.8% improvement for tiny model, 2.4% improvement for small model and 1.3% for big model with only half parameters. The efficacy of Inter-scale Alignment module is also clearly indicated in Table 4, which gains further 0.9% , 0.4% and 0.3% improvement compared to the simple version of DS-Net-T, DS-Net-S and DS-Net-B. Notably, without bells and whistles, DS-Net-T∗ DS-Net-S∗ also outperform other state-of-the-art methods, including CNN, vision transformer and some hybrid architectures.
sections.heading: 4.3 Object Detection and instance segmentation
sections.text: Settings. Experiments in this part are conducted on the challenging MSCOCO 2017 [25], containing 118K training images and 5K validation images. Specifically, the backbone is initialized by pretraind weights from ImageNet-1K, and other layers adopt Xavier. We evaluate our DS-Net on typical detectors: RetinaNet and Mask R-CNN [17]. As the standard 1× schedule(12 epochs), we adopt AdamW optimizer with initial learning rate of 1e-4, decayed by 0.1 at epoch 8 and 11. We set stochastic drop path regularization of 0.1 and weight decay of 0.05. Following previous methods, training and testing images are resized to 800×1333. Results. The results are shown in Table 5. For object detection, DS-Net-S∗ achieves significant improvement compared to ResNet-50 backbone [24] by 6.4% with RetinaNet and 6.1% with Mask R-CNN in terms of AP bbox, and outperforms the previous state-of-the-art Swin-T [27] by 1.2% and 0.6%. For instance segmentation, DS-Net-S∗ achieves 40.2% in terms of AP segm, which surpasses the ResNet-50 and Swin-T by 5.5% and 0.4%.
sections.heading: 4.4 Dual-stream Feature Pyramid Networks
sections.text: Settings. Experiments of DS-FPN are implemented on DS-Net-T and Swin Transformer [27] for object detection and instance segmentation on MSCOCO 2017 [25], by replacing the original FPN with DS-FPN. The training setting and scheme are the same as those mentioned above, which is 1× schedule(12 epochs) and AdamW optimizer with initial learning rate of 1e-4. Likewise, the backbone is initialized with pretrained weights, and DS-FPN is trained from scratch with newly added heads.
  Ablation Study. In Table 6, we report results of several different designs combining DS-Blocks with FPN on RetinaNet, with DS-Net-T backbone. Four inserted positions of DS-Blocks have been
  experimented, where "Last" means replacing the last 3×3 convolution layer, and "Lateral" equips them on lateral connections. More specifically, "Lateralrev" moves the inner channel-alignment 1 ×1 convolution layer from the last place to the first, and "Lateralextra" adds DS-Blocks also on extra feature outputs. The results show that "Lateralextra" has the best performance. Therefore, we set "Lateralextra" as our default, which is 1.4% higher than FPN with marginal memory costs.
  Comparison with FPN.As reported in Table 7. For object detection, DS-Net-T and Swin Transformer with DS-FPN gain 1.4% and 0.8% mAP improvement, respectively. For instance segmentation, DSFPN helps to gain 0.7% and 1.4% AP segm improvement for DS-Net-T and Swin Transformer, respectively. The results significantly prove the generality and effectiveness our Dual-stream design.
sections.heading: 5 Conclusion
sections.text: In this paper, we propose a generic Dual-stream Network, called DS-Net, which disentangles local and global features by generating two representations with different resolutions. We present Intrascale Propagation module and Inter-scale Alignment module to combine the merits of convolution and self-attention mechanisms, and identify cross-scale relations between local and global tokens. Besides, for downstream tasks, we design a Dual-stream Feature Pyramid Network (DS-FPN) to introduce contextual information to feature pyramid for further refinement with marginal costs. With the outstanding performance on image classification and dense downstream tasks including object detection and instance segmentation, our proposed DS-Net has shown its promising potential in vision tasks.
  Disclosure of Funding
  This work was supported by the National Natural Science Foundation of China under Grant 62076016 and the Shanghai Committee of Science and Technology, China (Grant No. 21DZ1100100).
title: Dual-stream Network for Visual Recognition