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


Python config.get_output_dir方法代码示例

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


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

示例1: test_rpn_msr_net

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def test_rpn_msr_net(net, imdb):

    output_dir = get_output_dir(imdb, net)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    det_file = os.path.join(output_dir, 'detections.pkl')
    if os.path.exists(det_file):
        with open(det_file, 'rb') as fid:
            all_boxes = cPickle.load(fid)
        print 'Detections loaded from {}'.format(det_file)

        print 'Evaluating detections'
        imdb.evaluate_proposals_msr(all_boxes, output_dir)
        return

    # Generate proposals on the imdb
    all_boxes = imdb_proposals_det(net, imdb)

    det_file = os.path.join(output_dir, 'detections.pkl')
    with open(det_file, 'wb') as f:
        cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL)

    print 'Evaluating detections'
    imdb.evaluate_proposals_msr(all_boxes, output_dir) 
开发者ID:tanshen,项目名称:SubCNN,代码行数:27,代码来源:test.py

示例2: test_net_VOC

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def test_net_VOC(net, imdb):
    """Test a Fast R-CNN network on an image database."""
    num_images = len(imdb.image_index)
    # heuristic: keep an average of 40 detections per class per images prior
    # to NMS

    output_dir = get_output_dir(imdb, net)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    # timers
    _t = {'im_cls' : Timer(), 'misc' : Timer()}

    roidb = imdb.roidb
    for i in xrange(num_images):
        im = cv2.imread(imdb.image_path_at(i))
        _t['im_cls'].tic()
        scores = im_cls(net, im, roidb[i]['boxes'])
        # scores = np.max(scores, axis=0)
        scores = np.mean(scores, axis=0)
        _t['im_cls'].toc()

        _t['misc'].tic()
        for j in xrange(imdb.num_classes):
            cls_file = os.path.join(output_dir, 'comp2_cls_test_'+imdb.classes[j]+'.txt')
            with open(cls_file, 'a') as f:
                f.write(imdb.image_index[i]+' '+str(scores[j])+'\n')
            
        _t['misc'].toc()

        print 'im_cls: {:d}/{:d} {:.3f}s {:.3f}s' \
              .format(i + 1, num_images, _t['im_cls'].average_time,
                      _t['misc'].average_time) 
开发者ID:ppengtang,项目名称:dpl,代码行数:35,代码来源:test.py

示例3: train_rpn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_rpn(queue=None, imdb_name=None, init_model=None, solver=None,
              max_iters=None, cfg=None):
    """Train a Region Proposal Network in a separate training process.
    """

    # Not using any proposals, just ground-truth boxes
    cfg.TRAIN.HAS_RPN = True
    cfg.TRAIN.BBOX_REG = False  # applies only to Fast R-CNN bbox regression
    cfg.TRAIN.PROPOSAL_METHOD = 'gt'
    cfg.TRAIN.IMS_PER_BATCH = 1
    print 'Init model: {}'.format(init_model)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name)
    print 'roidb len: {}'.format(len(roidb))
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)

    model_paths = train_net(solver, roidb, output_dir,
                            pretrained_model=init_model,
                            max_iters=max_iters)
    # Cleanup all but the final model
    for i in model_paths[:-1]:
        os.remove(i)
    rpn_model_path = model_paths[-1]
    # Send final model path through the multiprocessing queue
    queue.put({'model_path': rpn_model_path}) 
开发者ID:playerkk,项目名称:face-py-faster-rcnn,代码行数:33,代码来源:train_faster_rcnn_alt_opt.py

示例4: rpn_generate

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [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:playerkk,项目名称:face-py-faster-rcnn,代码行数:37,代码来源:train_faster_rcnn_alt_opt.py

示例5: train_fast_rcnn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_fast_rcnn(queue=None, imdb_name=None, init_model=None, solver=None,
                    max_iters=None, cfg=None, rpn_file=None):
    """Train a Fast R-CNN using proposals generated by an RPN.
    """

    cfg.TRAIN.HAS_RPN = False           # not generating prosals on-the-fly
    cfg.TRAIN.PROPOSAL_METHOD = 'rpn'   # use pre-computed RPN proposals instead
    cfg.TRAIN.IMS_PER_BATCH = 2
    print 'Init model: {}'.format(init_model)
    print 'RPN proposals: {}'.format(rpn_file)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name, rpn_file=rpn_file)
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Train Fast R-CNN
    model_paths = train_net(solver, roidb, output_dir,
                            pretrained_model=init_model,
                            max_iters=max_iters)
    # Cleanup all but the final model
    for i in model_paths[:-1]:
        os.remove(i)
    fast_rcnn_model_path = model_paths[-1]
    # Send Fast R-CNN model path over the multiprocessing queue
    queue.put({'model_path': fast_rcnn_model_path}) 
开发者ID:playerkk,项目名称:face-py-faster-rcnn,代码行数:31,代码来源:train_faster_rcnn_alt_opt.py

