Safemotion Lib
Loading...
Searching...
No Matches
build.py
Go to the documentation of this file.
1# encoding: utf-8
2"""
3@author: liaoxingyu
4@contact: sherlockliao01@gmail.com
5"""
6import torch
7
8from fastreid.utils.registry import Registry
9
10META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip
11META_ARCH_REGISTRY.__doc__ = """
12Registry for meta-architectures, i.e. the whole model.
13The registered object will be called with `obj(cfg)`
14and expected to return a `nn.Module` object.
15"""
16
17
18def build_model(cfg, device=None):
19 """
20 Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``.
21 Note that it does not load any weights from ``cfg``.
22 """
23 meta_arch = cfg.MODEL.META_ARCHITECTURE
24 model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
25 model.to(torch.device(cfg.MODEL.DEVICE))
26 return model
build_model(cfg, device=None)
Definition build.py:18