Reputation: 149
I am writing a sequence to sequence model that maps video to text. I have the frames of the video encoded as JPEG strings in a sequence feature of the SequenceExample proto. When building my input pipeline, I am doing 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 it to get the pixel values of uint8 between [0,255] to float between [0,1].
I tried to 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. Anybody has any idea what might be going wrong? Thanks in advance.
Upvotes: 4
Views: 1971
Reputation: 149
Nevermind. Just had to explicitly add a dtype of tf.float32 in the following line:
converted_video = tf.map_fn(lambda x: tf.image.convert_image_dtype(x, dtype=tf.float32), decoded_video, dtype=tf.float32)
Upvotes: 5