Ejemplo n.º 1
0
    def __init__(self, model_path):
        # self.net_name = net_name
        self.model_path = model_path

        self.num_classes = 81
        self.cuda = torch.cuda.is_available()

        self.label_map_list = list(coco_label_map.values())

        self._init_model()
Ejemplo n.º 2
0
config_f = 'configs/m2det512_vgg.py'
checkpoint_path = 'weights/m2det512_vgg_coco_epoch_14.pth'

# config_f = 'configs/m2det512_vgg_helmet.py'
# checkpoint_path = 'weights/m2det512_vgg_helmet_epoch_199.pth'
config_f = 'configs/m2det512_vgg_helmet.py'
# checkpoint_path = 'weights/m2det512_vgg_helmet_epoch_550.pth'

# config_f = 'configs/m2det320_vgg_helmet.py'
# checkpoint_path = 'weights/m2det320_vgg_helmet_epoch_246.pth'

# checkpoint_path = 'weights/M2Det_COCO_size320_netresnet101_epoch0.pth'
# config_f = 'configs/m2det320_resnet101.py'


classes = list(coco_label_map.values())
# classes = HELMET_CLASSES


def demo(v_f):
    cfg = Config.fromfile(config_f)
    anchor_config = anchors(cfg)
    priorbox = PriorBox(anchor_config)
    net = build_net('test',
                    size=cfg.model.input_size,
                    config=cfg.model.m2det_config)
    init_net(net, cfg, checkpoint_path)
    net.eval().to(device)
    with torch.no_grad():
        priors = priorbox.forward().to(device)
    _preprocess = BaseTransform(