How do I apply tf.map_fn to a sequence function? Getting error: TensorArray dtype is string but Op is trying to write dtype uint8
I am writing a sequence for a sequence model that maps video to text. I have video frames encoded as JPEG strings in the SequenceExample prototype sequence function. When building my input pipeline, I do the following to get an array of decoded jpegs:
encoded_video, caption = parse_sequence_example(
serialized_sequence_example,
video_feature="video/frames",
caption_feature="video/caption_ids")
decoded_video = tf.map_fn(lambda x: tf.image.decode_jpeg(x, channels=3), encoded_video)
However, I am getting the following error:
InvalidArgumentError (see above for traceback): TensorArray dtype is string but Op is trying to write dtype uint8.
My goal is to apply image = tf.image.convert_image_dtype(image, dtype=tf.float32)
after decoding to get uint8 pixel values ββbetween [0.255] to float between [0.1].
I tried the following:
decoded_video = tf.map_fn(lambda x: tf.image.decode_jpeg(x, channels=3), encoded_video, dtype=tf.uint8)
converted_video = tf.map_fn(lambda x: tf.image.convert_image_dtype(x, dtype=tf.float32), decoded_video)
However, I still get the same error. Anyone can figure out what could go wrong? Thanks in advance.
+3
source to share