transfer_learning.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:ModelZoo 作者: NervanaSystems 项目源码 文件源码
def compute_patches_at_scale(self, scale_idx, scale, p_id_base):
        debug("Processing {} scale_idx:{} scale:{}".format(self.file_name, scale_idx, scale))
        shape = np.array(self.shape)
        size = (np.amin(shape)-1) / scale
        num_samples = np.ceil( (shape-1) / size)
        num_samples = [int(n*2) if n > 1 else int(n) for n in num_samples]
        patches = []
        sample_locs = [ self.sample_locs_for_dim( self.shape[0], size, num_samples[0]),
                        self.sample_locs_for_dim( self.shape[1], size, num_samples[1])]
        p_id = p_id_base
        for sample_loc_0 in sample_locs[0]:
            for sample_loc_1 in sample_locs[1]:
                patch = ImagePatch( p_id, self, (sample_loc_0, sample_loc_1), size, scale)
                patch.label, patch.matched_roi_idx = \
                            self.get_label_for_patch(patch)
                if patch.label != PASCAL_VOC_BACKGROUND_CLASS:
                    self.non_background_patches.append(patch)
                else:
                    self.background_patches.append(patch)

                patches.append(patch)
                p_id += 1

        debug("Compute {} patches".format(p_id-p_id_base))

        return p_id

# Sample the Pascal VOC dataset
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号