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
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)
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)
def test_load_image_data_grey_scale(): io_utils.image_dataset_from_directory(IMG_DATA_DIR, image_size=(180, 180), color_mode="grayscale")
def test_load_image_data_rgba(): io_utils.image_dataset_from_directory(IMG_DATA_DIR, image_size=(180, 180), color_mode="rgba")