Download detectron2/modeling/backbone/build.py from Navyssh/StyleSync: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/Navyssh/StyleSync/resolve/refs%2Fpr%2F1/detectron2/modeling/backbone/build.py
- Command line
-
hf download hf://Navyssh/StyleSync@refs/pr/1/detectron2/modeling/backbone/build.py
-
curl -L -o build.py https://huggingface.co/Navyssh/StyleSync/resolve/refs%2Fpr%2F1/detectron2/modeling/backbone/build.py
1.02 kB
| # Copyright (c) Facebook, Inc. and its affiliates. | |
| from detectron2.layers import ShapeSpec | |
| from detectron2.utils.registry import Registry | |
| from .backbone import Backbone | |
| BACKBONE_REGISTRY = Registry("BACKBONE") | |
| BACKBONE_REGISTRY.__doc__ = """ | |
| Registry for backbones, which extract feature maps from images | |
| The registered object must be a callable that accepts two arguments: | |
| 1. A :class:`detectron2.config.CfgNode` | |
| 2. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification. | |
| Registered object must return instance of :class:`Backbone`. | |
| """ | |
| def build_backbone(cfg, input_shape=None): | |
| """ | |
| Build a backbone from `cfg.MODEL.BACKBONE.NAME`. | |
| Returns: | |
| an instance of :class:`Backbone` | |
| """ | |
| if input_shape is None: | |
| input_shape = ShapeSpec(channels=len(cfg.MODEL.PIXEL_MEAN)) | |
| backbone_name = cfg.MODEL.BACKBONE.NAME | |
| backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg, input_shape) | |
| assert isinstance(backbone, Backbone) | |
| return backbone | |