(num_images, height, width, num_channels),
dtype=np.uint8
)
for i in range(len(dataset_df)):
filepath = get_abs_path(
csv_path,
dataset_df[feature["name"]][i]
)
img = ImageBaseFeature._read_image_and_resize(
filepath,
width,
height,
should_resize,
num_channels,
preprocessing_parameters["resize_method"],
user_specified_num_channels
)
try:
data[feature["name"]][i, :, :, :] = img
except:
logger.error(
"Images are not of the same size. "
"Expected size is {}, "
"current image size is {}."
"Images are expected to be all of the same size"
"or explicit image width and height are expected"
"to be provided. "
"Additional information: https://uber.github.io/ludwig/user_guide///image-features-preprocessing"
.format(first_image.shape, img.shape)
)
raise
else:
data_fp = os.path.splitext(dataset_df.csv)[0] + ".hdf5"
mode = "w"
if os.path.isfile(data_fp):
mode = "r+"
with h5py.File(data_fp, mode) as h5_file:
image_dataset = h5_file.create_dataset(
feature["name"] + "_data",
(num_images, height, width, num_channels),
dtype=np.uint8
)
for i in range(len(dataset_df)):
filepath = get_abs_path(
csv_path,
dataset_df[feature["name"]][i]