Esempio n. 1
0
def test_load_image_data():
    dataset = io_utils.image_dataset_from_directory(
        IMG_DATA_DIR,
        image_size=(180, 180),
        validation_split=0.2,
        subset="training",
        seed=test_utils.SEED,
    )

    val_dataset = io_utils.image_dataset_from_directory(
        IMG_DATA_DIR,
        image_size=(180, 180),
        validation_split=0.2,
        subset="validation",
        seed=test_utils.SEED,
    )

    for data in dataset:
        assert data[0].numpy().shape == (32, 180, 180, 3)
        assert data[1].dtype == tf.string
        break

    for data in val_dataset:
        assert data[0].numpy().shape == (32, 180, 180, 3)
        assert data[1].dtype == tf.string
        break
Esempio n. 2
0
def test_load_image_data_raise_subset_error():
    with pytest.raises(ValueError) as info:
        io_utils.image_dataset_from_directory(
            IMG_DATA_DIR,
            image_size=(180, 180),
            validation_split=0.2,
            subset="abcd",
            seed=test_utils.SEED,
        )
    assert "`subset` must be either" in str(info.value)
Esempio n. 3
0
def test_load_image_data_raise_color_mode_error():
    with pytest.raises(ValueError) as info:
        io_utils.image_dataset_from_directory(IMG_DATA_DIR,
                                              image_size=(180, 180),
                                              color_mode="abcd")
    assert "`color_mode` must be one of" in str(info.value)
Esempio n. 4
0
def test_load_image_data_grey_scale():
    io_utils.image_dataset_from_directory(IMG_DATA_DIR,
                                          image_size=(180, 180),
                                          color_mode="grayscale")
Esempio n. 5
0
def test_load_image_data_rgba():
    io_utils.image_dataset_from_directory(IMG_DATA_DIR,
                                          image_size=(180, 180),
                                          color_mode="rgba")