code: def predict(
      path_or_dir,
      config_files,
      checkpoint,
      override_params,
      output_path,
      save_media_to,
      min_prob,
      max_detections,
      only_class,
      ignore_class,
      debug,
  ):
      """Obtain a model's predictions.
  
      Receives either `config_files` or `checkpoint` in order to load the correct
      model. Afterwards, runs the model through the inputs specified by
      `path-or-dir`, returning predictions according to the format specified by
      `output`.
  
      Additional model behavior may be modified with `min-prob`, `only-class` and
      `ignore-class`.
      """
      if debug:
          tf.logging.set_verbosity(tf.logging.DEBUG)
      else:
          tf.logging.set_verbosity(tf.logging.ERROR)
  
      if only_class and ignore_class:
          click.echo(
              "Only one of `only-class` or `ignore-class` may be specified."
          )
          return
  
      # Process the input and get the actual files to predict.
      files = resolve_files(path_or_dir)
      if not files:
          error = "No files to predict found. Accepted formats are: {}.".format(
              ", ".join(IMAGE_FORMATS + VIDEO_FORMATS)
          )
          click.echo(error)
          return
      else:
          click.echo("Found {} files to predict.".format(len(files)))
  
      # Build the `Formatter` based on the outputs, which automatically writes
      # the formatted output to all the requested output files.
      if output_path == "-":
          output = sys.stdout
      else:
          output = open(output_path, "w")
  
      # Create `save_media_to` if specified and it doesn't exist.
      if save_media_to:
          tf.gfile.MakeDirs(save_media_to)
  
      # Resolve the config to use and initialize the model.
      if checkpoint:
          config = get_checkpoint_config(checkpoint)
      elif config_files:
          config = get_config(config_files)
      else:
          click.echo(
              "Neither checkpoint not config specified, assuming `accurate`."
          )
          config = get_checkpoint_config("accurate")
  
      if override_params:
          config = override_config_params(config, override_params)
  
      # Filter bounding boxes according to `min_prob` and `max_detections`.
      if config.model.type == "fasterrcnn":
          if config.model.network.with_rcnn:
              config.model.rcnn.proposals.total_max_detections = (
                  max_detections
              )
          else:
              config.model.rpn.proposals.post_nms_top_n = max_detections
          config.model.rcnn.proposals.min_prob_threshold = min_prob
      elif config.model.type == "ssd":
          config.model.proposals.total_max_detections = max_detections
          config.model.proposals.min_prob_threshold = min_prob
      else:
          raise ValueError(
              "Model type '{}' not supported".format(config.model.type)
          )
  
      # Instantiate the model indicated by the config.
      network = PredictorNetwork(config)
  
      # Iterate over files and run the model on each.
      for file in files:
          # Get the media output path, if media storage is requested.
          save_path = (
              os.path.join(
                  save_media_to,
                  "pred_{}".format(os.path.basename(file)),
              )
              if save_media_to
              else None
          )
  
          file_type = get_file_type(file)
          predictor = (
              predict_image if file_type == "image" else predict_video
          )
  
          objects = predictor(
              network,
              file,
              only_classes=only_class,
              ignore_classes=ignore_class,
              save_path=save_path,
          )
  
          # TODO: Not writing jsons for video files for now.
          if objects is not None and file_type == "image":
              output.write(
                  json.dumps(
                      {
                          "file": file,
                          "objects": objects,
                      }
                  )
                  + "\n"
              )
  
      output.close()
  
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 6 for calling a global function with example usage: predict(path_or_dir, config_files, checkpoint, override_params, output_path, save_media_to, min_prob, max_detections, only_class, ignore_class, debug) without return types