Python caffe 模块,set_random_seed() 实例源码

我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用caffe.set_random_seed()

项目:QScode    作者:PierreHao    | 项目源码 | 文件源码
def init_detection_net(self, gpu_id=0, prototxt=None, caffemodel=None):
        """init extraction network"""
        cfg.TEST.HAS_RPN = True  # Use RPN for proposals
        if prototxt is None:
            prototxt = os.path.join(cfg.ROOT_DIR, 'models', NETS['zf'][0],
                            'faster_rcnn_alt_opt', 'faster_rcnn_test.pt')
        if caffemodel is None:
            caffemodel = os.path.join(cfg.ROOT_DIR, 'output/default/train',
                              NETS['zf'][1])

        if not os.path.isfile(caffemodel):
            raise IOError(('{:s} not found.\nDid you run ./data/script/'
                       'fetch_faster_rcnn_models.sh?').format(caffemodel))

        #np.random.seed(cfg.RNG_SEED)
        caffe.set_random_seed(cfg.RNG_SEED)       
        caffe.set_mode_gpu()
        caffe.set_device(gpu_id)        
        self.net_d = caffe.Net(prototxt, caffemodel, caffe.TEST)
项目:adversarial-frcnn    作者:xiaolonw    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:faster-rcnn-resnet    作者:Eniac-Xie    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-faster-rcnn-tk1    作者:joeking11829    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-faster-rcnn-resnet-imagenet    作者:tianzhi0549    | 项目源码 | 文件源码
def train_net(solver_prototxt, roidb, output_dir, nccl_uid, gpus, rank,
        queue, bbox_means, bbox_stds, pretrained_model=None, max_iters=40000):
    """Train a Fast R-CNN network."""
    caffe.set_mode_gpu()
    caffe.set_device(gpus[rank])
    caffe.set_solver_count(len(gpus))
    caffe.set_solver_rank(rank)
    caffe.set_multiprocess(True)
    caffe.set_random_seed(cfg.RNG_SEED)
    sw = SolverWrapper(solver_prototxt, roidb, output_dir, nccl_uid, 
        rank, bbox_means, bbox_stds, pretrained_model=pretrained_model)
    model_paths = sw.train_model(max_iters)
    if rank==0:
        queue.put(model_paths)
项目:face-py-faster-rcnn    作者:playerkk    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:deep-fashion    作者:zuowang    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:RPN    作者:hfut721    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:TattDL    作者:z-harry-sun    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:style_transfer    作者:crowsonkb    | 项目源码 | 文件源码
def run(self):
        """This method runs in the new process."""
        global logger
        setup_exceptions()
        logger = log_utils.setup_logger('tile_worker')

        if self.caffe_path is not None:
            sys.path.append(self.caffe_path + '/python')
        if self.device >= 0:
            os.environ['CUDA_VISIBLE_DEVICES'] = str(self.device)
        import caffe
        if self.device >= 0:
            caffe.set_mode_gpu()
        else:
            caffe.set_mode_cpu()

        caffe.set_random_seed(0)
        np.random.seed(0)

        self.model = CaffeModel(*self.model_info)
        self.model.img = np.zeros((3, 1, 1), dtype=np.float32)

        while True:
            try:
                self.process_one_request()
            except KeyboardInterrupt:
                break
项目:faster_rcnn_logo    作者:romyny    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:Faster_RCNN_Training_Toolkit    作者:VerseChow    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:KITTI-detection-OHEM    作者:manutdzou    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:KITTI-detection-OHEM    作者:manutdzou    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:ohem    作者:abhi2610    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-faster-rcnn-dockerface    作者:natanielruiz    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-faster-rcnn-dockerface    作者:natanielruiz    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:faster-rcnn-scenarios    作者:djdam    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:faster-rcnn-scenarios    作者:djdam    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:faster-rcnn-scenarios    作者:djdam    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:faster-rcnn-scenarios    作者:djdam    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:PVANet-FACE    作者:twmht    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-R-FCN    作者:YuwenXiong    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-R-FCN    作者:YuwenXiong    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:lsi-faster-rcnn    作者:cguindel    | 项目源码 | 文件源码
def _init_caffe(cfg):
    """Initialize pycaffe in a training process.
    """

    import caffe
    # fix the random seeds (numpy and caffe) for reproducibility
    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)
项目:py-faster-rcnn-resnet-imagenet    作者:tianzhi0549    | 项目源码 | 文件源码
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})