Arulkumar03/Fox_Sheep_Detector_Computer_Vision_model
0
1# Copyright (c) Facebook, Inc. and its affiliates.2from detectron2.layers import ShapeSpec3from detectron2.utils.registry import Registry4 5from .backbone import Backbone6 7BACKBONE_REGISTRY = Registry("BACKBONE")8BACKBONE_REGISTRY.__doc__ = """9Registry for backbones, which extract feature maps from images10 11The registered object must be a callable that accepts two arguments:12 131. A :class:`detectron2.config.CfgNode`142. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification.15 16Registered object must return instance of :class:`Backbone`.17"""18 19 20def build_backbone(cfg, input_shape=None):21 """22 Build a backbone from `cfg.MODEL.BACKBONE.NAME`.23 24 Returns:25 an instance of :class:`Backbone`26 """27 if input_shape is None:28 input_shape = ShapeSpec(channels=len(cfg.MODEL.PIXEL_MEAN))29 30 backbone_name = cfg.MODEL.BACKBONE.NAME31 backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg, input_shape)32 assert isinstance(backbone, Backbone)33 return backbone34 