Reputation: 11
I am using Image Data Generator to extend my dataset.
train_generator = train_datagen.flow_from_directory(
path_to_train,
target_size=(150, 150),
batch_size=32,
class_mode = "sparse",
color_mode="grayscale")
and then
history = model.fit(
train_generator,
steps_per_epoch=20,
epochs=100
)
The problem is that I want to apply some methods to the input images. I want to use Gaussian bluring and etc. But how can I apply it when I directly load it and use model fit.
Can you help me please? Thanks for you advices.
Upvotes: 0
Views: 1447
Reputation: 36684
You can do this with tfa.image.gaussian_filter2d
:
@tf.function
tfa.image.gaussian_filter2d(
image: tfa.types.TensorLike,
filter_shape: Union[List[int], Tuple[int], int] = [3, 3],
sigma: Union[List[float], Tuple[float], float] = 1.0,
padding: str = 'REFLECT',
constant_values: tfa.types.TensorLike = 0,
name: Optional[str] = None
) -> tfa.types.TensorLike
You can pass this function in ImageDataGenerator
:
img_gen = ImageDataGenerator(
proprocessing_function=tfa.image.gaussian_filter2d
)
Upvotes: 3