# Path: net_modules/hourglass.py
# class HourglassOptions:
#     def layer(p):
# def _hourglass_builder(x, layer_def, net_type=None, extra_highlevel_feature=None):
# def hourglass_builder(x, layer_def, net_type=None, scope=None, extra_highlevel_feature=None):
# 
# Path: net_modules/auto_struct/keypoint_encoder.py
# class BasicFactory(BaseFactory):
#     def __init__(self, output_channels, options):
#     def keypoint_init(self):
#     def use_random_transform(self):
#     def image_size(self, img_h, img_w):
#     def augment_images(self, image_tensor):
#     def heatmap_postprocess(self, heatmap):
#     def heatmap_postpostprocess(self, heatmap, image_tensor=None, heatmap_extra=None):
#     def heatmap2structure_internal(self, heatmap_tensor):
#     def heatmap2structure_basic(self, heatmap_tensor):
#     def heatmap2structure(self, heatmap_tensor):
#     def heatmap2structure_poststep(self, structure_pack):
#     def cleanup_augmentation_patchfeatures(self, patch_features, aug_cache):
#     def cleanup_augmentation_structure(self, structure_param, aug_cache, condition_tensor=None):
#     def structure_param2euclidean(self, structure_param):
#     def coordinate_to_stn(self, keypoint_param, aspect_ratio):


import tensorflow as tf
import zutils.tf_math_funcs as tmf
import numpy as np
import zutils.pt_utils as ptu
import prettytensor as pt
from net_modules.common import *
from net_modules.hourglass import hourglass
from net_modules.auto_struct.keypoint_encoder import Factory as BaseFactory
        return raw_heatmap_feat

    def image2feature(self, image_tensor):

        if self.patch_feature_dim == 0:
            return None

        mid_tensor = (
            pt.wrap(image_tensor).
            conv2d(3, 32).
            max_pool(2, 2)
        ).tensor  # 64x64

        hgd = [
            {"type": "conv2d", "depth": 64},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 32 x 32
            {"type": "conv2d", "depth": 128},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 16 x 16
            {"type": "conv2d", "depth": 256},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 8 x 8
            {"type": "conv2d", "depth": 512},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 4 x 4
            {"type": "conv2d", "depth": 512},
        ]

        with pt.defaults_scope(**self.pt_defaults_scope_value()):

# Path: net_modules/hourglass.py
# class HourglassOptions:
#     def layer(p):
# def _hourglass_builder(x, layer_def, net_type=None, extra_highlevel_feature=None):
# def hourglass_builder(x, layer_def, net_type=None, scope=None, extra_highlevel_feature=None):
# 
# Path: net_modules/auto_struct/keypoint_encoder.py
# class BasicFactory(BaseFactory):
#     def __init__(self, output_channels, options):
#     def keypoint_init(self):
#     def use_random_transform(self):
#     def image_size(self, img_h, img_w):
#     def augment_images(self, image_tensor):
#     def heatmap_postprocess(self, heatmap):
#     def heatmap_postpostprocess(self, heatmap, image_tensor=None, heatmap_extra=None):
#     def heatmap2structure_internal(self, heatmap_tensor):
#     def heatmap2structure_basic(self, heatmap_tensor):
#     def heatmap2structure(self, heatmap_tensor):
#     def heatmap2structure_poststep(self, structure_pack):
#     def cleanup_augmentation_patchfeatures(self, patch_features, aug_cache):
#     def cleanup_augmentation_structure(self, structure_param, aug_cache, condition_tensor=None):
#     def structure_param2euclidean(self, structure_param):
#     def coordinate_to_stn(self, keypoint_param, aspect_ratio):


# Path: nets/encoder/general_128x128_landmark.py
import tensorflow as tf
import zutils.tf_math_funcs as tmf
import numpy as np
import zutils.pt_utils as ptu
import prettytensor as pt
from net_modules.common import *
from net_modules.hourglass import hourglass
from net_modules.auto_struct.keypoint_encoder import Factory as BaseFactory

        return raw_heatmap_feat

    def image2feature(self, image_tensor):

        if self.patch_feature_dim == 0:
            return None

        mid_tensor = (
            pt.wrap(image_tensor).
            conv2d(3, 32).
            max_pool(2, 2)
        ).tensor  # 64x64

        hgd = [
            {"type": "conv2d", "depth": 64},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 32 x 32
            {"type": "conv2d", "depth": 128},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 16 x 16
            {"type": "conv2d", "depth": 256},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 8 x 8
            {"type": "conv2d", "depth": 512},
            {"type": "skip", "layer_num": 2},
            {"type": "pool", "pool": "max", "kernel": 2, "stride": 2},  # 4 x 4
            {"type": "conv2d", "depth": 512},
        ]

        with pt.defaults_scope(**self.pt_defaults_scope_value()):

            feature_map = hourglass(