def _enqueue_op(self, queue, msg_queue):
while msg_queue.qsize() == 0:
# randomly select index
indexes = np.random.randint(0, self._total_num, self.batch_size)
sz = self.target_size
output = np.zeros([self.batch_size, sz, sz, 1])
for i in range(len(indexes)):
index = indexes[i]
output[i] = self._random_preprocessing(scipy.misc.imread(
self._image_paths[index], mode='L').astype(np.float),
self.target_size).reshape([sz, sz, 1])
while np.amin(output[i]) == np.amax(output[i]): # some data are strange..
output[i] = self._random_preprocessing(scipy.misc.imread(
self._image_paths[index], mode='L').astype(np.float32),
self.target_size).reshape([sz, sz, 1])
queue.put(output)
评论列表
文章目录