def __init__(self, model_config: dict): super().__init__() model_config = Dict(model_config) backbone_type = model_config.backbone.pop('type') neck_type = model_config.neck.pop('type') head_type = model_config.head.pop('type') self.backbone = build_backbone(backbone_type, **model_config.backbone) self.neck = build_neck(neck_type, in_channels=self.backbone.out_channels, **model_config.neck) self.head = build_head(head_type, in_channels=self.neck.out_channels, **model_config.head) self.name = f'{backbone_type}_{neck_type}_{head_type}'
def __init__(self, model_config: dict): """ PANnet :param model_config: 模型配置 """ super().__init__() model_config = Dict(model_config) backbone_type = model_config.backbone.pop('type') neck_type = model_config.neck.pop('type') head_type = model_config.head.pop('type') self.normalize = Normalize([0.485 * 255, 0.456 * 255, 0.406 * 255], [0.229 * 255, 0.224 * 255, 0.225 * 255]) self.backbone = build_backbone(backbone_type, **model_config.backbone) self.neck = build_neck(neck_type, in_channels=self.backbone.out_channels, **model_config.neck) self.head = build_head(head_type, in_channels=self.neck.out_channels, **model_config.head) self.name = f'{backbone_type}_{neck_type}_{head_type}'
def __init__( self, num_classes, backbone='resnet50', pretrained=True, pooling='avg_pooling', pooling_size=1, head='BNHead', bn_where='after', batch_norm_bias=True, use_tqdm=True, is_inference=False): super(Baseline, self).__init__() self.head_name = head self.num_classes = num_classes self.is_inference = is_inference self.backbone, feature_dim = build_backbone(backbone, pretrained=pretrained, progress=use_tqdm) self.global_pooling = build_pooling(pooling, pooling_size) self.head = build_head(head, feature_dim, self.num_classes, bias_freeze=not batch_norm_bias, bn_where=bn_where, pooling_size=pooling_size)