如何解决如何为LSTM填充帧的输入序列?
我正在使用CNN + LSTM架构对人类的意识水平进行分类。我一直在尝试填充我的数据集,并将其预处理为每5秒拍摄的帧。
我分为3类0、5和10(感知范围)和180个视频,我:
- 转换为框架。
- 旋转它们以确保所有面孔都是垂直的。
- 从框架中提取人脸
- 将每个类别中的所有帧合并到一个新文件夹中(例如,将10类的所有帧合并在一起,并且每个类别几乎完美平衡,除了1个类别的帧比其他类别少1%)。
- 将它们分为训练(95%),验证(5%)和测试(5%)。
从目录获取火车数据集:
#BATCH_SIZE = 32
#SIZE = (224,224)
#SEED = 42
train_dataset = image_dataset_from_directory(
directory=TRAIN_DIR,labels="inferred",label_mode="int",class_names=["0","10","5"],batch_size=BATCH_SIZE,image_size=SIZE,seed=SEED,subset=None,interpolation="bilinear",follow_links=False,)
因此,在将帧发送到CNN + LSTM之前,我需要对帧进行填充以确保其大小均匀
train_dataset = sequence.pad_sequences(train_dataset,maxlen=BATCH_SIZE,padding="post",truncating="post")
# Dataset shape
<BatchDataset shapes: ((None,None,224,3),(None,None)),types: (tf.float32,tf.int32)>
但是出现以下错误:
InvalidArgumentError: assertion failed: [Unable to decode bytes as JPEG,PNG,GIF,or BMP]
[[{{node decode_image/cond_jpeg/else/_1/decode_image/cond_jpeg/cond_png/else/_20/decode_image/cond_jpeg/cond_png/cond_gif/else/_39/decode_image/cond_jpeg/cond_png/cond_gif/Assert/Assert}}]] [Op:IteratorGetNext]
Also if do not pad them I get the following error which is what I was told to do from this question。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。