def test_resnest_stem(): # Test default stem_channels model = ResNet(50) assert model.stem_channels == 64 assert model.conv1.out_channels == 64 assert model.norm1.num_features == 64 # Test default stem_channels, with base_channels=32 model = ResNet(50, base_channels=32) assert model.stem_channels == 32 assert model.conv1.out_channels == 32 assert model.norm1.num_features == 32 assert model.layer1[0].conv1.in_channels == 32 # Test stem_channels=64 model = ResNet(50, stem_channels=64) assert model.stem_channels == 64 assert model.conv1.out_channels == 64 assert model.norm1.num_features == 64 assert model.layer1[0].conv1.in_channels == 64 # Test stem_channels=64, with base_channels=32 model = ResNet(50, stem_channels=64, base_channels=32) assert model.stem_channels == 64 assert model.conv1.out_channels == 64 assert model.norm1.num_features == 64 assert model.layer1[0].conv1.in_channels == 64 # Test stem_channels=128 model = ResNet(depth=50, stem_channels=128) model.init_weights() model.train() assert model.conv1.out_channels == 128 assert model.layer1[0].conv1.in_channels == 128 # Test V1d stem_channels model = ResNetV1d(depth=50, stem_channels=128) model.init_weights() model.train() assert model.stem[0].out_channels == 64 assert model.stem[1].num_features == 64 assert model.stem[3].out_channels == 64 assert model.stem[4].num_features == 64 assert model.stem[6].out_channels == 128 assert model.stem[7].num_features == 128 assert model.layer1[0].conv1.in_channels == 128
def test_resnest_stem(): # Test default stem_channels model = ResNet(50) assert model.stem_channels == 64 assert model.conv1.out_channels == 64 assert model.norm1.num_features == 64 # Test default stem_channels, with base_channels=3 model = ResNet(50, base_channels=3) assert model.stem_channels == 3 assert model.conv1.out_channels == 3 assert model.norm1.num_features == 3 assert model.layer1[0].conv1.in_channels == 3 # Test stem_channels=3 model = ResNet(50, stem_channels=3) assert model.stem_channels == 3 assert model.conv1.out_channels == 3 assert model.norm1.num_features == 3 assert model.layer1[0].conv1.in_channels == 3 # Test stem_channels=3, with base_channels=2 model = ResNet(50, stem_channels=3, base_channels=2) assert model.stem_channels == 3 assert model.conv1.out_channels == 3 assert model.norm1.num_features == 3 assert model.layer1[0].conv1.in_channels == 3 # Test V1d stem_channels model = ResNetV1d(depth=50, stem_channels=6) model.train() assert model.stem[0].out_channels == 3 assert model.stem[1].num_features == 3 assert model.stem[3].out_channels == 3 assert model.stem[4].num_features == 3 assert model.stem[6].out_channels == 6 assert model.stem[7].num_features == 6 assert model.layer1[0].conv1.in_channels == 6
def __init__(self): super(Net3, self).__init__() cfg = mmcv.Config.fromfile('/home/liuziming/mmdetection/configs/rpn_r50_fpn_1x.py') # set cudnn_benchmark if cfg.get('cudnn_benchmark', False): torch.backends.cudnn.benchmark = True cfg.model.pretrained = None cfg.data.test.test_mode = True self.RPN = builder.build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) self.backbone = ResNet(50,4,frozen_stages=1,) self.init_weights(pretrained='modelzoo://resnet50') self.relation = SelfAttention(2,256,256,256) self.fc = nn.Linear(256*2,40) self.avgpool = nn.AdaptiveAvgPool2d((1,1))