def backbone_generator(params): """Generator function for various backbone models.""" if params.architecture.backbone == 'resnet': resnet_params = params.resnet backbone_fn = resnet.Resnet( resnet_depth=resnet_params.resnet_depth, dropblock=dropblock_generator(resnet_params.dropblock), batch_norm_relu=batch_norm_relu_generator( resnet_params.batch_norm, activation=resnet_params.activation), init_drop_connect_rate=resnet_params.init_drop_connect_rate, activation=resnet_params.activation) elif params.architecture.backbone == 'spinenet': spinenet_params = params.spinenet block_specs_list = None if spinenet_params.block_specs: block_specs_list = json.loads(spinenet_params.block_specs) backbone_fn = spinenet.SpineNet( block_specs=spinenet.build_block_specs(block_specs_list), min_level=spinenet_params.min_level, max_level=spinenet_params.max_level, endpoints_num_filters=spinenet_params.endpoints_num_filters, resample_alpha=spinenet_params.resample_alpha, use_native_resize_op=spinenet_params.use_native_resize_op, block_repeats=spinenet_params.block_repeats, filter_size_scale=spinenet_params.filter_size_scale, activation=spinenet_params.activation, batch_norm_relu=batch_norm_relu_generator( spinenet_params.batch_norm, activation=spinenet_params.activation), init_drop_connect_rate=spinenet_params.init_drop_connect_rate) else: raise ValueError('Backbone model %s is not supported.' % params.architecture.backbone) return backbone_fn
def backbone_generator(params): """Generator function for various backbone models.""" if params.architecture.backbone == 'resnet': resnet_params = params.resnet backbone_fn = resnet.Resnet( resnet_depth=resnet_params.resnet_depth, dropblock=dropblock_generator(resnet_params.dropblock), batch_norm_relu=batch_norm_relu_generator(resnet_params.batch_norm)) else: raise ValueError('Backbone model %s is not supported.' % params.architecture.backbone) return backbone_fn
def backbone_generator(params): """Generator function for various backbone models.""" if params.architecture.backbone == 'resnet': resnet_params = params.resnet backbone_fn = resnet.Resnet( resnet_depth=resnet_params.resnet_depth, dropblock=dropblock_generator(params.dropblock), activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=resnet_params.init_drop_connect_rate) elif params.architecture.backbone == 'spinenet': spinenet_params = params.spinenet block_specs_list = None if spinenet_params.block_specs: block_specs_list = json.loads(spinenet_params.block_specs) backbone_fn = spinenet.spinenet_builder( model_id=spinenet_params.model_id, min_level=params.architecture.min_level, max_level=params.architecture.max_level, block_specs=spinenet.build_block_specs(block_specs_list), use_native_resize_op=spinenet_params.use_native_resize_op, activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=spinenet_params.init_drop_connect_rate) elif params.architecture.backbone == 'spinenet_mbconv': spinenet_mbconv_params = params.spinenet_mbconv block_specs_list = None if spinenet_mbconv_params.block_specs: block_specs_list = json.loads(spinenet_mbconv_params.block_specs) backbone_fn = spinenet_mbconv.spinenet_mbconv_builder( model_id=spinenet_mbconv_params.model_id, min_level=params.architecture.min_level, max_level=params.architecture.max_level, block_specs=spinenet_mbconv.build_block_specs(block_specs_list), use_native_resize_op=spinenet_mbconv_params.use_native_resize_op, se_ratio=spinenet_mbconv_params.se_ratio, activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=spinenet_mbconv_params. init_drop_connect_rate) else: raise ValueError('Backbone model %s is not supported.' % params.architecture.backbone) return backbone_fn
def backbone_generator(params): """Generator function for various backbone models.""" if params.architecture.backbone == 'resnet': resnet_params = params.resnet backbone_fn = resnet.Resnet( resnet_depth=resnet_params.resnet_depth, dropblock=dropblock_generator(params.dropblock), activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=resnet_params.init_drop_connect_rate, space_to_depth_block_size=params.architecture. space_to_depth_block_size) elif params.architecture.backbone == 'spinenet': spinenet_params = params.spinenet backbone_fn = spinenet.spinenet_builder( model_id=spinenet_params.model_id, min_level=params.architecture.min_level, max_level=params.architecture.max_level, use_native_resize_op=spinenet_params.use_native_resize_op, activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=spinenet_params.init_drop_connect_rate) elif params.architecture.backbone == 'spinenet_mbconv': spinenet_mbconv_params = params.spinenet_mbconv backbone_fn = spinenet_mbconv.spinenet_mbconv_builder( model_id=spinenet_mbconv_params.model_id, min_level=params.architecture.min_level, max_level=params.architecture.max_level, use_native_resize_op=spinenet_mbconv_params.use_native_resize_op, se_ratio=spinenet_mbconv_params.se_ratio, activation=params.batch_norm_activation.activation, batch_norm_activation=batch_norm_activation_generator( params.batch_norm_activation), init_drop_connect_rate=spinenet_mbconv_params. init_drop_connect_rate) elif 'efficientnet' in params.architecture.backbone: backbone_fn = efficientnet.Efficientnet(params.architecture.backbone) else: raise ValueError('Backbone model %s is not supported.' % params.architecture.backbone) return backbone_fn
def backbone_generator(params): """Generator function for various backbone models.""" if params.architecture.backbone == 'resnet': resnet_params = params.resnet backbone_fn = resnet.Resnet(resnet_depth=resnet_params.resnet_depth, dropblock=dropblock_generator( resnet_params.dropblock), batch_norm_relu=batch_norm_relu_generator( resnet_params.batch_norm)) elif params.architecture.backbone == 'seresnext': resnet_params = params.resnet backbone_fn = seresnext.SEResNeXt(blocks=resnet_params.resnet_depth) elif params.architecture.backbone.startswith('efficientnet-b'): backbone_fn = efficientnet_builder.effnet_generator( params.architecture.backbone) else: raise ValueError('Backbone model %s is not supported.' % params.architecture.backbone) return backbone_fn