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


Python train.train_net方法代碼示例

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


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

示例1: train_fast_rcnn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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

示例2: train_rpn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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

示例3: train_rpn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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

示例4: train_rfcn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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:ucloud,項目名稱:uai-sdk,代碼行數:38,代碼來源:train_rfcn_alt_opt_5stage.py

示例5: train_rpn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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

示例6: train_fast_rcnn

# 需要導入模塊: from fast_rcnn import train [as 別名]
# 或者: from fast_rcnn.train import train_net [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.train.train_net方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。