code: def predict_image(
      network,
      path,
      only_classes=None,
      ignore_classes=None,
      save_path=None,
  ):
      click.echo("Predicting {}...".format(path), nl=False)
  
      # Open and read the image to predict.
      with tf.gfile.Open(path, "rb") as f:
          try:
              image = Image.open(f).convert("RGB")
          except (tf.errors.OutOfRangeError, OSError) as e:
              click.echo()
              click.echo(
                  "Error while processing {}: {}".format(path, e)
              )
              return
  
      # Run image through the network.
      objects = network.predict_image(image)
  
      # Filter the results according to the user input.
      objects = filter_classes(
          objects,
          only_classes=only_classes,
          ignore_classes=ignore_classes,
      )
  
      # Save predicted image.
      if save_path:
          vis_objects(np.array(image), objects).save(save_path)
  
      click.echo(" done.")
      return objects
  
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 4 for calling a global function with example usage: predict_image(network, path, only_classes, ignore_classes, save_path) and returns: objects