def voc2007_classification_generator2(which, batch_size, input_size,
outer_input_size,
shuffle=True,# seed=0,
color_transform=None, random_mirror=False):
path = os.path.expandvars('$VOC2007_DIR/ImageSets/Main')
assert which in ['test', 'val']
imgs, C = dd.io.load('{}.h5'.format(which), ['/data', '/labels'])
if shuffle:
rs = np.random.RandomState()
while True:
II = rs.randint(len(imgs), size=batch_size)
ii, cc = imgs[II], C[II]
if random_mirror and rs.randint(2) == 1:
ii = ii[:, :, ::-1]
yield ii, cc
else:
for i in range(len(imgs)//batch_size):
ss = np.s_[i*batch_size:(i+1)*batch_size]
yield imgs[ss], C[ss]
评论列表
文章目录