code: def predict_image(img, model_func):
      """
      Run detection on one image, using the TF callable.
      This function should handle the preprocessing internally.
  
      Args:
          img: an image
          model_func: a callable from the TF model.
              It takes image and returns (boxes, probs, labels, [masks])
  
      Returns:
          [DetectionResult]
      """
      orig_shape = img.shape[:2]
      resizer = CustomResize(
          cfg.PREPROC.TEST_SHORT_EDGE_SIZE, cfg.PREPROC.MAX_SIZE
      )
      resized_img = resizer.augment(img)
      scale = np.sqrt(
          resized_img.shape[0]
          * 1.0
          / img.shape[0]
          * resized_img.shape[1]
          / img.shape[1]
      )
      boxes, probs, labels, *masks = model_func(resized_img)
  
      # Some slow numpy postprocessing:
      boxes = boxes / scale
      # boxes are already clipped inside the graph, but after the floating point scaling, this may not be true any more.
      boxes = clip_boxes(boxes, orig_shape)
      if masks:
          full_masks = [
              _paste_mask(box, mask, orig_shape)
              for box, mask in zip(boxes, masks[0])
          ]
          masks = full_masks
      else:
          # fill with none
          masks = [None] * len(boxes)
  
      results = [
          DetectionResult(*args)
          for args in zip(boxes, probs, labels.tolist(), masks)
      ]
      return results
  
imports: import itertools
  import json
  import numpy
  import os
  import sys
  from collections import namedtuple
  from concurrent.futures import ThreadPoolExecutor
  from contextlib import ExitStack
  import cv2
  import pycocotools.mask
  import tqdm
  from scipy import interpolate
  from tensorpack.callbacks import Callback
  from tensorpack.tfutils.common import get_tf_version_tuple
  from tensorpack.utils import logger, get_tqdm
  from common import CustomResize, clip_boxes
  from config import config
  from data import get_eval_dataflow
  from dataset import DatasetRegistry
  from tensorpack.compat import tfv1
label_desc: Use image node_id 3 for calling a global function with example usage: predict_image(img, model_func) and returns: results