MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / base

Function base

SwissArmyTransformer/examples/yolos/models/backbone.py:445–457  ·  view source on GitHub ↗
(pretrained=None, **kwargs)

Source from the content-addressed store, hash-verified

443
444
445def base(pretrained=None, **kwargs):
446 model = VisionTransformer(
447 img_size=384, patch_size=16, embed_dim=768, depth=12, num_heads=12, mlp_ratio=4, qkv_bias=True,
448 norm_layer=partial(nn.LayerNorm, eps=1e-6),is_distill=True, **kwargs)
449 if pretrained:
450 # checkpoint = torch.load('deit_base_distilled_patch16_384-d0272ac0.pth', map_location="cpu")
451 # checkpoint = torch.hub.load_state_dict_from_url(
452 # url="https://dl.fbaipublicfiles.com/deit/deit_base_distilled_patch16_384-d0272ac0.pth",
453 # map_location="cpu", check_hash=True
454 # )
455 checkpoint = torch.load(pretrained, map_location="cpu")
456 model.load_state_dict(checkpoint["model"], strict=False)
457 return model, 768

Callers 1

__init__Method · 0.85

Calls 3

VisionTransformerClass · 0.85
loadMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected