# Path: moonlight/glyphs/convolutional.py
# DEFAULT_RUN_MIN_LENGTH = 3
# class Convolutional1DGlyphClassifier(base.BaseGlyphClassifier):
#   def __init__(self, run_min_length=DEFAULT_RUN_MIN_LENGTH):
#   def staffline_predictions(self):
#   def _build_detected_glyphs(self, predictions_arr):
#   def _create_glyph_arr(self, staff_index, y_position, x, type_value):
#   def get_detected_glyphs(self):
# 
# Path: moonlight/staves/staffline_extractor.py
# DEFAULT_TARGET_HEIGHT = 18
# DEFAULT_NUM_SECTIONS = 19
# DEFAULT_STAFFLINE_DISTANCE_MULTIPLE = 3
#   STAFF = 0
#   POSITION = 1
#   Y = 2
#   X = 3
# class Axes(enum.IntEnum):
# class StafflineExtractor(object):
# class StafflinePatchExtractor(object):
# def get_staffline(y_position, extracted_staff_arr):
# def y_position_to_index(y_position, num_stafflines):
#   def __init__(self,
#                image,
#                staves,
#                target_height=DEFAULT_TARGET_HEIGHT,
#                num_sections=DEFAULT_NUM_SECTIONS,
#                staffline_distance_multiple=DEFAULT_STAFFLINE_DISTANCE_MULTIPLE):
#   def extract_staves(self):
#     def do_extract_staves():
#       def extract_staff(i):
#         def extract_staffline_by_index(j):
#   def _extract_staffline(self, staff_y, staffline_distance, staffline_num):
#   def _get_resized_width(self, staffline_distance):
#   def _get_staffline_window_size(self, staffline_distance):
#   def __init__(self,
#                num_sections=DEFAULT_NUM_SECTIONS,
#                patch_height=15,
#                patch_width=12,
#                run_options=None):
#   def extract_staff_strip(self, filename, staff_index, y_position):
#   def extract_staff_patch(self, filename, staff_index, y_position, image_x):
#   def page_patch_iterator(self, filename):
#     def generator():
#   def make_patch_id(filename, staff_index, y_position, image_x):
# 
# Path: moonlight/util/patches.py
# def patches_1d(images, patch_width):
#   def do_extract_patches():
#   def empty_patches():


