(config, checkpoint=None, device='cuda:0')
return model
Initialize a detector from config file.

    Args:
        config (str or :obj:`mmcv.Config`): Config file path or the config
            object.
        checkpoint (str, optional): Checkpoint path. If left as None, the model
            will not load any weights.

    Returns:
        nn.Module: The constructed detector.
Initialize a detector from config file.
Initialize a detector from config file .
def init_detector(config, checkpoint=None, device='cuda:0'):
    """Initialize a detector from config file.

    Args:
        config (str or :obj:`mmcv.Config`): Config file path or the config
            object.
        checkpoint (str, optional): Checkpoint path. If left as None, the model
            will not load any weights.

    Returns:
        nn.Module: The constructed detector.
    """
    if isinstance(config, str):
        config = mmcv.Config.fromfile(config)
    elif not isinstance(config, mmcv.Config):
        raise TypeError('config must be a filename or Config object, '
                        'but got {}'.format(type(config)))
    config.model.pretrained = None
    model = build_detector(config.model, test_cfg=config.test_cfg)
    if checkpoint is not None:
        checkpoint = load_checkpoint(model, checkpoint)
        if 'CLASSES' in checkpoint['meta']:
            model.CLASSES = checkpoint['meta']['CLASSES']
        else:
            warnings.warn('Class names are not saved in the checkpoint\'s '
                          'meta data, use COCO classes by default.')
            model.CLASSES = get_classes('coco')
    model.cfg = config  # save the config in the model for convenience
    model.to(device)
    model.eval()
    return model
def init_detector ( config , checkpoint = None , device = 'cuda:0' ) : if isinstance ( config , str ) : config = mmcv . Config . fromfile ( config ) elif not isinstance ( config , mmcv . Config ) : raise TypeError ( 'config must be a filename or Config object, ' 'but got {}' . format ( type ( config ) ) ) config . model . pretrained = None model = build_detector ( config . model , test_cfg = config . test_cfg ) if checkpoint is not None : checkpoint = load_checkpoint ( model , checkpoint ) if 'CLASSES' in checkpoint [ 'meta' ] : model . CLASSES = checkpoint [ 'meta' ] [ 'CLASSES' ] else : warnings . warn ( 'Class names are not saved in the checkpoint\'s ' 'meta data, use COCO classes by default.' ) model . CLASSES = get_classes ( 'coco' ) model . cfg = config # save the config in the model for convenience model . to ( device ) model . eval ( ) return model