stitcher源码阅读

陈康老哥的实现虽然是用maskrcnn-benchmark的 但实现的还挺全,batch和非batch都实现了,基本配置在这里

https://github.com/yukang2017/Stitcher/blob/41063c4d9af077908cd1368ae86d43a27c77f479/maskrcnn_benchmark/config/defaults.py#L91

在这里插入图片描述

stitcher合成

主要合成图片的地方在 BatchCollatorSynthesize (https://github.com/yukang2017/Stitcher/blob/41063c4d9af077908cd1368ae86d43a27c77f479/maskrcnn_benchmark/data/build.py#L184) 调用了 to_image_list_synthesize 进而调用了 to_image_list_synthesize_4 (https://github.com/yukang2017/Stitcher/blob/41063c4d9af077908cd1368ae86d43a27c77f479/maskrcnn_benchmark/structures/image_list.py#L79)

在这里插入图片描述

计算small object loss

https://github.com/yukang2017/Stitcher/blob/41063c4d9af077908cd1368ae86d43a27c77f479/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py#L168

 reference_boxes = matched_targets_boxes[sampled_pos_inds_subset]
 gt_widths = reference_boxes[:, 2] - reference_boxes[:, 0]
 gt_heights = reference_boxes[:, 3] - reference_boxes[:, 1]
 gt_areas = gt_widths * gt_heights

 small_index = gt_areas < 1024 

 box_loss, box_loss_vec = smooth_l1_loss(
     box_regression[sampled_pos_inds_subset[:, None], map_inds],
     regression_targets[sampled_pos_inds_subset],
     size_average=False,
     beta=1,
     return_loss_vec=True
 )
 if cfg.STITCHER.FEEDBACK == 'cls_loss':
     cls_loss_vec = F.cross_entropy(class_logits, labels, reduction='none')[sampled_pos_inds_subset]
     ratio_small = cls_loss_vec[small_index].sum()/classification_loss 
 else:
     ratio_small = box_loss_vec[small_index].sum()/box_loss

 box_loss = box_loss / labels.numel()

 return classification_loss, box_loss, ratio_small

很简单的实现,默认是reg_loss

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值