Region proposal networks by faster rcnn

解析网络结构 http://blog.csdn.net/sloanqin/article/details/51545125

anchor 产生 http://blog.csdn.net/xzzppp/article/details/52317863
http://blog.csdn.net/u012905422/article/details/52634208

部分代码解析
http://www.cnblogs.com/573177885qq/p/6141507.html

im = single(im);
    [im_blob, im_scales] = get_image_blob(conf, im);
    im_size = size(im);
    scaled_im_size = round(im_size * im_scales);

    % permute data into caffe c++ memory, thus [num, channels, height, width]
    im_blob = im_blob(:, :, [3, 2, 1], :); % from rgb to brg
    im_blob = permute(im_blob, [2, 1, 3, 4]);
    im_blob = single(im_blob);

    net_inputs = {im_blob};

    % Reshape net's input blobs

    caffe_net.reshape_as_input(net_inputs);
    output_blobs = caffe_net.forward(net_inputs);%得到cls layer 和 reg layer的输出结果


    % Apply bounding-box regression deltas
    box_deltas = output_blobs{1};%位置回归参数
    featuremap_size = [size(box_deltas, 2), size(box_deltas, 1)];
    % permute from [width, height, channel] to [channel, height, width], where channel is the
        % fastest dimension
    box_deltas = permute(box_deltas, [3, 2, 1]);
    box_deltas = reshape(box_deltas, 4, [])';

    anchors = proposal_locate_anchors(conf, size(im), conf.test_scales, featuremap_size);%产生所有的anchor 15*15*9
    pred_boxes = fast_rcnn_bbox_transform_inv(anchors, box_deltas);%变回gt
      % scale back
    pred_boxes = bsxfun(@times, pred_boxes - 1, ...
        ([im_size(2), im_size(1), im_size(2), im_size(1)] - 1) ./ ([scaled_im_size(2), scaled_im_size(1), scaled_im_size(2), scaled_im_size(1)] - 1)) + 1;%映射会原图位置
    pred_boxes = clip_boxes(pred_boxes, size(im, 2), size(im, 1));

    assert(conf.test_binary == false);
    % use softmax estimated probabilities
    scores = output_blobs{2}(:, :, end);%得到分数背景或对象
    scores = reshape(scores, size(output_blobs{1}, 1), size(output_blobs{1}, 2), []);
    % permute from [width, height, channel] to [channel, height, width], where channel is the
        % fastest dimension
    scores = permute(scores, [3, 2, 1]);
    scores = scores(:);

    box_deltas_ = box_deltas;
    anchors_ = anchors;
    scores_ = scores;

    if conf.test_drop_boxes_runoff_image
        contained_in_image = is_contain_in_image(anchors, round(size(im) * im_scales));
        pred_boxes = pred_boxes(contained_in_image, :);
        scores = scores(contained_in_image, :);
    end

    % drop too small boxes
    [pred_boxes, scores] = filter_boxes(conf.test_min_box_size, conf.test_min_box_height, pred_boxes, scores);

    % sort
    [scores, scores_ind] = sort(scores, 'descend');
    pred_boxes = pred_boxes(scores_ind, :);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值