code: def convert_image_annot(
      image_path,
      annot_path,
      target_image,
      target_annot,
      width,
      height,
      box_shrink=0.8,
      min_size=0.01,
      debug_dir=None,
  ):
      boxes = spacenet_utils.get_bounding_boxes(image_path, annot_path)
  
      # save as target image
      image_array = spacenet_utils.load_as_uint8(image_path)
      (c, h, w) = image_array.shape
  
      image = Image.fromarray(image_array.transpose([1, 2, 0]))
      image = image.resize((width, height), Image.ANTIALIAS)
      image.save(target_image)
      # print('Image saved to {}'.format(target_image))
  
      (scale, _) = util.get_image_scale((h, w), (height, width))
      h = height
      w = width
      assert c == 3, "Only 3-band data supported."
  
      annot = {
          "object": [],
          "filename": target_image,
          "annot_filename": target_annot,
          "size": {"depth": c, "height": h, "width": w},
          "num_blank": np.sum(np.mean(image_array, axis=0) == 0),
          "num_total": h * w,
      }
  
      h_threshold = annot["size"]["height"] * min_size
      w_threshold = annot["size"]["width"] * min_size
  
      for box in boxes:
          box = {
              "xmin": box[0],
              "xmax": box[1],
              "ymin": box[2],
              "ymax": box[3],
          }
  
          box = rescale_box(
              box, scale, annot["size"]
          )  # resize boxes to match image resize
          box = shrink_box(
              box, annot["size"], box_shrink
          )  # shrink boxes by box_shrink
          box = ensure_within_bounds(
              box, annot["size"]
          )  # make sure box within bounds of image
          box = {
              key: box[key].astype(int) for key in box.keys()
          }  # convert to integers
  
          obj = {"bndbox": box, "difficult": False, "name": "building"}
  
          if (
              obj["bndbox"]["xmax"] - obj["bndbox"]["xmin"]
          ) > w_threshold and (
              obj["bndbox"]["ymax"] - obj["bndbox"]["ymin"]
          ) > h_threshold:
              annot["object"].append(obj)
  
      with open(target_annot, "w") as f:
          json.dump(annot, f, indent=4)
  
      # print('Annotations saved to {}'.format(target_annot))
  
      # plot test image for inspection
      if debug_dir is not None:
          test_image_save = os.path.join(
              debug_dir, os.path.basename(target_image)
          )
          plot_image(target_image, target_annot, test_image_save)
  
      return annot
  
imports: import pickle
  import glob
  import os
  import json
  import spacenet_utils
  from PIL import Image, ImageDraw
  from collections import OrderedDict
  import ingest_utils
  import numpy
  from tqdm import tqdm
  import warnings
  from configargparse import ArgumentParser
  from neon.util.persist import get_data_cache_or_nothing
label_desc: Use image node_id 7 for calling a global function with example usage: convert_image_annot(image_path, annot_path, target_image, target_annot, width, height, box_shrink, min_size, debug_dir) and returns: annot