| 685 | |
| 686 | @BACKBONE_REGISTRY.register() |
| 687 | class D2SwinTransformer(SwinTransformer, Backbone): |
| 688 | def __init__(self, cfg, input_shape): |
| 689 | |
| 690 | pretrain_img_size = cfg.MODEL.SWIN.PRETRAIN_IMG_SIZE |
| 691 | patch_size = cfg.MODEL.SWIN.PATCH_SIZE |
| 692 | in_chans = 3 |
| 693 | embed_dim = cfg.MODEL.SWIN.EMBED_DIM |
| 694 | depths = cfg.MODEL.SWIN.DEPTHS |
| 695 | num_heads = cfg.MODEL.SWIN.NUM_HEADS |
| 696 | window_size = cfg.MODEL.SWIN.WINDOW_SIZE |
| 697 | mlp_ratio = cfg.MODEL.SWIN.MLP_RATIO |
| 698 | qkv_bias = cfg.MODEL.SWIN.QKV_BIAS |
| 699 | qk_scale = cfg.MODEL.SWIN.QK_SCALE |
| 700 | drop_rate = cfg.MODEL.SWIN.DROP_RATE |
| 701 | attn_drop_rate = cfg.MODEL.SWIN.ATTN_DROP_RATE |
| 702 | drop_path_rate = cfg.MODEL.SWIN.DROP_PATH_RATE |
| 703 | norm_layer = nn.LayerNorm |
| 704 | ape = cfg.MODEL.SWIN.APE |
| 705 | patch_norm = cfg.MODEL.SWIN.PATCH_NORM |
| 706 | use_checkpoint = cfg.MODEL.SWIN.USE_CHECKPOINT |
| 707 | |
| 708 | super().__init__( |
| 709 | pretrain_img_size, |
| 710 | patch_size, |
| 711 | in_chans, |
| 712 | embed_dim, |
| 713 | depths, |
| 714 | num_heads, |
| 715 | window_size, |
| 716 | mlp_ratio, |
| 717 | qkv_bias, |
| 718 | qk_scale, |
| 719 | drop_rate, |
| 720 | attn_drop_rate, |
| 721 | drop_path_rate, |
| 722 | norm_layer, |
| 723 | ape, |
| 724 | patch_norm, |
| 725 | use_checkpoint=use_checkpoint, |
| 726 | ) |
| 727 | |
| 728 | self._out_features = cfg.MODEL.SWIN.OUT_FEATURES |
| 729 | |
| 730 | self._out_feature_strides = { |
| 731 | "res2": 4, |
| 732 | "res3": 8, |
| 733 | "res4": 16, |
| 734 | "res5": 32, |
| 735 | } |
| 736 | self._out_feature_channels = { |
| 737 | "res2": self.num_features[0], |
| 738 | "res3": self.num_features[1], |
| 739 | "res4": self.num_features[2], |
| 740 | "res5": self.num_features[3], |
| 741 | } |
| 742 | |
| 743 | def forward(self, x): |
| 744 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected