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
评论列表
文章目录