flow_images_from_dataframe {keras} | R Documentation |
Takes the dataframe and the path to a directory and generates batches of augmented/normalized data.
Description
Takes the dataframe and the path to a directory and generates batches of augmented/normalized data.
Usage
flow_images_from_dataframe(
dataframe,
directory = NULL,
x_col = "filename",
y_col = "class",
generator = image_data_generator(),
target_size = c(256, 256),
color_mode = "rgb",
classes = NULL,
class_mode = "categorical",
batch_size = 32,
shuffle = TRUE,
seed = NULL,
save_to_dir = NULL,
save_prefix = "",
save_format = "png",
subset = NULL,
interpolation = "nearest",
drop_duplicates = NULL
)
Arguments
dataframe |
|
directory |
character, path to the directory to read images from.
If |
x_col |
character, column in dataframe that contains the filenames
(or absolute paths if directory is |
y_col |
string or list, column/s in dataframe that has the target data. |
generator |
Image data generator to use for augmenting/normalizing image data. |
target_size |
Either |
color_mode |
one of "grayscale", "rgb". Default: "rgb". Whether the images will be converted to have 1 or 3 color channels. |
classes |
optional list of classes (e.g. |
class_mode |
one of "categorical", "binary", "sparse", "input", "other" or None. Default: "categorical". Mode for yielding the targets:
|
batch_size |
int (default: |
shuffle |
boolean (defaut: |
seed |
int (default: |
save_to_dir |
|
save_prefix |
str (default: ”). Prefix to use for filenames of saved
pictures (only relevant if |
save_format |
one of "png", "jpeg" (only relevant if save_to_dir is set). Default: "png". |
subset |
Subset of data ( |
interpolation |
Interpolation method used to resample the image if the target size is different from that of the loaded image. Supported methods are "nearest", "bilinear", and "bicubic". If PIL version 1.1.3 or newer is installed, "lanczos" is also supported. If PIL version 3.4.0 or newer is installed, "box" and "hamming" are also supported. By default, "nearest" is used. |
drop_duplicates |
(deprecated in TF >= 2.3) Boolean, whether to drop
duplicate rows based on filename. The default value is |
Details
Yields batches indefinitely, in an infinite loop.
Yields
(x, y)
where x
is an array of image data and y
is a
array of corresponding labels. The generator loops indefinitely.
Note
This functions requires that pandas
(Python module) is installed in the
same environment as tensorflow
and keras
.
If you are using r-tensorflow
(the default environment) you can install
pandas
by running reticulate::virtualenv_install("pandas", envname = "r-tensorflow")
or reticulate::conda_install("pandas", envname = "r-tensorflow")
depending on
the kind of environment you are using.
See Also
Other image preprocessing:
fit_image_data_generator()
,
flow_images_from_data()
,
flow_images_from_directory()
,
image_load()
,
image_to_array()