Vision Transformer. This backbone is the implementation of `An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale `_. Args: img_size (int | tuple): Input image size. Default: 224. patch_size (int): The patch siz
| 96 | |
| 97 | @BACKBONES.register_module() |
| 98 | class SelfPatch_ViT(BaseModule): |
| 99 | """Vision Transformer. |
| 100 | |
| 101 | This backbone is the implementation of `An Image is Worth 16x16 Words: |
| 102 | Transformers for Image Recognition at |
| 103 | Scale <https://arxiv.org/abs/2010.11929>`_. |
| 104 | |
| 105 | Args: |
| 106 | img_size (int | tuple): Input image size. Default: 224. |
| 107 | patch_size (int): The patch size. Default: 16. |
| 108 | in_channels (int): Number of input channels. Default: 3. |
| 109 | embed_dims (int): embedding dimension. Default: 768. |
| 110 | num_layers (int): depth of transformer. Default: 12. |
| 111 | num_heads (int): number of attention heads. Default: 12. |
| 112 | mlp_ratio (int): ratio of mlp hidden dim to embedding dim. |
| 113 | Default: 4. |
| 114 | out_indices (list | tuple | int): Output from which stages. |
| 115 | Default: -1. |
| 116 | qkv_bias (bool): enable bias for qkv if True. Default: True. |
| 117 | drop_rate (float): Probability of an element to be zeroed. |
| 118 | Default 0.0 |
| 119 | attn_drop_rate (float): The drop out rate for attention layer. |
| 120 | Default 0.0 |
| 121 | drop_path_rate (float): stochastic depth rate. Default 0.0 |
| 122 | with_cls_token (bool): Whether concatenating class token into image |
| 123 | tokens as transformer input. Default: True. |
| 124 | output_cls_token (bool): Whether output the cls_token. If set True, |
| 125 | `with_cls_token` must be True. Default: False. |
| 126 | norm_cfg (dict): Config dict for normalization layer. |
| 127 | Default: dict(type='LN') |
| 128 | act_cfg (dict): The activation config for FFNs. |
| 129 | Defalut: dict(type='GELU'). |
| 130 | patch_norm (bool): Whether to add a norm in PatchEmbed Block. |
| 131 | Default: False. |
| 132 | final_norm (bool): Whether to add a additional layer to normalize |
| 133 | final feature map. Default: False. |
| 134 | interpolate_mode (str): Select the interpolate mode for position |
| 135 | embeding vector resize. Default: bicubic. |
| 136 | num_fcs (int): The number of fully-connected layers for FFNs. |
| 137 | Default: 2. |
| 138 | norm_eval (bool): Whether to set norm layers to eval mode, namely, |
| 139 | freeze running stats (mean and var). Note: Effect on Batch Norm |
| 140 | and its variants only. Default: False. |
| 141 | with_cp (bool): Use checkpoint or not. Using checkpoint will save |
| 142 | some memory while slowing down the training speed. Default: False. |
| 143 | pretrained (str, optional): model pretrained path. Default: None. |
| 144 | init_cfg (dict or list[dict], optional): Initialization config dict. |
| 145 | Default: None. |
| 146 | """ |
| 147 | |
| 148 | def __init__(self, |
| 149 | img_size=224, |
| 150 | patch_size=16, |
| 151 | in_channels=3, |
| 152 | embed_dims=768, |
| 153 | num_layers=12, |
| 154 | num_heads=12, |
| 155 | mlp_ratio=4, |
nothing calls this directly
no outgoing calls
no test coverage detected