-
Notifications
You must be signed in to change notification settings - Fork 36
/
net.py
39 lines (26 loc) · 997 Bytes
/
net.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
from cvpods.layers import ShapeSpec
from cvpods.modeling.anchor_generator import ShiftGenerator
from cvpods.modeling.backbone import Backbone
from cvpods.modeling.backbone.fpn import build_retinanet_resnet_fpn_p5_backbone
from fcos import FCOS
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 = build_retinanet_resnet_fpn_p5_backbone(cfg, input_shape)
assert isinstance(backbone, Backbone)
return backbone
def build_shift_generator(cfg, input_shape):
return ShiftGenerator(cfg, input_shape)
def build_model(cfg):
cfg.build_backbone = build_backbone
cfg.build_shift_generator = build_shift_generator
model = FCOS(cfg)
logger = logging.getLogger(__name__)
logger.info("Model:\n{}".format(model))
return model