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)
python类set_random_seed()的实例源码
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:faster-rcnn-resnet
作者: Eniac-Xie
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:py-faster-rcnn-tk1
作者: joeking11829
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
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)
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:face-py-faster-rcnn
作者: playerkk
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
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)
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)
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)
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)
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
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:Faster_RCNN_Training_Toolkit
作者: VerseChow
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
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)
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:KITTI-detection-OHEM
作者: manutdzou
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
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)
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)
train_faster_rcnn_alt_opt_doubledb.py 文件源码
项目:py-faster-rcnn-dockerface
作者: natanielruiz
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:py-faster-rcnn-dockerface
作者: natanielruiz
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
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)
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)
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)
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)
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)
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)
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)
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)
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)
train_faster_rcnn_alt_opt.py 文件源码
项目:py-faster-rcnn-resnet-imagenet
作者: tianzhi0549
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
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})