Я пытаюсь построить конвейеры данных из tfrecords, вот мой код
def _parse_image_function(example_proto):
keys_to_features = {
'image/encoded': tf.io.FixedLenFeature((), tf.string),
'image/format': tf.io.FixedLenFeature((), tf.string, default_value='jpeg'),
'image/height': tf.io.FixedLenFeature([1], tf.int64),
'image/width': tf.io.FixedLenFeature([1], tf.int64),
'image/channels': tf.io.FixedLenFeature([1], tf.int64),
'image/shape': tf.io.FixedLenFeature([3], tf.int64),
'image/object/bbox/xmin': tf.io.VarLenFeature(dtype=tf.float32),
'image/object/bbox/ymin': tf.io.VarLenFeature(dtype=tf.float32),
'image/object/bbox/xmax': tf.io.VarLenFeature(dtype=tf.float32),
'image/object/bbox/ymax': tf.io.VarLenFeature(dtype=tf.float32),
'image/object/bbox/label': tf.io.VarLenFeature(dtype=tf.int64),
'image/object/bbox/difficult': tf.io.VarLenFeature(dtype=tf.int64),
'image/object/bbox/truncated': tf.io.VarLenFeature(dtype=tf.int64),
}
example = tf.io.parse_single_example(example_proto, keys_to_features)
image = tf.io.decode_raw(example['image/encoded'], tf.int32)
return image
Затем я получаю изображение после декодирования
for img in train_ds:
print(img.numpy())
Но я получил ошибку
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __inference_Dataset_map__parse_image_function_78}} Input to DecodeRaw has length 286478 that is not a multiple of 4, the size of int32
[[{{node DecodeRaw}}]] [Op:IteratorGetNextSync]
Как мне это исправить?