當前位置: 首頁>>代碼示例>>Python>>正文


Python augmenters.Noop方法代碼示例

本文整理匯總了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 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:21,代碼來源:segmentation.py

示例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 
開發者ID:minerva-ml,項目名稱:open-solution-data-science-bowl-2018,代碼行數:20,代碼來源:loaders.py

示例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) 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:25,代碼來源:test.py

示例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 
開發者ID:aleju,項目名稱:cat-bbs,代碼行數:40,代碼來源:train.py

示例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) 
開發者ID:aleju,項目名稱:cat-bbs,代碼行數:15,代碼來源:train.py

示例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 
開發者ID:neptune-ai,項目名稱:open-solution-salt-identification,代碼行數:5,代碼來源:augmentation.py

示例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) 
開發者ID:minerva-ml,項目名稱:open-solution-data-science-bowl-2018,代碼行數:4,代碼來源:augmentation.py

示例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() 
開發者ID:selimsef,項目名稱:dsb2018_topcoders,代碼行數:6,代碼來源:transforms.py

示例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))) 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:29,代碼來源:check_single_image_warning.py

示例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
    ) 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:8,代碼來源:generate_documentation_images.py

示例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] 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:43,代碼來源:test.py

示例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 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:35,代碼來源:test.py

示例13: processor

# 需要導入模塊: from imgaug import augmenters [as 別名]
# 或者: from imgaug.augmenters import Noop [as 別名]
def processor(self):
        return iaa.Noop() 
開發者ID:albumentations-team,項目名稱:albumentations,代碼行數:4,代碼來源:transforms.py

示例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) 
開發者ID:aleju,項目名稱:self-driving-truck,代碼行數:45,代碼來源:generate_video_frames.py

示例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.") 
開發者ID:aleju,項目名稱:self-driving-truck,代碼行數:57,代碼來源:train.py


注:本文中的imgaug.augmenters.Noop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。