Пример #1
0
def test_normalizer(min_labels):
    # tf.executing_eagerly()

    labels_reader = providers.LabelsReader(min_labels)
    ds_img = labels_reader.make_dataset()

    normalizer = normalization.Normalizer(ensure_grayscale=True)
    ds = normalizer.transform_dataset(ds_img)
    example = next(iter(ds))
    assert example["image"].shape[-1] == 1

    normalizer = normalization.Normalizer(ensure_float=True,
                                          ensure_grayscale=True)
    ds = normalizer.transform_dataset(ds_img)
    example = next(iter(ds))
    assert example["image"].dtype == tf.float32
    assert example["image"].shape[-1] == 1

    normalizer = normalization.Normalizer(ensure_float=True, ensure_rgb=True)
    ds = normalizer.transform_dataset(ds_img)
    example = next(iter(ds))
    assert example["image"].dtype == tf.float32
    assert example["image"].shape[-1] == 3

    normalizer = normalization.Normalizer(ensure_grayscale=True,
                                          ensure_rgb=True)
    ds = normalizer.transform_dataset(ds_img)
    example = next(iter(ds))
    assert example["image"].shape[-1] == 1
Пример #2
0
def test_ensure_rgb_from_provider(centered_pair_vid):
    video = providers.VideoReader(
        video=centered_pair_vid,
        example_indices=[0],
    )

    normalizer = normalization.Normalizer(image_key="image", ensure_rgb=True)

    ds = video.make_dataset()
    ds = normalizer.transform_dataset(ds)
    example = next(iter(ds))

    assert example["image"].shape[-1] == 3
Пример #3
0
def test_normalizer(min_labels):
    tf.executing_eagerly()

    labels_reader = providers.LabelsReader(min_labels)
    normalizer = normalization.Normalizer(image_key="image",
                                          ensure_float=True,
                                          ensure_grayscale=True)

    ds = labels_reader.make_dataset()
    ds = normalizer.transform_dataset(ds)
    example = next(iter(ds))

    assert example["image"].dtype == tf.float32
Пример #4
0
def test_ensure_grayscale_from_provider(small_robot_mp4_vid):
    video = providers.VideoReader(
        video=small_robot_mp4_vid,
        example_indices=[0],
    )

    normalizer = normalization.Normalizer(image_key="image",
                                          ensure_grayscale=True)

    ds = video.make_dataset()
    ds = normalizer.transform_dataset(ds)
    example = next(iter(ds))

    assert example["image"].shape[-1] == 1