code: def datagen(self, frames, mels):
      img_batch, mel_batch, frame_batch, coords_batch = [], [], [], []
  
      if self.box[0] == -1:
          if not self.static:
              face_det_results = self.face_detect(
                  frames
              )  # BGR2RGB for CNN face detection
          else:
              face_det_results = self.face_detect([frames[0]])
      else:
          print(
              "Using the specified bounding box instead of face detection..."
          )
          y1, y2, x1, x2 = self.box
          face_det_results = [
              [f[y1:y2, x1:x2], (y1, y2, x1, x2)] for f in frames
          ]
  
      for i, m in enumerate(mels):
          idx = 0 if self.static else i % len(frames)
          frame_to_save = frames[idx].copy()
          face, coords = face_det_results[idx].copy()
  
          face = cv2.resize(face, (self.img_size, self.img_size))
  
          img_batch.append(face)
          mel_batch.append(m)
          frame_batch.append(frame_to_save)
          coords_batch.append(coords)
  
          if len(img_batch) >= self.wav2lip_batch_size:
              img_batch, mel_batch = np.asarray(img_batch), np.asarray(
                  mel_batch
              )
  
              img_masked = img_batch.copy()
              img_masked[:, self.img_size // 2 :] = 0
  
              img_batch = (
                  np.concatenate((img_masked, img_batch), axis=3)
                  / 255.0
              )
              mel_batch = np.reshape(
                  mel_batch,
                  [
                      len(mel_batch),
                      mel_batch.shape[1],
                      mel_batch.shape[2],
                      1,
                  ],
              )
  
              yield img_batch, mel_batch, frame_batch, coords_batch
              img_batch, mel_batch, frame_batch, coords_batch = (
                  [],
                  [],
                  [],
                  [],
              )
  
      if len(img_batch) > 0:
          img_batch, mel_batch = np.asarray(img_batch), np.asarray(
              mel_batch
          )
  
          img_masked = img_batch.copy()
          img_masked[:, self.img_size // 2 :] = 0
  
          img_batch = (
              np.concatenate((img_masked, img_batch), axis=3) / 255.0
          )
          mel_batch = np.reshape(
              mel_batch,
              [
                  len(mel_batch),
                  mel_batch.shape[1],
                  mel_batch.shape[2],
                  1,
              ],
          )
  
          yield img_batch, mel_batch, frame_batch, coords_batch
  
file_path: PaddleHub/modules/image/Image_gan/gan/wav2lip/model.py
imports: from os import listdir, path, makedirs
  import platform
  import numpy
  import scipy, cv2, os, sys, argparse
  import json, subprocess, random, string
  from tqdm import tqdm
  from glob import glob
  import paddle
  from paddle.utils.download import get_weights_path_from_url
  from ppgan.faceutils import face_detection
  from ppgan.utils import audio
  from ppgan.models.generators.wav2lip import Wav2Lip
label_desc: Use image node_id 4 for calling the Wav2LipPredictor obj's underlying member method code with example usage: obj.datagen(frames, mels) without return types