def apply_transform(args, batch_queue, aug_queue): np.random.seed(int(time.time())) while True: augs = batch_queue.get() if augs is None: break x, y = augs o_aug, l_aug = transform(x, y, args.fliplr, args.rotate, args.norm, args.ortho_side, args.ortho_side, 3, args.label_side, args.label_side) aug_queue.put((o_aug, l_aug)) aug_queue.put(None)
def apply_transform(args, batch_queue, aug_queue): np.random.seed(int(time.time())) while True: augs = batch_queue.get() if augs is None: break x, y = augs o_aug, l_aug = transform( x, y, args.fliplr, args.rotate, args.norm, args.ortho_side, args.ortho_side, 3, args.label_side, args.label_side) aug_queue.put((o_aug, l_aug)) aug_queue.put(None)
(args.ortho_original_side, args.ortho_original_side, 3)) l_patch = np.fromstring(l_val, dtype=np.uint8).reshape( (args.label_original_side, args.label_original_side, 1)) o_batch.append(o_patch) l_batch.append(l_patch) ortho_cur.next() label_cur.next() st = time.time() o_batch = np.asarray(o_batch, dtype=np.uint8) l_batch = np.asarray(l_batch, dtype=np.uint8) o_aug, l_aug = transform( o_batch, l_batch, args.fliplr, args.rotate, args.norm, args.ortho_side, args.ortho_side, 3, args.label_side, args.label_side) print(time.time() - st, 'sec', o_aug.shape, l_aug.shape) for i, (o, l) in enumerate(zip(o_aug, l_aug)): o = o.transpose((1, 2, 0)) o = o - o.min() o = o / o.max() o *= 255 l = l.reshape(-1) l = np.hstack([l == 0, l == 1, l == 2]) l = l.reshape( (3, 16, 16)).transpose((1, 2, 0)).astype(np.uint8) * 255
(args.ortho_original_side, args.ortho_original_side, 3)) l_patch = np.fromstring(l_val, dtype=np.uint8).reshape( (args.label_original_side, args.label_original_side, 1)) o_batch.append(o_patch) l_batch.append(l_patch) ortho_cur.next() label_cur.next() st = time.time() o_batch = np.asarray(o_batch, dtype=np.uint8) l_batch = np.asarray(l_batch, dtype=np.uint8) o_aug, l_aug = transform( o_batch, l_batch, args.fliplr, args.rotate, args.norm, args.ortho_side, args.ortho_side, 3, args.label_side, args.label_side) print(time.time() - st, 'sec', o_aug.shape, l_aug.shape) for i, (o, l) in enumerate(zip(o_aug, l_aug)): o = o.transpose((1, 2, 0)) o = o - o.min() #nan_check = np.isfinite(o).all() #if not nan_check: print('NaN value encountered.') # Culprit matrix is '+str(o)+' .') #all_zeros = not o.any() #if all_zeros: print('An all zero matrix was encountered.') # Culprit matrix is '+str(o)+' .') o = o / o.max()