当前位置: 首页>>代码示例>>Python>>正文


Python generate.imdb_proposals方法代码示例

本文整理汇总了Python中rpn.generate.imdb_proposals方法的典型用法代码示例。如果您正苦于以下问题:Python generate.imdb_proposals方法的具体用法?Python generate.imdb_proposals怎么用?Python generate.imdb_proposals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rpn.generate的用法示例。


在下文中一共展示了generate.imdb_proposals方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rpn_generate

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate(queue=None, imdb_name=None, rpn_model_path=None, cfg=None,
                 rpn_test_prototxt=None):
    """Use a trained RPN to generate proposals.
    """

    cfg.TEST.RPN_PRE_NMS_TOP_N = -1     # no pre NMS filtering
    cfg.TEST.RPN_POST_NMS_TOP_N = 2000  # limit top boxes after NMS
    print 'RPN model: {}'.format(rpn_model_path)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    # NOTE: the matlab implementation computes proposals on flipped images, too.
    # We compute them on the image once and then flip the already computed
    # proposals. This might cause a minor loss in mAP (less proposal jittering).
    imdb = get_imdb(imdb_name)
    print 'Loaded dataset `{:s}` for proposal generation'.format(imdb.name)

    # Load RPN and configure output directory
    rpn_net = caffe.Net(rpn_test_prototxt, rpn_model_path, caffe.TEST)
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Generate proposals on the imdb
    rpn_proposals = imdb_proposals(rpn_net, imdb)
    # Write proposals to disk and send the proposal file path through the
    # multiprocessing queue
    rpn_net_name = os.path.splitext(os.path.basename(rpn_model_path))[0]
    rpn_proposals_path = os.path.join(
        output_dir, rpn_net_name + '_proposals.pkl')
    with open(rpn_proposals_path, 'wb') as f:
        cPickle.dump(rpn_proposals, f, cPickle.HIGHEST_PROTOCOL)
    print 'Wrote RPN proposals to {}'.format(rpn_proposals_path)
    queue.put({'proposal_path': rpn_proposals_path}) 
开发者ID:xiaolonw,项目名称:adversarial-frcnn,代码行数:37,代码来源:train_faster_rcnn_alt_opt.py

示例2: rpn_generate

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate(queue=None, imdb_name=None, rpn_model_path=None, cfg=None,
                 rpn_test_prototxt=None):
    """Use a trained RPN to generate proposals.
    """

    cfg.TEST.RPN_PRE_NMS_TOP_N = -1     # no pre NMS filtering
    cfg.TEST.RPN_POST_NMS_TOP_N = 2000  # limit top boxes after NMS
    print 'RPN model: {}'.format(rpn_model_path)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    # NOTE: the matlab implementation computes proposals on flipped images, too.
    # We compute them on the image once and then flip the already computed
    # proposals. This might cause a minor loss in mAP (less proposal jittering).
    imdb = get_imdb(imdb_name)
    print 'Loaded dataset `{:s}` for proposal generation'.format(imdb.name)

    # Load RPN and configure output directory
    rpn_net = caffe.Net(rpn_test_prototxt, rpn_model_path, caffe.TEST)
    output_dir = get_output_dir(imdb, None)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Generate proposals on the imdb
    rpn_proposals = imdb_proposals(rpn_net, imdb)
    # Write proposals to disk and send the proposal file path through the
    # multiprocessing queue
    rpn_net_name = os.path.splitext(os.path.basename(rpn_model_path))[0]
    rpn_proposals_path = os.path.join(
        output_dir, rpn_net_name + '_proposals.pkl')
    with open(rpn_proposals_path, 'wb') as f:
        cPickle.dump(rpn_proposals, f, cPickle.HIGHEST_PROTOCOL)
    print 'Wrote RPN proposals to {}'.format(rpn_proposals_path)
    queue.put({'proposal_path': rpn_proposals_path}) 
开发者ID:joeking11829,项目名称:py-faster-rcnn-tk1,代码行数:37,代码来源:train_faster_rcnn_alt_opt.py

示例3: rpn_generate_single_gpu

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate_single_gpu(prototxt, caffemodel, imdb, rank, gpus, output_dir):
    cfg.GPU_ID = gpus[rank]
    caffe.set_mode_gpu()
    caffe.set_device(cfg.GPU_ID)
    net = caffe.Net(prototxt, caffemodel, caffe.TEST)
    imdb_boxes = imdb_proposals(net, imdb, rank, len(gpus), output_dir) 
开发者ID:tianzhi0549,项目名称:py-faster-rcnn-resnet-imagenet,代码行数:8,代码来源:rpn_generate.py

