python - AttributeError:模块'keras.utils'没有数据生成器的属性'Sequence'
问题描述
我尝试使用 Keras 制作视频帧生成器,但出现上述错误。对于神经网络训练,使用 Keras.model.fit_generator 方法。这需要一个生成器来读取并向 Keras 引擎生成训练数据。
import glob
import os
import sys
#from gtts import utils
import tensorflow as tf
import numpy as np
import pandas as pd
import tensorflow as tf
from sklearn.preprocessing import LabelEncoder
import keras
from frame import files2frames, images_normalize, frames_show
class FramesGenerator(tf.keras.utils.Sequence):
"""Read and yields video frames/optical flow for Keras.model.fit_generator
Generator can be used for multi-threading.
Substantial initialization and checks upfront, including one-hot-encoding of labels.
"""
def __init__(self, sPath: str, \
nBatchSize: int, nFrames: int, nHeight: int, nWidth: int, nChannels: int, \
liClassesFull: list = None, bShuffle: bool = True):
"""
Assume directory structure:
... / sPath / class / videoname / frames.jpg
"""
'Initialization'
self.nBatchSize = nBatchSize
self.nFrames = nFrames
self.nHeight = nHeight
self.nWidth = nWidth
self.nChannels = nChannels
self.tuXshape = (nFrames, nHeight, nWidth, nChannels)
self.bShuffle = bShuffle
解决方案
推荐阅读
- python - 运行时错误 此 GPIO 通道已存在 PWM 对象
- visual-studio - 找不到或创建 .env 文件
- javascript - 单击文本时尝试更改屏幕,但意外出现“;” 改为错误
- python - 遍历嵌套在 dicts 中的多级列表的函数无法正常工作
- php -
我有一个文本框,由 jquery“观察”几个动作,所有代码都是“搜索即输入”表单的一部分。好吧,一切都在 Mozilla 上完美运行,但在 Chrome 中,文本框在第一次点击后失去焦点,所以我必须再次点击文本框才能继续搜索。有什么线索吗?我的经验导致我遇到错误
- javascript - 按钮不响应点击 JQuery
- java - 如何使用 SQL 查询删除列与任何集合匹配的行?
- python - Pytest 导入 pyhive 失败
- excel - 如何优化这个对 SQL 数据进行排序和格式化的宏?
- scala - 在 Intellij 中使用带有 sbt 的 GraalVM 需要哪些设置?