本文整理汇总了Python中fast_rcnn.config.cfg方法的典型用法代码示例。如果您正苦于以下问题:Python config.cfg方法的具体用法?Python config.cfg怎么用?Python config.cfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fast_rcnn.config
的用法示例。
在下文中一共展示了config.cfg方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def setup(self, bottom, top):
# parse the layer parameter string, which must be valid YAML
layer_params = yaml.load(self.param_str_)
self._feat_stride = layer_params['feat_stride']
self._anchors = generate_anchors(cfg.TRAIN.RPN_BASE_SIZE, cfg.TRAIN.RPN_ASPECTS, cfg.TRAIN.RPN_SCALES)
self._num_anchors = self._anchors.shape[0]
if DEBUG:
print 'feat_stride: {}'.format(self._feat_stride)
print 'anchors:'
print self._anchors
# rois blob: holds R regions of interest, each is a 5-tuple
# (n, x1, y1, x2, y2) specifying an image batch index n and a
# rectangle (x1, y1, x2, y2)
top[0].reshape(1, 5)
# scores blob: holds scores for R regions of interest
if len(top) > 1:
top[1].reshape(1, 1, 1, 1)
示例2: combined_roidb
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def combined_roidb(imdb_names):
def get_roidb(imdb_name):
imdb = get_imdb(imdb_name)
print 'Loaded dataset `{:s}` for training'.format(imdb.name)
imdb.set_proposal_method(cfg.TRAIN.PROPOSAL_METHOD)
print 'Set proposal method: {:s}'.format(cfg.TRAIN.PROPOSAL_METHOD)
roidb = get_training_roidb(imdb)
return roidb
roidbs = [get_roidb(s) for s in imdb_names.split('+')]
roidb = roidbs[0]
if len(roidbs) > 1:
for r in roidbs[1:]:
roidb.extend(r)
imdb = datasets.imdb.imdb(imdb_names)
else:
imdb = get_imdb(imdb_names)
return imdb, roidb
示例3: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Generate bbox output from a Fast R-CNN network')
parser.add_argument('--gpu', dest='gpu_id', help='GPU id(s) to use',
default='0', type=str)
parser.add_argument('--def', dest='prototxt',
help='prototxt file defining the network',
default=None, type=str)
parser.add_argument('--out', dest='outfile',
help='output filepath',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file', default=None, type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
parser.add_argument('--imgroot', type=str, default='/workspace/images/')
parser.add_argument('--split', type=str, default='valid')
parser.add_argument('--caffemodel', type=str, default='./resnet101_faster_rcnn_final_iter_320000.caffemodel')
args = parser.parse_args()
return args
示例4: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Test a DPL network')
parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use',
default=0, type=int)
parser.add_argument('--def', dest='prototxt',
help='prototxt file defining the network',
default=None, type=str)
parser.add_argument('--net', dest='caffemodel',
help='model to test',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file', default=None, type=str)
parser.add_argument('--wait', dest='wait',
help='wait until net file exists',
default=True, type=bool)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to test',
default='voc_2007_test', type=str)
parser.add_argument('--comp', dest='comp_mode', help='competition mode',
action='store_true')
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
parser.add_argument('--task', dest='task',
default=None, type=str)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
示例5: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Train a DPL network')
parser.add_argument('--gpu', dest='gpu_id',
help='GPU device id to use [0]',
default=0, type=int)
parser.add_argument('--solver', dest='solver',
help='solver prototxt',
default=None, type=str)
parser.add_argument('--iters', dest='max_iters',
help='number of iterations to train',
default=80000, type=int)
parser.add_argument('--weights', dest='pretrained_model',
help='initialize with pretrained model weights',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file',
default=None, type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to train on',
default='voc_2007_trainval', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
示例6: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Test an OICR network')
parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use',
default=0, type=int)
parser.add_argument('--def', dest='prototxt',
help='prototxt file defining the network',
default=None, type=str)
parser.add_argument('--net', dest='caffemodel',
help='model to test',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file', default=None, type=str)
parser.add_argument('--wait', dest='wait',
help='wait until net file exists',
default=True, type=bool)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to test',
default='voc_2007_test', type=str)
parser.add_argument('--comp', dest='comp_mode', help='competition mode',
action='store_true')
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
示例7: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Train an OICR network')
parser.add_argument('--gpu', dest='gpu_id',
help='GPU device id to use [0]',
default=0, type=int)
parser.add_argument('--solver', dest='solver',
help='solver prototxt',
default=None, type=str)
parser.add_argument('--iters', dest='max_iters',
help='number of iterations to train',
default=70000, type=int)
parser.add_argument('--weights', dest='pretrained_model',
help='initialize with pretrained model weights',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file',
default=None, type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to train on',
default='voc_2007_trainval', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
示例8: parse_args
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Train a Face-Magnet network')
parser.add_argument('--gpus', dest='gpu_id',
help='GPUs device id to use [0]',
default='0,1', type=str)
parser.add_argument('--solver', dest='solver',
help='solver prototxt',
default=None, type=str)
parser.add_argument('--iters', dest='max_iters',
help='number of iterations to train',
default=38000, type=int)
parser.add_argument('--weights', dest='pretrained_model',
help='initialize with pretrained model weights',
default=None, type=str)
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file',
default=None, type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to train on',
default='wider', type=str)
parser.add_argument('--max_size', dest='max_size',
help='dataset to max size on',
default='10', type=str)
parser.add_argument('--min_size', dest='max_size',
help='dataset to max size on',
default='10', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
parser.add_argument('--reload', dest='reload',
help='Reloading saved weights. Set it if not initializing with imagenet weights.',
action='store_true')
parser.add_argument('--randomize', dest='randomize',
help='Randomize the training.',
action='store_true')
parser.add_argument('--shuffle', dest='shuffle',
help='Shuffle the testing order, for parallel testing',
action='store_true')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
示例9: get_detections_from_im
# 需要导入模块: from fast_rcnn import config [as 别名]
# 或者: from fast_rcnn.config import cfg [as 别名]
def get_detections_from_im(net, im_file, image_id, conf_thresh=0.2):
"""
:param net:
:param im_file: full path to an image
:param image_id:
:param conf_thresh:
:return: all information from detection and attr prediction
"""
im = cv2.imread(im_file)
scores, boxes, attr_scores, rel_scores = im_detect(net, im)
# Keep the original boxes, don't worry about the regresssion bbox outputs
rois = net.blobs['rois'].data.copy()
# unscale back to raw image space
blobs, im_scales = _get_blobs(im, None)
cls_boxes = rois[:, 1:5] / im_scales[0]
cls_prob = net.blobs['cls_prob'].data
attr_prob = net.blobs['attr_prob'].data
pool5 = net.blobs['pool5_flat'].data
# Keep only the best detections
max_conf = np.zeros((rois.shape[0]))
for cls_ind in range(1, cls_prob.shape[1]):
cls_scores = scores[:, cls_ind]
dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis])).astype(np.float32)
keep = np.array(nms(dets, cfg.TEST.NMS))
max_conf[keep] = np.where(cls_scores[keep] > max_conf[keep], cls_scores[keep], max_conf[keep])
keep_boxes = np.where(max_conf >= conf_thresh)[0]
if len(keep_boxes) < MIN_BOXES:
keep_boxes = np.argsort(max_conf)[::-1][:MIN_BOXES]
elif len(keep_boxes) > MAX_BOXES:
keep_boxes = np.argsort(max_conf)[::-1][:MAX_BOXES]
objects = np.argmax(cls_prob[keep_boxes][:, 1:], axis=1)
objects_conf = np.max(cls_prob[keep_boxes][:, 1:], axis=1)
attrs = np.argmax(attr_prob[keep_boxes][:, 1:], axis=1)
attrs_conf = np.max(attr_prob[keep_boxes][:, 1:], axis=1)
return {
"img_id": image_id,
"img_h": np.size(im, 0),
"img_w": np.size(im, 1),
"objects_id": base64.b64encode(objects), # int64
"objects_conf": base64.b64encode(objects_conf), # float32
"attrs_id": base64.b64encode(attrs), # int64
"attrs_conf": base64.b64encode(attrs_conf), # float32
"num_boxes": len(keep_boxes),
"boxes": base64.b64encode(cls_boxes[keep_boxes]), # float32
"features": base64.b64encode(pool5[keep_boxes]) # float32
}