def _data_generator(self, batch_file_list):
    videos = np.zeros((self._batch_size, *self.video_shape), dtype=np.float32)
    audios = np.zeros((self._batch_size, *self.audio_shape), dtype=np.float32)
    labels = []
    for (i, filename) in enumerate(batch_file_list):
        length = self.length_dict[filename]
        frame_idx = np.random.choice(length, self.sel_frames)
        for (j, idx) in enumerate(frame_idx):
            videos[((i * self.sel_frames) + j)] = io.imread((Path(self.video_root) / '{}_{}.jpg'.format(filename, idx)))
            audios[((i * self.sel_frames) + j)] = np.load((Path(self.audio_root) / '{}_{}.npy'.format(filename, idx)))[(..., None)]
        labels += ([self.label_dict[filename]] * self.sel_frames)
    if self.video_preproc:
        videos = self.video_preproc(videos)
    if self.audio_preproc:
        audios = self.audio_preproc(audios)
    labels = keras.utils.to_categorical(labels, self._n_classes)
    X = [videos, audios]
    y = []
    if self.ret_label_X:
        X += [labels]
    if self.ret_label_y:
        y += [labels]
    return (X, y)
def _data_generator(self, batch_file_list):
    videos = np.zeros((self._batch_size, *self.video_shape), dtype=np.float32)
    audios = np.zeros((self._batch_size, *self.audio_shape), dtype=np.float32)
    labels = []
    for (i, filename) in enumerate(batch_file_list):
        length = self.length_dict[filename]
        frame_idx = np.random.choice(length, self.sel_frames)
        for (j, idx) in enumerate(frame_idx):
            videos[((i * self.sel_frames) + j)] = io.imread((Path(self.video_root) / '{}_{}.jpg'.format(filename, idx)))
            audios[((i * self.sel_frames) + j)] = np.load((Path(self.audio_root) / '{}_{}.npy'.format(filename, idx)))[(..., None)]
        labels += ([self.label_dict[filename]] * self.sel_frames)
    if self.video_preproc:
        videos = self.video_preproc(videos)
    if self.audio_preproc:
        audios = self.audio_preproc(audios)
    labels = keras.utils.to_categorical(labels, self._n_classes)
    X = [videos, audios]
    y = []
    if self.ret_label_X:
        X += [labels]
    if self.ret_label_y:
        y += [labels]
    return (X, y)