class_docstr: Visualize action predictions for videos or folder of images with precomputed
  and ground-truth boxes in AVA format.
class_docstr_tok: ["Visualize","action","predictions","for","videos","or","folder","of","images","with","precomputed","and","ground-truth","boxes","in","AVA","format","."]
docstr: Args:
      cfg (CfgNode): configs. Details can be found in
          slowfast/config/defaults.py
docstr_tok: ["Args",":","cfg","(","CfgNode",")",":","configs",".","Details","can","be","found","in","slowfast\/config\/defaults.py"]
code: def __init__(self, cfg):
      """
      Args:
          cfg (CfgNode): configs. Details can be found in
              slowfast/config/defaults.py
      """
      self.source = pathmgr.get_local_path(path=cfg.DEMO.INPUT_VIDEO)
      self.fps = None
      if pathmgr.isdir(self.source):
          self.fps = cfg.DEMO.FPS
          self.video_name = self.source.split("/")[-1]
          self.source = os.path.join(
              self.source, "{}_%06d.jpg".format(self.video_name)
          )
      else:
          self.video_name = self.source.split("/")[-1]
          self.video_name = self.video_name.split(".")[0]
  
      self.cfg = cfg
      self.cap = cv2.VideoCapture(self.source)
      if self.fps is None:
          self.fps = self.cap.get(cv2.CAP_PROP_FPS)
  
      self.total_frames = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT))
  
      self.display_width = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))
      self.display_height = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
  
      if not self.cap.isOpened():
          raise IOError("Video {} cannot be opened".format(self.source))
  
      self.output_file = None
  
      if cfg.DEMO.OUTPUT_FILE != "":
          self.output_file = self.get_output_file(cfg.DEMO.OUTPUT_FILE)
  
      self.pred_boxes, self.gt_boxes = load_boxes_labels(
          cfg,
          self.video_name,
          self.fps,
          self.display_width,
          self.display_height,
      )
  
      self.seq_length = cfg.DATA.NUM_FRAMES * cfg.DATA.SAMPLING_RATE
      self.no_frames_repeat = cfg.DEMO.SLOWMO
  
imports: import numpy
  import os
  import cv2
  import torch
  import tqdm
  import slowfast.utils.checkpoint
  import slowfast.utils.logging
  from slowfast.datasets.ava_helper import parse_bboxes_file
  from slowfast.datasets.cv2_transform import scale, scale_boxes
  from slowfast.datasets.utils import get_sequence
  from slowfast.models import build_model
  from slowfast.utils import misc
  from slowfast.utils.env import pathmgr
  from slowfast.visualization.utils import process_cv2_inputs
  from slowfast.visualization.video_visualizer import VideoVisualizer
label_desc: Use image node_id 1 to create a new AVAVisualizerWithPrecomputedBox object  with example: obj = AVAVisualizerWithPrecomputedBox(cfg)