本文整理汇总了Python中imgaug.augmenters.Noop方法的典型用法代码示例。如果您正苦于以下问题:Python augmenters.Noop方法的具体用法?Python augmenters.Noop怎么用?Python augmenters.Noop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imgaug.augmenters
的用法示例。
在下文中一共展示了augmenters.Noop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def __init__(self, X, y, train_mode,
image_transform, image_augment_with_target,
mask_transform, image_augment,
image_source='memory'):
super().__init__()
self.X = X
if y is not None:
self.y = y
else:
self.y = None
self.train_mode = train_mode
self.image_transform = image_transform
self.mask_transform = mask_transform
self.image_augment = image_augment if image_augment is not None else ImgAug(iaa.Noop())
self.image_augment_with_target = image_augment_with_target if image_augment_with_target is not None else ImgAug(
iaa.Noop())
self.image_source = image_source
示例2: __init__
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def __init__(self, X, y, train_mode,
image_transform, image_augment_with_target,
mask_transform, image_augment,
image_source='memory'):
super().__init__()
self.X = X
if y is not None:
self.y = y
else:
self.y = None
self.train_mode = train_mode
self.image_transform = image_transform
self.mask_transform = mask_transform
self.image_augment = image_augment if image_augment is not None else ImgAug(iaa.Noop())
self.image_augment_with_target = image_augment_with_target if image_augment_with_target is not None else ImgAug(iaa.Noop())
self.image_source = image_source
示例3: test_Noop
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def test_Noop():
reseed()
images = create_random_images((16, 70, 50, 3))
keypoints = create_random_keypoints((16, 70, 50, 3), 4)
aug = iaa.Noop()
aug_det = aug.to_deterministic()
observed = aug.augment_images(images)
expected = images
assert np.array_equal(observed, expected)
observed = aug_det.augment_images(images)
expected = images
assert np.array_equal(observed, expected)
observed = aug.augment_keypoints(keypoints)
expected = keypoints
assert keypoints_equal(observed, expected)
observed = aug_det.augment_keypoints(keypoints)
expected = keypoints
assert keypoints_equal(observed, expected)
示例4: generate_video_image
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def generate_video_image(batch_idx, examples, model):
"""Generate frames for a video of the training progress.
Each frame contains N examples shown in a grid. Each example shows
the input image and the main heatmap predicted by the model."""
start_time = time.time()
#print("A", time.time() - start_time)
model.eval()
# fw through network
inputs, outputs_gt = examples_to_batch(examples, iaa.Noop())
inputs_torch = torch.from_numpy(inputs)
inputs_torch = Variable(inputs_torch, volatile=True)
if GPU >= 0:
inputs_torch = inputs_torch.cuda(GPU)
outputs_pred_torch = model(inputs_torch)
#print("B", time.time() - start_time)
outputs_pred = outputs_pred_torch.cpu().data.numpy()
inputs = (inputs * 255).astype(np.uint8).transpose(0, 2, 3, 1)
#print("C", time.time() - start_time)
heatmaps = []
for i in range(inputs.shape[0]):
hm_drawn = draw_heatmap(inputs[i], np.squeeze(outputs_pred[i][0]), alpha=0.5)
heatmaps.append(hm_drawn)
#print("D", time.time() - start_time)
grid = ia.draw_grid(heatmaps, cols=11, rows=6).astype(np.uint8)
#grid_rs = misc.imresize(grid, (720-32, 1280-32))
# pad by 42 for the text and to get the image to 720p aspect ratio
grid_pad = np.pad(grid, ((0, 42), (0, 0), (0, 0)), mode="constant")
grid_pad_text = ia.draw_text(
grid_pad,
x=grid_pad.shape[1]-220,
y=grid_pad.shape[0]-35,
text="Batch %05d" % (batch_idx,),
color=[255, 255, 255]
)
#print("E", time.time() - start_time)
return grid_pad_text
示例5: examples_to_batch
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def examples_to_batch(examples, seq=None):
"""Convert examples from the dataset to inputs and ground truth outputs
for the model.
"""
if seq is None:
seq = iaa.Noop()
seq_det = seq.to_deterministic()
inputs = [ex.image for ex in examples]
inputs_aug = seq_det.augment_images(inputs)
bb_coords = [ex.get_bb_coords_keypoints(seq_det) for ex in examples]
return images_coords_to_batch(inputs_aug, bb_coords)
示例6: pad_to_fit_net
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def pad_to_fit_net(divisor, pad_mode, rest_of_augs=iaa.Noop()):
seq = iaa.Sequential(InferencePad(divisor, pad_mode), rest_of_augs)
return seq
示例7: pad_to_fit_net
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def pad_to_fit_net(divisor, pad_mode, rest_of_augs=iaa.Noop()):
return iaa.Sequential(InferencePad(divisor, pad_mode), rest_of_augs)
示例8: __init__
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def __init__(self, prob=0.5):
super().__init__(prob)
self.processor = iaa.Noop()
self.deterministic_processor = iaa.Noop()
示例9: main
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def main():
def z(shape):
return np.zeros(shape, dtype=np.uint8)
seq = iaa.Noop()
print("This should generate NO warning:")
image_aug = seq.augment_images(z((1, 16, 16, 3)))
print("This should generate NO warning:")
image_aug = seq.augment_images(z((16, 16, 8)))
print("This should generate NO warning:")
image_aug = seq.augment_images([z((16, 16, 3))])
print("This should generate NO warning:")
image_aug = seq.augment_images([z((16, 16))])
print("This should generate a warning:")
image_aug = seq.augment_images(z((16, 16, 3)))
print("This should generate a warning:")
for _ in range(2):
image_aug = seq.augment_images(z((16, 16, 1)))
print("This should fail:")
image_aug = seq.augment_images(z((16, 16)))
示例10: chapter_augmenters_noop
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def chapter_augmenters_noop():
aug = iaa.Noop()
run_and_save_augseq(
"noop.jpg", aug,
[ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
)
示例11: test_find
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def test_find():
reseed()
noop1 = iaa.Noop(name="Noop")
fliplr = iaa.Fliplr(name="Fliplr")
flipud = iaa.Flipud(name="Flipud")
noop2 = iaa.Noop(name="Noop2")
seq2 = iaa.Sequential([flipud, noop2], name="Seq2")
seq1 = iaa.Sequential([noop1, fliplr, seq2], name="Seq")
augs = seq1.find_augmenters_by_name("Seq")
assert len(augs) == 1
assert augs[0] == seq1
augs = seq1.find_augmenters_by_name("Seq2")
assert len(augs) == 1
assert augs[0] == seq2
augs = seq1.find_augmenters_by_names(["Seq", "Seq2"])
assert len(augs) == 2
assert augs[0] == seq1
assert augs[1] == seq2
augs = seq1.find_augmenters_by_name(r"Seq.*", regex=True)
assert len(augs) == 2
assert augs[0] == seq1
assert augs[1] == seq2
augs = seq1.find_augmenters(lambda aug, parents: aug.name in ["Seq", "Seq2"])
assert len(augs) == 2
assert augs[0] == seq1
assert augs[1] == seq2
augs = seq1.find_augmenters(lambda aug, parents: aug.name in ["Seq", "Seq2"] and len(parents) > 0)
assert len(augs) == 1
assert augs[0] == seq2
augs = seq1.find_augmenters(lambda aug, parents: aug.name in ["Seq", "Seq2"], flat=False)
assert len(augs) == 2
assert augs[0] == seq1
assert augs[1] == [seq2]
示例12: test_remove
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def test_remove():
reseed()
def get_seq():
noop1 = iaa.Noop(name="Noop")
fliplr = iaa.Fliplr(name="Fliplr")
flipud = iaa.Flipud(name="Flipud")
noop2 = iaa.Noop(name="Noop2")
seq2 = iaa.Sequential([flipud, noop2], name="Seq2")
seq1 = iaa.Sequential([noop1, fliplr, seq2], name="Seq")
return seq1
augs = get_seq()
augs = augs.remove_augmenters(lambda aug, parents: aug.name == "Seq2")
seqs = augs.find_augmenters_by_name(r"Seq.*", regex=True)
assert len(seqs) == 1
assert seqs[0].name == "Seq"
augs = get_seq()
augs = augs.remove_augmenters(lambda aug, parents: aug.name == "Seq2" and len(parents) == 0)
seqs = augs.find_augmenters_by_name(r"Seq.*", regex=True)
assert len(seqs) == 2
assert seqs[0].name == "Seq"
assert seqs[1].name == "Seq2"
augs = get_seq()
augs = augs.remove_augmenters(lambda aug, parents: True)
assert augs is not None
assert isinstance(augs, iaa.Noop)
augs = get_seq()
augs = augs.remove_augmenters(lambda aug, parents: True, noop_if_topmost=False)
assert augs is None
示例13: processor
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def processor(self):
return iaa.Noop()
示例14: draw_frames
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def draw_frames(self, recording):
previous_states = collections.deque(maxlen=max(PREVIOUS_STATES_DISTANCES))
for frame in recording["frames"]:
scr = util.decompress_img(frame["scr"])
scr = np.clip(scr.astype(np.float32) * 1.5, 0, 255).astype(np.uint8)
current_state = frame["state"]
current_plan_idx = frame["current_plan_idx"]
current_plan_step_idx = frame["current_plan_step_idx"]
idr_v = frame["idr_v"]
idr_adv = frame["idr_adv"]
plan_to_rewards_direct = frame["plan_to_rewards_direct"]
plan_to_reward_indirect = frame["plan_to_reward_indirect"]
plan_to_reward = frame["plan_to_reward"]
plans_ranking = frame["plans_ranking"]
if current_plan_idx is not None:
frame_plans = self.draw_frame_plans(
scr, current_state,
recording["plans"],
current_plan_idx, current_plan_step_idx,
idr_v, idr_adv,
plan_to_rewards_direct, plan_to_reward_indirect, plan_to_reward,
plans_ranking
)
else:
frame_plans = None
if len(previous_states) == previous_states.maxlen:
batch = states_to_batch([list(previous_states)], [[current_state]], iaa.Noop(), PREVIOUS_STATES_DISTANCES, MODEL_HEIGHT, MODEL_WIDTH, MODEL_PREV_HEIGHT, MODEL_PREV_WIDTH)
inputs_supervised = batch.inputs_supervised(volatile=True, gpu=Config.GPU)
x_ae, x_grids, x_atts, x_ma, x_flow, x_canny, x_flipped, x_emb = self.embedder_supervised.forward(inputs_supervised[0], inputs_supervised[1])
frame_attributes = self.draw_frame_attributes(scr, x_atts)
frame_grids = self.draw_frame_grids(scr, x_grids)
else:
frame_attributes = None
frame_grids = None
yield (frame_plans, frame_attributes, frame_grids)
previous_states.append(current_state)
示例15: train
# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Noop [as 别名]
def train(self):
"""Training function."""
print("[OnRouteAdvisorVisible] Training.")
print("[OnRouteAdvisorVisible] Memory size: %d train, %d val" % (self.memory.size, self.memory_val.size))
# initialize background batch loaders that generate batches on other
# CPU cores
batch_loader_train = BatchLoader(
val=False, batch_size=BATCH_SIZE, augseq=self.augseq,
previous_states_distances=PREVIOUS_STATES_DISTANCES, nb_future_states=NB_FUTURE_STATES_TRAIN, model_height=MODEL_HEIGHT, model_width=MODEL_WIDTH, model_prev_height=MODEL_PREV_HEIGHT, model_prev_width=MODEL_PREV_WIDTH
)
batch_loader_val = BatchLoader(
val=True, batch_size=BATCH_SIZE, augseq=iaa.Noop(),
previous_states_distances=PREVIOUS_STATES_DISTANCES, nb_future_states=NB_FUTURE_STATES_VAL, model_height=MODEL_HEIGHT, model_width=MODEL_WIDTH, model_prev_height=MODEL_PREV_HEIGHT, model_prev_width=MODEL_PREV_WIDTH
)
batch_loader_train = BackgroundBatchLoader(batch_loader_train, queue_size=25, nb_workers=6)
batch_loader_val = BackgroundBatchLoader(batch_loader_val, queue_size=15, nb_workers=2)
self.switch_models_to_train()
for batch_idx in xrange(NB_BATCHES_PER_TRAIN):
# fix model parameters every N batches
if batch_idx == 0 or batch_idx % TRAIN_FIX_EVERY_N_BATCHES == 0:
models_fixed = dict([(key, copy.deepcopy(model)) for (key, model) in self.models.items() if key in set(["indirect_reward_predictor"])])
self._run_batch(batch_loader_train, batch_idx, models_fixed, val=False)
if DO_VALIDATE(self.epoch, batch_idx, self.batch_idx_total):
self.switch_models_to_eval()
for i in xrange(NB_VAL_BATCHES):
self._run_batch(batch_loader_val, batch_idx, models_fixed, val=True)
self.switch_models_to_train()
# every N batches, plot loss curves
if DO_PLOT(self.epoch, batch_idx, self.batch_idx_total):
self.loss_plotter.plot(self.history)
# every N batches, save a checkpoint
if DO_SAVE(self.epoch, batch_idx, self.batch_idx_total):
self._save()
self.batch_idx_total += 1
print("Joining batch loaders...")
batch_loader_train.join()
batch_loader_val.join()
print("Saving...")
self._save()
self.switch_models_to_eval()
self.epoch += 1
print("Finished training.")