當前位置: 首頁>>代碼示例>>Python>>正文


Python core.config方法代碼示例

本文整理匯總了Python中caffe2.python.core.config方法的典型用法代碼示例。如果您正苦於以下問題:Python core.config方法的具體用法?Python core.config怎麽用?Python core.config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在caffe2.python.core的用法示例。


在下文中一共展示了core.config方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure_bbox_reg_weights

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def configure_bbox_reg_weights(model, saved_cfg):
    """Compatibility for old models trained with bounding box regression
    mean/std normalization (instead of fixed weights).
    """
    if 'MODEL' not in saved_cfg or 'BBOX_REG_WEIGHTS' not in saved_cfg.MODEL:
        logger.warning('Model from weights file was trained before config key '
                       'MODEL.BBOX_REG_WEIGHTS was added. Forcing '
                       'MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.) to ensure '
                       'correct **inference** behavior.')
        # Generally we don't allow modifying the config, but this is a one-off
        # hack to support some very old models
        is_immutable = cfg.is_immutable()
        cfg.immutable(False)
        cfg.MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.)
        cfg.immutable(is_immutable)
        logger.info('New config:')
        logger.info(pprint.pformat(cfg))
        assert not model.train, (
            'This model was trained with an older version of the code that '
            'used bounding box regression mean/std normalization. It can no '
            'longer be used for training. To upgrade it to a trainable model '
            'please use fb/compat/convert_bbox_reg_normalized_model.py.'
        ) 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:25,代碼來源:net.py

示例2: parse_args

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def parse_args():
    parser = argparse.ArgumentParser(
        description='Train a network with Detectron'
    )
    parser.add_argument(
        '--cfg',
        dest='cfg_file',
        help='Config file for training (and optionally testing)',
        default=None,
        type=str
    )
    parser.add_argument(
        'opts',
        help='See lib/core/config.py for all options',
        default=None,
        nargs=argparse.REMAINDER
    )
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    return parser.parse_args() 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:23,代碼來源:test_proposal_target.py

示例3: configure_bbox_reg_weights

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def configure_bbox_reg_weights(model, saved_cfg):
    """Compatibility for old models trained with bounding box regression
    mean/std normalization (instead of fixed weights).
    """
    if 'MODEL' not in saved_cfg or 'BBOX_REG_WEIGHTS' not in saved_cfg.MODEL:
        logger.warning('Model from weights file was trained before config key '
                       'MODEL.BBOX_REG_WEIGHTS was added. Forcing '
                       'MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.) to ensure '
                       'correct **inference** behavior.')
        cfg.MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.)
        logger.info('New config:')
        logger.info(pprint.pformat(cfg))
        assert not model.train, (
            'This model was trained with an older version of the code that '
            'used bounding box regression mean/std normalization. It can no '
            'longer be used for training. To upgrade it to a trainable model '
            'please use fb/compat/convert_bbox_reg_normalized_model.py.'
        ) 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:20,代碼來源:net.py

示例4: parse_args

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def parse_args():
    parser = argparse.ArgumentParser(description='Run DetectandTrack on a single video and visualize the results')
    parser.add_argument(
        '--cfg', '-c', dest='cfg_file', required=True,
        help='Config file to run')
    parser.add_argument(
        '--video', '-v', dest='video_path',
        help='Path to Video',
        required=True)
    parser.add_argument(
        '--output', '-o', dest='out_path',
        help='Path to Output')
    parser.add_argument(
        'opts', help='See lib/core/config.py for all options', default=None,
        nargs=argparse.REMAINDER)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    return parser.parse_args() 
開發者ID:facebookresearch,項目名稱:DetectAndTrack,代碼行數:21,代碼來源:test_on_single_video.py

示例5: configure_bbox_reg_weights

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def configure_bbox_reg_weights(model, saved_cfg):
    if 'MODEL' not in saved_cfg or 'BBOX_REG_WEIGHTS' not in saved_cfg.MODEL:
        logger.warning('Model from weights file was trained before config key '
                       'MODEL.BBOX_REG_WEIGHTS was added. Forcing '
                       'MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.) to ensure '
                       'correct **inference** behavior.')
        cfg.MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.)
        logger.info('New config:')
        logger.info(pprint.pformat(cfg))
        assert not model.train, 'This mode should only be used for inference' 
開發者ID:facebookresearch,項目名稱:DetectAndTrack,代碼行數:12,代碼來源:net.py

示例6: parse_args

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--loaders', dest='num_loaders',
        help='Number of data loading threads',
        default=4, type=int)
    parser.add_argument(
        '--dequeuers', dest='num_dequeuers',
        help='Number of dequeuers',
        default=1, type=int)
    parser.add_argument(
        '--minibatch-queue-size', dest='minibatch_queue_size',
        help='Size of minibatch queue',
        default=64, type=int)
    parser.add_argument(
        '--blobs-queue-capacity', dest='blobs_queue_capacity',
        default=8, type=int)
    parser.add_argument(
        '--num-batches', dest='num_batches',
        help='Number of minibatches to run',
        default=200, type=int)
    parser.add_argument(
        '--sleep', dest='sleep_time',
        help='Seconds sleep to emulate a network running',
        default=0.1, type=float)
    parser.add_argument(
        '--cfg', dest='cfg_file', help='optional config file', default=None,
        type=str)
    parser.add_argument(
        '--x-factor', dest='x_factor', help='simulates x-factor more GPUs',
        default=1, type=int)
    parser.add_argument(
        '--profiler', dest='profiler', help='profile minibatch load time',
        action='store_true')
    parser.add_argument(
        'opts', help='See lib/core/config.py for all options', default=None,
        nargs=argparse.REMAINDER)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    args = parser.parse_args()
    return args 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:44,代碼來源:data_loader_benchmark.py

