Check rpn proposals in faster-rcnn

1. Usage

  1. Create checkProposals.ipynb in py-faster-rcnn/tools/
  2. Paste three code cells into ipynb.
  3. Run each cell and see the output.
  4. You may need to change rpn_file and insulator_2016_train to your own.

2. Code

1.load roidb

import _init_paths
from fast_rcnn.train import get_training_roidb
from datasets.factory import get_imdb
import numpy as np

def get_roidb(imdb_name, rpn_file=None):
    imdb = get_imdb(imdb_name)
    imdb.set_proposal_method('rpn')
    if rpn_file is not None:
        imdb.config['rpn_file'] = rpn_file
    roidb = get_training_roidb(imdb)
    return roidb, imdb

rpn_file = '/home/cv/project/py-faster-rcnn/output/faster_rcnn_alt_opt/insulator_2016_train/zf_rpn_stage1_iter_80000_proposals.pkl'

roidb, imdb = get_roidb('insulator_2016_train', rpn_file)

2.print roidb information

print roidb[0]['width'], roidb[0]['height']
print 'gt_classes', roidb[0]['gt_classes']
print 'boxes',roidb[0]['boxes'].shape
print len([i for i in roidb[0]['max_classes'].tolist() if i == 1])

3.plot proposals

from matplotlib.pyplot import imshow
%matplotlib inline
from PIL import Image
from PIL import ImageDraw

index = 0
img = Image.open(roidb[index]['image'])
draw = ImageDraw.Draw(img)
for i in range(0,50):
    draw.rectangle(roidb[index]['boxes'][i,0:4].tolist(), outline=(255,0,0))
imshow(np.asarray(img))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值