(pretrained=False, load_pos_embed=True, pretrain_path=None, pos_embed_interp=False, **kwargs)
| 593 | |
| 594 | |
| 595 | def vit_large_patch16(pretrained=False, load_pos_embed=True, pretrain_path=None, pos_embed_interp=False, **kwargs): |
| 596 | default = dict( |
| 597 | drop_path_rate=0.5, use_abs_pos_emb=True, # as in table 11 |
| 598 | #### |
| 599 | patch_size=16, embed_dim=1024, depth=24, num_heads=16, mlp_ratio=4, qkv_bias=True, |
| 600 | norm_layer=partial(nn.LayerNorm, eps=1e-6) |
| 601 | ) |
| 602 | recursive_update(default, kwargs) |
| 603 | model = ViT(**default) |
| 604 | # del model.head |
| 605 | |
| 606 | # if pretrained: |
| 607 | if False: |
| 608 | script_dir = os.path.dirname(__file__) |
| 609 | if pretrain_path: |
| 610 | checkpoint = torch.load(pretrain_path)['model'] |
| 611 | print("load pretrain from {}".format(pretrain_path)) |
| 612 | elif pretrained == 'supervised-80ecf9dd': |
| 613 | rel_path = "pretrain_weights/jx_vit_base_p16_224-80ecf9dd.pth" |
| 614 | checkpoint = torch.load(os.path.join(script_dir, rel_path)) |
| 615 | elif pretrained == 'clip': |
| 616 | rel_path = "pretrain_weights/CLIP-ViT-B-16.pt" |
| 617 | checkpoint = torch.load(os.path.join(script_dir, rel_path)) |
| 618 | # rename & clean loaded keys |
| 619 | checkpoint = clip_checkpoint_preprocess(checkpoint) |
| 620 | else: |
| 621 | rel_path = "pretrain_weights/mae_pretrain_vit_base.pth" |
| 622 | checkpoint = torch.load(os.path.join(script_dir, rel_path))['model'] |
| 623 | |
| 624 | # load while interpolates position embedding |
| 625 | load_checkpoint(model, checkpoint, load_pos_embed, strict=False, pos_embed_interp=pos_embed_interp, logger=dummy_logger) |
| 626 | del checkpoint |
| 627 | |
| 628 | return model |
| 629 | |
| 630 | def vit_base_patch16_ema(**kwargs): |
| 631 | backbone = vit_base_patch16(**kwargs) |
nothing calls this directly
no test coverage detected