示例7: parse_args

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def parse_args():
    parser = argparse.ArgumentParser(
        description='Convert a trained network to pb format'
    )
    parser.add_argument(
        '--cfg', dest='cfg_file', help='optional config file', default=None,
        type=str)
    parser.add_argument(
        '--net_name', dest='net_name', help='optional name for the net',
        default="detectron", type=str)
    parser.add_argument(
        '--out_dir', dest='out_dir', help='output dir', default=None,
        type=str)
    parser.add_argument(
        '--test_img', dest='test_img',
        help='optional test image, used to verify the model conversion',
        default=None,
        type=str)
    parser.add_argument(
        '--fuse_af', dest='fuse_af', help='1 to fuse_af',
        default=1,
        type=int)
    parser.add_argument(
        '--device', dest='device',
        help='Device to run the model on',
        choices=['cpu', 'gpu'],
        default='cpu',
        type=str)
    parser.add_argument(
        '--net_execution_type', dest='net_execution_type',
        help='caffe2 net execution type',
        choices=['simple', 'dag'],
        default='simple',
        type=str)
    parser.add_argument(
        '--use_nnpack', dest='use_nnpack',
        help='Use nnpack for conv',
        default=1,
        type=int)
    parser.add_argument(
        'opts', help='See lib/core/config.py for all options', default=None,
        nargs=argparse.REMAINDER)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    ret = parser.parse_args()
    ret.out_dir = os.path.abspath(ret.out_dir)
    if ret.device == 'gpu' and ret.use_nnpack:
        logger.warn('Should not use mobile engine for gpu model.')
        ret.use_nnpack = 0

    return ret 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:54,代碼來源:convert_pkl_to_pb.py

示例8: main

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def main():
    workspace.GlobalInit(['caffe2', '--caffe2_log_level=0'])
    args = parse_args()
    logger.info('Called with args:')
    logger.info(args)
    if args.cfg_file is not None:
        merge_cfg_from_file(args.cfg_file)
    if args.opts is not None:
        merge_cfg_from_list(args.opts)
    cfg.NUM_GPUS = 1
    assert_and_infer_cfg()
    logger.info('Conerting model with config:')
    logger.info(pprint.pformat(cfg))

    assert not cfg.MODEL.KEYPOINTS_ON, "Keypoint model not supported."
    assert not cfg.MODEL.MASK_ON, "Mask model not supported."
    assert not cfg.FPN.FPN_ON, "FPN not supported."
    assert not cfg.RETINANET.RETINANET_ON, "RetinaNet model not supported."

    # load model from cfg
    model, blobs = load_model(args)

    net = core.Net('')
    net.Proto().op.extend(copy.deepcopy(model.net.Proto().op))
    net.Proto().external_input.extend(
        copy.deepcopy(model.net.Proto().external_input))
    net.Proto().external_output.extend(
        copy.deepcopy(model.net.Proto().external_output))
    net.Proto().type = args.net_execution_type
    net.Proto().num_workers = 1 if args.net_execution_type == 'simple' else 4

    # Reset the device_option, change to unscope name and replace python operators
    convert_net(args, net.Proto(), blobs)

    # add operators for bbox
    add_bbox_ops(args, net, blobs)

    if args.fuse_af:
        print('Fusing affine channel...')
        net, blobs = mutils.fuse_net_affine(
            net, blobs)

    if args.use_nnpack:
        mutils.update_mobile_engines(net.Proto())

    # generate init net
    empty_blobs = ['data', 'im_info']
    init_net = gen_init_net(net, blobs, empty_blobs)

    if args.device == 'gpu':
        [net, init_net] = convert_model_gpu(args, net, init_net)

    net.Proto().name = args.net_name
    init_net.Proto().name = args.net_name + "_init"

    if args.test_img is not None:
        verify_model(args, [net, init_net], args.test_img)

    _save_models(net, init_net, args) 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:61,代碼來源:convert_pkl_to_pb.py

示例9: parse_args

# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import config [as 別名]
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--loaders', dest='num_loaders',
        help='Number of data loading threads',
        default=4, type=int)
    parser.add_argument(
        '--dequeuers', dest='num_dequeuers',
        help='Number of dequeuers',
        default=1, type=int)
    parser.add_argument(
        '--minibatch-queue-size', dest='minibatch_queue_size',
        help='Size of minibatch queue',
        default=64, type=int)
    parser.add_argument(
        '--blobs-queue-capacity', dest='blobs_queue_capacity',
        default=8, type=int)
    parser.add_argument(
        '--num-batches', dest='num_batches',
        help='Number of minibatches to run',
        default=500, type=int)
    parser.add_argument(
        '--sleep', dest='sleep_time',
        help='Seconds sleep to emulate a network running',
        default=0.1, type=float)
    parser.add_argument(
        '--cfg', dest='cfg_file', help='optional config file', default=None,
        type=str)
    parser.add_argument(
        '--x-factor', dest='x_factor', help='simulates x-factor more GPUs',
        default=1, type=int)
    parser.add_argument(
        '--profiler', dest='profiler', help='profile minibatch load time',
        action='store_true')
    parser.add_argument(
        'opts', help='See lib/core/config.py for all options', default=None,
        nargs=argparse.REMAINDER)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    args = parser.parse_args()
    return args 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:44,代碼來源:data_loader_benchmark.py


注:本文中的caffe2.python.core.config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。