示例6: train_rpn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_rpn(queue=None, imdb_name=None, init_model=None, solver=None,
              max_iters=None, cfg=None, output_cache=None):
    """Train a Region Proposal Network in a separate training process.
    """

    # Not using any proposals, just ground-truth boxes
    cfg.TRAIN.HAS_RPN = True
    cfg.TRAIN.BBOX_REG = False  # applies only to R-FCN bbox regression
    cfg.TRAIN.PROPOSAL_METHOD = 'gt'
    cfg.TRAIN.IMS_PER_BATCH = 1
    print 'Init model: {}'.format(init_model)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name)
    print 'roidb len: {}'.format(len(roidb))
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    final_caffemodel = os.path.join(output_dir, output_cache)

    if os.path.exists(final_caffemodel):
        queue.put({'model_path': final_caffemodel})
    else:
        model_paths = train_net(solver, roidb, output_dir,
                                pretrained_model=init_model,
                                max_iters=max_iters)
        # Cleanup all but the final model
        for i in model_paths[:-1]:
            os.remove(i)
        rpn_model_path = model_paths[-1]
        # Send final model path through the multiprocessing queue
        shutil.copyfile(rpn_model_path, final_caffemodel)
        queue.put({'model_path': final_caffemodel}) 
开发者ID:ucloud,项目名称:uai-sdk,代码行数:38,代码来源:train_rfcn_alt_opt_5stage.py

示例7: rpn_generate

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [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:ucloud,项目名称:uai-sdk,代码行数:40,代码来源:train_rfcn_alt_opt_5stage.py

示例8: train_rfcn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_rfcn(queue=None, imdb_name=None, init_model=None, solver=None,
                    max_iters=None, cfg=None, rpn_file=None, output_cache=None):
    """Train a R-FCN using proposals generated by an RPN.
    """

    cfg.TRAIN.HAS_RPN = False           # not generating prosals on-the-fly
    cfg.TRAIN.PROPOSAL_METHOD = 'rpn'   # use pre-computed RPN proposals instead
    cfg.TRAIN.IMS_PER_BATCH = 1
    print 'Init model: {}'.format(init_model)
    print 'RPN proposals: {}'.format(rpn_file)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name, rpn_file=rpn_file)
    output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Train R-FCN
    # Send R-FCN model path over the multiprocessing queue
    final_caffemodel = os.path.join(output_dir, output_cache)

    if os.path.exists(final_caffemodel):
        queue.put({'model_path': final_caffemodel})
    else:
        model_paths = train_net(solver, roidb, output_dir,
                                pretrained_model=init_model,
                                max_iters=max_iters)
        # Cleanup all but the final model
        for i in model_paths[:-1]:
            os.remove(i)
        rfcn_model_path = model_paths[-1]
        # Send final model path through the multiprocessing queue
        shutil.copyfile(rfcn_model_path, final_caffemodel)
        queue.put({'model_path': final_caffemodel}) 
开发者ID:YuwenXiong,项目名称:py-R-FCN,代码行数:38,代码来源:train_rfcn_alt_opt_5stage.py

示例9: train_rpn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_rpn(queue=None, imdb_name=None, init_model=None, solver=None,
              max_iters=None, cfg=None, output_dir=None):
    """Train a Region Proposal Network in a separate training process.
    """

    # Not using any proposals, just ground-truth boxes
    cfg.TRAIN.HAS_RPN = True
    cfg.TRAIN.BBOX_REG = False  # applies only to Fast R-CNN bbox regression
    cfg.TRAIN.PROPOSAL_METHOD = 'gt'
    cfg.TRAIN.IMS_PER_BATCH = 1
    print 'Init model: {}'.format(init_model)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name)
    # print 'first image: ',imdb.gt_roidb()
    # print 'roidb len: {}'.format(len(roidb))
    if output_dir==None:
        output_dir = get_output_dir(imdb)
    print 'Output will be saved to `{:s}`'.format(output_dir)
    print 'len roidb=',len(roidb)
    model_paths = train_net(solver, roidb, output_dir,
                            pretrained_model=init_model,
                            max_iters=max_iters)
    # Cleanup all but the final model
    for i in model_paths[:-1]:
        os.remove(i)
    rpn_model_path = model_paths[-1]
    # Send final model path through the multiprocessing queue
    queue.put({'model_path': rpn_model_path}) 
开发者ID:djdam,项目名称:faster-rcnn-scenarios,代码行数:35,代码来源:train.py

示例10: rpn_generate

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [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

示例11: train_fast_rcnn

# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import get_output_dir [as 别名]
def train_fast_rcnn(queue=None, imdb_name=None, init_model=None, solver=None,
                    max_iters=None, cfg=None, rpn_file=None, output_dir=None):
    """Train a Fast R-CNN using proposals generated by an RPN.
    """

    cfg.TRAIN.HAS_RPN = False           # not generating prosals on-the-fly
    cfg.TRAIN.PROPOSAL_METHOD = 'rpn'   # use pre-computed RPN proposals instead
    cfg.TRAIN.IMS_PER_BATCH = 1
    print 'Init model: {}'.format(init_model)
    print 'RPN proposals: {}'.format(rpn_file)
    print('Using config:')
    pprint.pprint(cfg)

    import caffe
    _init_caffe(cfg)

    roidb, imdb = get_roidb(imdb_name, rpn_file=rpn_file)
    if output_dir==None:
        output_dir = get_output_dir(imdb)

    print 'Output will be saved to `{:s}`'.format(output_dir)
    # Train Fast R-CNN
    model_paths = train_net(solver, roidb, output_dir,
                            pretrained_model=init_model,
                            max_iters=max_iters)
    # Cleanup all but the final model
    for i in model_paths[:-1]:
        os.remove(i)
    fast_rcnn_model_path = model_paths[-1]
    # Send Fast R-CNN model path over the multiprocessing queue
    if queue != None:
        queue.put({'model_path': fast_rcnn_model_path}) 
开发者ID:djdam,项目名称:faster-rcnn-scenarios,代码行数:34,代码来源:train.py


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