# Path: automl_video_ondevice/types.py
# class Format(enum.Enum):
#   UNDEFINED = 0
#   TFLITE = 1
#   TENSORFLOW = 2


import json
import re
from automl_video_ondevice.types import Format
      re.sub(
          r'[\n\s]*}[\n\s]+item[\n\s]*{[\n\s]*', '\n}, \n{\n',
          re.sub(r'[\n\s]*name:\s*"', '\n  "name": "',
                 re.sub(r'\n?\s+id:\s*', ',\n  "id": ', label_map)))) + ']'
  parsed_label_map = json.loads(label_map_json)

  # TensorFlow maps by id to name.
  # TFLite maps by list index to name, ditching the id.

  label_map = dict()
  label_list = list()
  for item in parsed_label_map:
    label_map[item['id']] = item['name']
    label_list.append(item['name'])

  return label_map, label_list


def format_from_filename(filename):
  """Determines format of file from the filename.

  Args:
    filename: The filename to parse.

  Returns:
    The format of the file.
  """
  if filename.endswith('.tflite'):
    return Format.TFLITE
  if filename.endswith('.pb'):

# Path: automl_video_ondevice/types.py
# class Format(enum.Enum):
#   UNDEFINED = 0
#   TFLITE = 1
#   TENSORFLOW = 2


# Path: automl_video_ondevice/utils.py
import json
import re
from automl_video_ondevice.types import Format

      re.sub(
          r'[\n\s]*}[\n\s]+item[\n\s]*{[\n\s]*', '\n}, \n{\n',
          re.sub(r'[\n\s]*name:\s*"', '\n  "name": "',
                 re.sub(r'\n?\s+id:\s*', ',\n  "id": ', label_map)))) + ']'
  parsed_label_map = json.loads(label_map_json)

  # TensorFlow maps by id to name.
  # TFLite maps by list index to name, ditching the id.

  label_map = dict()
  label_list = list()
  for item in parsed_label_map:
    label_map[item['id']] = item['name']
    label_list.append(item['name'])

  return label_map, label_list


def format_from_filename(filename):
  """Determines format of file from the filename.

  Args:
    filename: The filename to parse.

  Returns:
    The format of the file.
  """
  if filename.endswith('.tflite'):
    return Format.TFLITE
  if filename.endswith('.pb'):

    return Format.TENSORFLOW