# 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/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
from PIL import Image
from PIL import ImageDraw
from pycoral.adapters import common
from pycoral.utils.edgetpu import make_interpreter
```
"""



_NUM_KEYPOINTS = 17


def main():
  parser = argparse.ArgumentParser(
      formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument(
      '-m', '--model', required=True, help='File path of .tflite file.')
  parser.add_argument(
      '-i', '--input', required=True, help='Image to be classified.')
  parser.add_argument(
      '--output',
      default='movenet_result.jpg',
      help='File path of the output image.')
  args = parser.parse_args()

  interpreter = make_interpreter(args.model)
  interpreter.allocate_tensors()

  img = Image.open(args.input)
  resized_img = img.resize(common.input_size(interpreter), Image.ANTIALIAS)
  common.set_input(interpreter, resized_img)

  interpreter.invoke()


# 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/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/movenet_pose_estimation.py
import argparse
from PIL import Image
from PIL import ImageDraw
from pycoral.adapters import common
from pycoral.utils.edgetpu import make_interpreter

```
"""



_NUM_KEYPOINTS = 17


def main():
  parser = argparse.ArgumentParser(
      formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument(
      '-m', '--model', required=True, help='File path of .tflite file.')
  parser.add_argument(
      '-i', '--input', required=True, help='Image to be classified.')
  parser.add_argument(
      '--output',
      default='movenet_result.jpg',
      help='File path of the output image.')
  args = parser.parse_args()

  interpreter = make_interpreter(args.model)
  interpreter.allocate_tensors()

  img = Image.open(args.input)
  resized_img = img.resize(common.input_size(interpreter), Image.ANTIALIAS)
  common.set_input(interpreter, resized_img)

  interpreter.invoke()


  pose = common.output_tensor(interpreter, 0).copy().reshape(_NUM_KEYPOINTS, 3)