示例4: rpn_generate

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate(queue=None, imdb_name=None, rpn_model_path=None, cfg=None,
                 rpn_test_prototxt=None, output_dir=None, part_id=None):
    """Use a trained RPN to generate proposals.
    """

    cfg.TEST.RPN_PRE_NMS_TOP_N = -1     # no pre NMS filtering
    cfg.TEST.RPN_POST_NMS_TOP_N = 2000  # limit top boxes after NMS
    print 'RPN model: {}'.format(rpn_model_path)
    print('Using config:')
    pp = pprint.PrettyPrinter(depth=6)
    pp.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    # NOTE: the matlab implementation computes proposals on flipped images, too.
    # We compute them on the image once and then flip the already computed
    # proposals. This might cause a minor loss in mAP (less proposal jittering).
    imdb = get_imdb(imdb_name)
    print 'Loaded dataset `{:s}` for proposal generation'.format(imdb.name)

    # Load RPN and configure output directory
    rpn_net = caffe.Net(rpn_test_prototxt, rpn_model_path, caffe.TEST)
    if output_dir==None:
        output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Generate proposals on the imdb
    rpn_proposals = imdb_proposals(rpn_net, imdb)
    # Write proposals to disk and send the proposal file path through the
    # multiprocessing queue
    rpn_net_name = os.path.splitext(os.path.basename(rpn_model_path))[0]
    rpn_proposals_path = os.path.join(
        output_dir, rpn_net_name + ('_'+part_id if part_id != None else '')+'_proposals.pkl')
    with open(rpn_proposals_path, 'wb') as f:
        cPickle.dump(rpn_proposals, f, cPickle.HIGHEST_PROTOCOL)
    print 'Wrote RPN proposals to {}'.format(rpn_proposals_path)
    queue.put({'proposal_path': rpn_proposals_path, 'rpn_net': rpn_net_name}) 
开发者ID:djdam,项目名称:faster-rcnn-scenarios,代码行数:39,代码来源:train.py

示例5: rpn_generate

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate(queue=None, imdb_name=None, rpn_model_path=None, cfg=None,
                 rpn_test_prototxt=None):
    """Use a trained RPN to generate proposals.
    """

    cfg.TEST.RPN_PRE_NMS_TOP_N = 6000     # no pre NMS filtering
    cfg.TEST.RPN_POST_NMS_TOP_N = 300  # limit top boxes after NMS
    print 'RPN model: {}'.format(rpn_model_path)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    # NOTE: the matlab implementation computes proposals on flipped images, too.
    # We compute them on the image once and then flip the already computed
    # proposals. This might cause a minor loss in mAP (less proposal jittering).
    imdb = get_imdb(imdb_name)
    print 'Loaded dataset `{:s}` for proposal generation'.format(imdb.name)

    # Load RPN and configure output directory
    rpn_net = caffe.Net(rpn_test_prototxt, rpn_model_path, caffe.TEST)
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    rpn_net_name = os.path.splitext(os.path.basename(rpn_model_path))[0]
    rpn_proposals_path = os.path.join(
        output_dir, rpn_net_name + '_proposals.pkl')

    # Generate proposals on the imdb

    # Write proposals to disk and send the proposal file path through the
    # multiprocessing queue
    if not os.path.exists(rpn_proposals_path):
        rpn_proposals = imdb_proposals(rpn_net, imdb)
        with open(rpn_proposals_path, 'wb') as f:
            cPickle.dump(rpn_proposals, f, cPickle.HIGHEST_PROTOCOL)
    queue.put({'proposal_path': rpn_proposals_path})
    print 'Wrote RPN proposals to {}'.format(rpn_proposals_path) 
开发者ID:YuwenXiong,项目名称:py-R-FCN,代码行数:40,代码来源:train_rfcn_alt_opt_5stage.py

示例6: rpn_generate

# 需要导入模块: from rpn import generate [as 别名]
# 或者: from rpn.generate import imdb_proposals [as 别名]
def rpn_generate(gpus, queue=None, imdb_name=None, rpn_model_path=None, cfg=None,
                 rpn_test_prototxt=None):
    """Use a trained RPN to generate proposals.
    """
    def rpn_generate_signle_gpu(rank):
        cfg.GPU_ID=gpus[rank]
        
        print('Using config:')
        pprint.pprint(cfg)

        import caffe
        np.random.seed(cfg.RNG_SEED)
        caffe.set_random_seed(cfg.RNG_SEED)
        # set up caffe
        caffe.set_mode_gpu()
        caffe.set_device(cfg.GPU_ID)

        # Load RPN and configure output directory
        rpn_net = caffe.Net(rpn_test_prototxt, rpn_model_path, caffe.TEST)
        
        # Generate proposals on the imdb
        rpn_proposals = imdb_proposals(rpn_net, imdb, rank, len(gpus), output_dir)


    cfg.TEST.RPN_PRE_NMS_TOP_N = -1     # no pre NMS filtering
    cfg.TEST.RPN_POST_NMS_TOP_N = 2000  # limit top boxes after NMS
    
    print 'RPN model: {}'.format(rpn_model_path)
    imdb = get_imdb(imdb_name)
    
    output_dir = os.path.join(get_output_dir(imdb), "proposals")
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # NOTE: the matlab implementation computes proposals on flipped images, too.
        # We compute them on the image once and then flip the already computed
        # proposals. This might cause a minor loss in mAP (less proposal jittering).
    print 'Loaded dataset `{:s}` for proposal generation'.format(imdb.name)
    
    procs=[]
    for rank in range(len(gpus)):
        p = mp.Process(target=rpn_generate_signle_gpu,
                    args=(rank, ))
        p.daemon = True
        p.start()
        procs.append(p)
    for p in procs:
        p.join()
    queue.put({'proposal_path': output_dir}) 
开发者ID:tianzhi0549,项目名称:py-faster-rcnn-resnet-imagenet,代码行数:51,代码来源:train_faster_rcnn_alt_opt.py


注:本文中的rpn.generate.imdb_proposals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。