mirror of
https://github.com/open-mmlab/mmselfsup.git
synced 2025-06-03 14:59:38 +08:00
* [Feature]: Add BEiT Support * [Fix]: fix bugs after update * [Fix]: fix bugs in backbone * [Refactor]: refactor config * [Feature]: Support BEiTv2 * [Fix]: Fix UT * [Fix]: rename some configs * [Fix]: fix beitv2neck * [Refactor]: refactor beitv2 * [Fix]: fix lint * refactor configs * refactor beitv2 * update configs * add dalle target generator * refactor for beitv1 * refactor rel_pos_bias of beit * update configs * update configs * update v1 configs * update v2 configs * refactoe layer decay * update unittest * fix lint * fix ut * add docstrings * rename * fix lint * add beit model and log links * fix lint * update according to review * update * update * update LearningRateDecayOptimWrapperConstructor related configs * update init and backbone * update neck and vqkd * refactor neck * fix lint * add some comments * fix typo Co-authored-by: 任琴 <PJLAB\renqin@shai14001114l.pjlab.org> Co-authored-by: fangyixiao18 <fangyx18@hotmail.com>
29 lines
679 B
Python
29 lines
679 B
Python
# Copyright (c) OpenMMLab. All rights reserved.
|
|
import platform
|
|
|
|
import pytest
|
|
import torch
|
|
|
|
from mmselfsup.models.backbones import BEiTViT
|
|
|
|
backbone = dict(
|
|
arch='base',
|
|
patch_size=16,
|
|
drop_path_rate=0.1,
|
|
final_norm=True,
|
|
layer_scale_init_value=0.1,
|
|
)
|
|
|
|
|
|
@pytest.mark.skipif(platform.system() == 'Windows', reason='Windows mem limit')
|
|
def test_beit_vit():
|
|
beit_backbone = BEiTViT(**backbone)
|
|
beit_backbone.init_weights()
|
|
|
|
fake_inputs = torch.randn((2, 3, 224, 224))
|
|
fake_mask = torch.zeros((2, 196))
|
|
fake_mask[:, 75:150] = 1
|
|
fake_outputs = beit_backbone(fake_inputs, fake_mask)
|
|
|
|
assert list(fake_outputs[0].shape) == [2, 197, 768]
|