In the directory, images have names in the format ‘fileNo-x-y’. I’m trying to label the images with the x and y coordinates, but I’m getting issues due to the keypoint_labels function. Here’s what I’ve got so far:
train_ds = image_dataset_from_directory(
'C:/Users/joshu/Desktop/data',
label_mode='int',
image_size=[60, 80],
interpolation='nearest',
validation_split=0.2,
subset='training',
batch_size=64,
seed=42,
)
valid_ds = image_dataset_from_directory(
'C:/Users/joshu/Desktop/data',
label_mode='int',
image_size=[60, 80],
interpolation='nearest',
validation_split=0.2,
subset='validation',
batch_size=64,
seed=42,
)
# Data Pipeline
def convert_to_float(image, label):
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
return image, label
def keypoint_labels(image, label):
image_string = tf.io.read_file(image)
_, x, y = file_name.stem.split('-')
label = (int(x), int(y))
return image, (x, y)
AUTOTUNE = tf.data.experimental.AUTOTUNE
train = (
train_ds.map(keypoint_labels)
.map(convert_to_float)
.cache()
.prefetch(buffer_size=AUTOTUNE)
)
valid = (
valid_ds.map(keypoint_labels)
.map(convert_to_float)
.cache()
.prefetch(buffer_size=AUTOTUNE)
)
Any help or advice would be appreciated. If you need any more info let me know!