stitcher源码阅读

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

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

stitcher源码阅读

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)

stitcher源码阅读

计算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

上一篇:<el-form>的<el-form-item>使用自定义label 插槽


下一篇:mybatis sql不等于