Team Ai
Apppublic

Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
build.py26 linesDownload Raw Back to meta_arch
1# Copyright (c) Facebook, Inc. and its affiliates.2import torch3 4from detectron2.utils.logger import _log_api_usage5from detectron2.utils.registry import Registry6 7META_ARCH_REGISTRY = Registry("META_ARCH")  # noqa F401 isort:skip8META_ARCH_REGISTRY.__doc__ = """9Registry for meta-architectures, i.e. the whole model.10 11The registered object will be called with `obj(cfg)`12and expected to return a `nn.Module` object.13"""14 15 16def build_model(cfg):17    """18    Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``.19    Note that it does not load any weights from ``cfg``.20    """21    meta_arch = cfg.MODEL.META_ARCHITECTURE22    model = META_ARCH_REGISTRY.get(meta_arch)(cfg)23    model.to(torch.device(cfg.MODEL.DEVICE))24    _log_api_usage("modeling.meta_arch." + meta_arch)25    return model26