code: def predict_video(
      network,
      path,
      only_classes=None,
      ignore_classes=None,
      save_path=None,
  ):
      if save_path:
          # We hardcode the video output to mp4 for the time being.
          save_path = os.path.splitext(save_path)[0] + ".mp4"
          try:
              writer = skvideo.io.FFmpegWriter(save_path)
          except AssertionError as e:
              tf.logging.error(e)
              tf.logging.error(
                  "Please install ffmpeg before making video predictions."
              )
              exit()
      else:
          click.echo(
              "Video not being saved. Note that for the time being, no JSON "
              "output is being generated. Did you mean to specify `--save-path`?"
          )
  
      num_of_frames = int(
          skvideo.io.ffprobe(path)["video"]["@nb_frames"]
      )
  
      video_progress_bar = click.progressbar(
          skvideo.io.vreader(path),
          length=num_of_frames,
          label="Predicting {}".format(path),
      )
  
      colormap = build_colormap()
  
      objects_per_frame = []
      with video_progress_bar as bar:
          try:
              start_time = time.time()
              for idx, frame in enumerate(bar):
                  # Run image through network.
                  objects = network.predict_image(frame)
  
                  # Filter the results according to the user input.
                  objects = filter_classes(
                      objects,
                      only_classes=only_classes,
                      ignore_classes=ignore_classes,
                  )
  
                  objects_per_frame.append(
                      {"frame": idx, "objects": objects}
                  )
  
                  # Draw the image and write it to the video file.
                  if save_path:
                      image = vis_objects(
                          frame, objects, colormap=colormap
                      )
                      writer.writeFrame(np.array(image))
  
              stop_time = time.time()
              click.echo(
                  "fps: {0:.1f}".format(
                      num_of_frames / (stop_time - start_time)
                  )
              )
          except RuntimeError as e:
              click.echo()  # Error prints next to progress bar otherwise.
              click.echo(
                  "Error while processing {}: {}".format(path, e)
              )
              if save_path:
                  click.echo(
                      "Partially processed video file saved in {}".format(
                          save_path
                      )
                  )
  
      if save_path:
          writer.close()
  
      return objects_per_frame
  
file_path: luminoth/luminoth/predict.py
imports: import click
  import json
  import numpy
  import os
  import skvideo.io
  import sys
  import time
  import tensorflow
  from PIL import Image
  from luminoth.tools.checkpoint import get_checkpoint_config
  from luminoth.utils.config import get_config, override_config_params
  from luminoth.utils.predicting import PredictorNetwork
  from luminoth.vis import build_colormap, vis_objects
label_desc: Use image node_id 5 for calling a global function with example usage: predict_video(network, path, only_classes, ignore_classes, save_path) and returns: objects_per_frame