(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ignore",)
| 9 | ) |
| 10 | |
| 11 | def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ignore",): |
| 12 | if backbone == "vitl16_384": |
| 13 | pretrained = _make_pretrained_vitl16_384( |
| 14 | use_pretrained, hooks=hooks, use_readout=use_readout |
| 15 | ) |
| 16 | scratch = _make_scratch( |
| 17 | [256, 512, 1024, 1024], features, groups=groups, expand=expand |
| 18 | ) # ViT-L/16 - 85.0% Top1 (backbone) |
| 19 | elif backbone == "vitb_rn50_384": |
| 20 | pretrained = _make_pretrained_vitb_rn50_384( |
| 21 | use_pretrained, |
| 22 | hooks=hooks, |
| 23 | use_vit_only=use_vit_only, |
| 24 | use_readout=use_readout, |
| 25 | ) |
| 26 | scratch = _make_scratch( |
| 27 | [256, 512, 768, 768], features, groups=groups, expand=expand |
| 28 | ) # ViT-H/16 - 85.0% Top1 (backbone) |
| 29 | elif backbone == "vitb16_384": |
| 30 | pretrained = _make_pretrained_vitb16_384( |
| 31 | use_pretrained, hooks=hooks, use_readout=use_readout |
| 32 | ) |
| 33 | scratch = _make_scratch( |
| 34 | [96, 192, 384, 768], features, groups=groups, expand=expand |
| 35 | ) # ViT-B/16 - 84.6% Top1 (backbone) |
| 36 | elif backbone == "resnext101_wsl": |
| 37 | pretrained = _make_pretrained_resnext101_wsl(use_pretrained) |
| 38 | scratch = _make_scratch([256, 512, 1024, 2048], features, groups=groups, expand=expand) # efficientnet_lite3 |
| 39 | elif backbone == "efficientnet_lite3": |
| 40 | pretrained = _make_pretrained_efficientnet_lite3(use_pretrained, exportable=exportable) |
| 41 | scratch = _make_scratch([32, 48, 136, 384], features, groups=groups, expand=expand) # efficientnet_lite3 |
| 42 | else: |
| 43 | print(f"Backbone '{backbone}' not implemented") |
| 44 | assert False |
| 45 | |
| 46 | return pretrained, scratch |
| 47 | |
| 48 | |
| 49 | def _make_scratch(in_shape, out_shape, groups=1, expand=False): |
no test coverage detected