matlab rootdir,Python cfg.ROOT_DIR属性代码示例

# 需要导入模块: from fast_rcnn.config import cfg [as 别名]

# 或者: from fast_rcnn.config.cfg import ROOT_DIR [as 别名]

def demo(net, image_name, classes):

"""Detect object classes in an image using pre-computed object proposals."""

# Load pre-computed Selected Search object proposals

box_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo',

image_name + '_boxes.mat')

obj_proposals = sio.loadmat(box_file)['boxes']

# Load the demo image

im_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo', image_name + '.jpg')

im = cv2.imread(im_file)

# Detect all object classes and regress object bounds

timer = Timer()

timer.tic()

scores, boxes = im_detect(net, im, obj_proposals, len(classes))

timer.toc()

print ('Detection took {:.3f}s for '

'{:d} object proposals').format(timer.total_time, boxes.shape[0])

# Visualize detections for each class

CONF_THRESH = 0.8

NMS_THRESH = 0.3

for cls in classes:

cls_ind = CLASSES.index(cls)

cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]

cls_scores = scores[:, cls_ind]

dets = np.hstack((cls_boxes,

cls_scores[:, np.newaxis])).astype(np.float32)

keep = nms(dets, NMS_THRESH)

dets = dets[keep, :]

print 'All {} detections with p({} | box) >= {:.1f}'.format(cls, cls,

CONF_THRESH)

vis_detections(im, cls, dets, thresh=CONF_THRESH)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值