import tensorflow as tf
from tensorflow.contrib import graph_editor as contrib_graph_editor
from tensorflow.contrib import util as contrib_util
from tensorflow_estimator.python.estimator.canned import prediction_keys
from moonlight.glyphs import convolutional
from moonlight.staves import staffline_extractor
from moonlight.util import patches
    """
    super(SavedConvolutional1DClassifier, self).__init__(*args, **kwargs)
    sess = tf.get_default_session()
    graph_def = tf.saved_model.loader.load(
        sess, [tf.saved_model.tag_constants.SERVING], saved_model_dir)

    signature = None
    for key in _SIGNATURE_KEYS:
      if key in graph_def.signature_def:
        signature = graph_def.signature_def[key]
        break
    else:
      # for/else is only executed if the loop completes without breaking.
      raise ValueError('One of the following signatures must be present: %s' %
                       _SIGNATURE_KEYS)

    input_info = signature.inputs['input']
    if not (len(input_info.tensor_shape.dim) == 3 and
            input_info.tensor_shape.dim[1].size > 0 and
            input_info.tensor_shape.dim[2].size > 0):
      raise ValueError('Invalid patches input: ' + str(input_info))
    patch_height = input_info.tensor_shape.dim[1].size
    patch_width = input_info.tensor_shape.dim[2].size

    with tf.name_scope('saved_classifier'):
      self.staffline_extractor = staffline_extractor.StafflineExtractor(
          structure.staff_remover.remove_staves,
          structure.staff_detector,
          num_sections=num_sections,
          target_height=patch_height)

# Path: moonlight/glyphs/convolutional.py
# DEFAULT_RUN_MIN_LENGTH = 3
# class Convolutional1DGlyphClassifier(base.BaseGlyphClassifier):
#   def __init__(self, run_min_length=DEFAULT_RUN_MIN_LENGTH):
#   def staffline_predictions(self):
#   def _build_detected_glyphs(self, predictions_arr):
#   def _create_glyph_arr(self, staff_index, y_position, x, type_value):
#   def get_detected_glyphs(self):
# 
# Path: moonlight/staves/staffline_extractor.py
# DEFAULT_TARGET_HEIGHT = 18
# DEFAULT_NUM_SECTIONS = 19
# DEFAULT_STAFFLINE_DISTANCE_MULTIPLE = 3
#   STAFF = 0
#   POSITION = 1
#   Y = 2
#   X = 3
# class Axes(enum.IntEnum):
# class StafflineExtractor(object):
# class StafflinePatchExtractor(object):
# def get_staffline(y_position, extracted_staff_arr):
# def y_position_to_index(y_position, num_stafflines):
#   def __init__(self,
#                image,
#                staves,
#                target_height=DEFAULT_TARGET_HEIGHT,
#                num_sections=DEFAULT_NUM_SECTIONS,
#                staffline_distance_multiple=DEFAULT_STAFFLINE_DISTANCE_MULTIPLE):
#   def extract_staves(self):
#     def do_extract_staves():
#       def extract_staff(i):
#         def extract_staffline_by_index(j):
#   def _extract_staffline(self, staff_y, staffline_distance, staffline_num):
#   def _get_resized_width(self, staffline_distance):
#   def _get_staffline_window_size(self, staffline_distance):
#   def __init__(self,
#                num_sections=DEFAULT_NUM_SECTIONS,
#                patch_height=15,
#                patch_width=12,
#                run_options=None):
#   def extract_staff_strip(self, filename, staff_index, y_position):
#   def extract_staff_patch(self, filename, staff_index, y_position, image_x):
#   def page_patch_iterator(self, filename):
#     def generator():
#   def make_patch_id(filename, staff_index, y_position, image_x):
# 
# Path: moonlight/util/patches.py
# def patches_1d(images, patch_width):
#   def do_extract_patches():
#   def empty_patches():


# Path: moonlight/glyphs/saved_classifier.py
import tensorflow as tf
from tensorflow.contrib import graph_editor as contrib_graph_editor
from tensorflow.contrib import util as contrib_util
from tensorflow_estimator.python.estimator.canned import prediction_keys
from moonlight.glyphs import convolutional
from moonlight.staves import staffline_extractor
from moonlight.util import patches

    """
    super(SavedConvolutional1DClassifier, self).__init__(*args, **kwargs)
    sess = tf.get_default_session()
    graph_def = tf.saved_model.loader.load(
        sess, [tf.saved_model.tag_constants.SERVING], saved_model_dir)

    signature = None
    for key in _SIGNATURE_KEYS:
      if key in graph_def.signature_def:
        signature = graph_def.signature_def[key]
        break
    else:
      # for/else is only executed if the loop completes without breaking.
      raise ValueError('One of the following signatures must be present: %s' %
                       _SIGNATURE_KEYS)

    input_info = signature.inputs['input']
    if not (len(input_info.tensor_shape.dim) == 3 and
            input_info.tensor_shape.dim[1].size > 0 and
            input_info.tensor_shape.dim[2].size > 0):
      raise ValueError('Invalid patches input: ' + str(input_info))
    patch_height = input_info.tensor_shape.dim[1].size
    patch_width = input_info.tensor_shape.dim[2].size

    with tf.name_scope('saved_classifier'):
      self.staffline_extractor = staffline_extractor.StafflineExtractor(
          structure.staff_remover.remove_staves,
          structure.staff_detector,
          num_sections=num_sections,
          target_height=patch_height)

      stafflines = self.staffline_extractor.extract_staves()