# Path: pycoral/adapters/common.py
# def output_tensor(interpreter, i):
# def input_details(interpreter, key):
# def input_size(interpreter):
# def input_tensor(interpreter):
# def set_input(interpreter, data):
# def set_resized_input(interpreter, size, resize):
# 
# Path: pycoral/adapters/segment.py
# def get_output(interpreter):
# 
# Path: pycoral/utils/edgetpu.py
# def make_interpreter(model_path_or_content, device=None, delegate=None):
#   """Creates a new ``tf.lite.Interpreter`` instance using the given model.
# 
#   **Note:** If you have multiple Edge TPUs, you should always specify the
#   ``device`` argument.
# 
#   Args:
#      model_path_or_content (str or bytes): `str` object is interpreted as
#        model path, `bytes` object is interpreted as model content.
#      device (str): The Edge TPU device you want:
# 
#        + None      -- use any Edge TPU (this is the default)
#        + ":<N>"    -- use N-th Edge TPU (this corresponds to the enumerated
#          index position from :func:`list_edge_tpus`)
#        + "usb"     -- use any USB Edge TPU
#        + "usb:<N>" -- use N-th USB Edge TPU
#        + "pci"     -- use any PCIe Edge TPU
#        + "pci:<N>" -- use N-th PCIe Edge TPU
# 
#        If left as None, you cannot reliably predict which device you'll get.
#        So if you have multiple Edge TPUs and want to run a specific model on
#        each one, then you must specify the device.
#      delegate: A pre-loaded Edge TPU delegate object, as provided by
#        :func:`load_edgetpu_delegate`. If provided, the `device` argument
#        is ignored.
# 
#   Returns:
#      New ``tf.lite.Interpreter`` instance.
#   """
#   if delegate:
#     delegates = [delegate]
#   else:
#     delegates = [load_edgetpu_delegate({'device': device} if device else {})]
#   if isinstance(model_path_or_content, bytes):
#     return tflite.Interpreter(
#         model_content=model_path_or_content, experimental_delegates=delegates)
#   else:
#     return tflite.Interpreter(
#         model_path=model_path_or_content, experimental_delegates=delegates)


import argparse
import numpy as np
from PIL import Image
from pycoral.adapters import common
from pycoral.adapters import segment
from pycoral.utils.edgetpu import make_interpreter
  return colormap[label]


def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('--model', required=True,
                      help='Path of the segmentation model.')
  parser.add_argument('--input', required=True,
                      help='File path of the input image.')
  parser.add_argument('--output', default='semantic_segmentation_result.jpg',
                      help='File path of the output image.')
  parser.add_argument(
      '--keep_aspect_ratio',
      action='store_true',
      default=False,
      help=(
          'keep the image aspect ratio when down-sampling the image by adding '
          'black pixel padding (zeros) on bottom or right. '
          'By default the image is resized and reshaped without cropping. This '
          'option should be the same as what is applied on input images during '
          'model training. Otherwise the accuracy may be affected and the '
          'bounding box of detection result may be stretched.'))
  args = parser.parse_args()

  interpreter = make_interpreter(args.model, device=':0')
  interpreter.allocate_tensors()
  width, height = common.input_size(interpreter)

  img = Image.open(args.input)
  if args.keep_aspect_ratio:

# Path: pycoral/adapters/common.py
# def output_tensor(interpreter, i):
# def input_details(interpreter, key):
# def input_size(interpreter):
# def input_tensor(interpreter):
# def set_input(interpreter, data):
# def set_resized_input(interpreter, size, resize):
# 
# Path: pycoral/adapters/segment.py
# def get_output(interpreter):
# 
# Path: pycoral/utils/edgetpu.py
# def make_interpreter(model_path_or_content, device=None, delegate=None):
#   """Creates a new ``tf.lite.Interpreter`` instance using the given model.
# 
#   **Note:** If you have multiple Edge TPUs, you should always specify the
#   ``device`` argument.
# 
#   Args:
#      model_path_or_content (str or bytes): `str` object is interpreted as
#        model path, `bytes` object is interpreted as model content.
#      device (str): The Edge TPU device you want:
# 
#        + None      -- use any Edge TPU (this is the default)
#        + ":<N>"    -- use N-th Edge TPU (this corresponds to the enumerated
#          index position from :func:`list_edge_tpus`)
#        + "usb"     -- use any USB Edge TPU
#        + "usb:<N>" -- use N-th USB Edge TPU
#        + "pci"     -- use any PCIe Edge TPU
#        + "pci:<N>" -- use N-th PCIe Edge TPU
# 
#        If left as None, you cannot reliably predict which device you'll get.
#        So if you have multiple Edge TPUs and want to run a specific model on
#        each one, then you must specify the device.
#      delegate: A pre-loaded Edge TPU delegate object, as provided by
#        :func:`load_edgetpu_delegate`. If provided, the `device` argument
#        is ignored.
# 
#   Returns:
#      New ``tf.lite.Interpreter`` instance.
#   """
#   if delegate:
#     delegates = [delegate]
#   else:
#     delegates = [load_edgetpu_delegate({'device': device} if device else {})]
#   if isinstance(model_path_or_content, bytes):
#     return tflite.Interpreter(
#         model_content=model_path_or_content, experimental_delegates=delegates)
#   else:
#     return tflite.Interpreter(
#         model_path=model_path_or_content, experimental_delegates=delegates)


# Path: examples/semantic_segmentation.py
import argparse
import numpy as np
from PIL import Image
from pycoral.adapters import common
from pycoral.adapters import segment
from pycoral.utils.edgetpu import make_interpreter

  return colormap[label]


def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('--model', required=True,
                      help='Path of the segmentation model.')
  parser.add_argument('--input', required=True,
                      help='File path of the input image.')
  parser.add_argument('--output', default='semantic_segmentation_result.jpg',
                      help='File path of the output image.')
  parser.add_argument(
      '--keep_aspect_ratio',
      action='store_true',
      default=False,
      help=(
          'keep the image aspect ratio when down-sampling the image by adding '
          'black pixel padding (zeros) on bottom or right. '
          'By default the image is resized and reshaped without cropping. This '
          'option should be the same as what is applied on input images during '
          'model training. Otherwise the accuracy may be affected and the '
          'bounding box of detection result may be stretched.'))
  args = parser.parse_args()

  interpreter = make_interpreter(args.model, device=':0')
  interpreter.allocate_tensors()
  width, height = common.input_size(interpreter)

  img = Image.open(args.input)
  if args.keep_aspect_ratio:

    resized_img, _ = common.set_resized_input(