# Path: utils/custom_layers.py
# def abs_smooth(x):
# def abs_smooth_2(x):
# def l2_normalization(
#         inputs,
#         scaling=False,
#         scale_initializer=init_ops.ones_initializer(),
#         reuse=None,
#         variables_collections=None,
#         outputs_collections=None,
#         data_format='NHWC',
#         trainable=True,
#         scope=None):
# def pad2d(inputs,
#           pad=(0, 0),
#           mode='CONSTANT',
#           data_format='NHWC',
#           trainable=True,
#           scope=None):
# def channel_to_last(inputs,
#                     data_format='NHWC',
#                     scope=None):
# def dropout_with_noise(net):
# 
# Path: ssd/ssd_utils.py
# def tensor_shape(x, rank=3):
# def multibox_layer(inputs, num_classes, anchor_sizes, anchor_ratios, normalization):
# def compute_jaccard(gt_bboxes, anchors):
# def anchor_one_layer(img_shape, feat_shape, sizes, ratios, step, offset=0.5, dtype=np.float32):
# def arg_scope(weight_decay=0.0005, data_format='NHWC'):
# def bboxes_encode_layer(labels,
#                         bboxes,
#                         anchors_layer,
#                         num_classes,
#                         prior_scaling=[0.1, 0.1, 0.2, 0.2],
#                         dtype=tf.float32):
#     def jaccard_with_anchors(bbox):
#     def intersection_with_anchors(bbox):
#     def condition(i, feat_labels, feat_scores,
#                   feat_ymin, feat_xmin, feat_ymax, feat_xmax):
#     def body(i, feat_labels, feat_scores,
#              feat_ymin, feat_xmin, feat_ymax, feat_xmax):
# def _bboxes_decode_layer(feat_localizations,
#                                anchors_layer,
#                                prior_scaling=[0.1, 0.1, 0.2, 0.2]):
# def bboxes_decode(feat_localizations,
#                          anchors,
#                          prior_scaling=[0.1, 0.1, 0.2, 0.2],
#                          scope='ssd_bboxes_decode'):
# def _match_no_miss(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, gt_labels, gt_bboxes, num_anchors):
#     def cond(i, gt_anchors_labels, gt_anchors_bboxes, gt_anchors_scores):
#     def body(i, gt_anchors_labels, gt_anchors_bboxes, gt_anchors_scores):
# def match_no_labels(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, matching_threshold,
#                       gt_labels, gt_bboxes, num_anchors):
# def match_with_labels(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, matching_threshold,
#                         gt_labels, gt_bboxes, num_anchors):
# def _bboxes_select_layer(predictions_layer, localizations_layer,
#                         select_threshold=None,
#                         num_classes=21,
#                         ignore_class=0,
#                         scope=None):
# def bboxes_select(predictions_net, localizations_net,
#                   select_threshold=None,
#                   num_classes=21,
#                   ignore_class=0,
#                   scope=None):


import tensorflow as tf
from utils import custom_layers
from ssd.ssd_utils import SSDParams
                 'mobilenet_v1_050': 'Conv2d_11_pointwise',
                 'mobilenet_v1_025': 'Conv2d_11_pointwise',
                 'xception': ''
                 }


def ssd300(net, end_points):
    """
    Implementation of the SSD300 network.

    The default features layers with 300x300 image input are:
      conv4 ==> 38 x 38
      conv7 ==> 19 x 19
      conv8 ==> 10 x 10
      conv9 ==> 5 x 5
      conv10 ==> 3 x 3
      conv11 ==> 1 x 1
    The default image size used to train this network is 300x300.

    No prediction and localization layers included!!!
    """
    # block 6: 3x3 conv
    net = slim.conv2d(net, 1024, [3, 3], rate=6, scope='conv6')
    net = slim.batch_norm(net)
    net = custom_layers.dropout_with_noise(net)
    end_points['ssd_block6'] = net

    # block 7: 1x1 conv
    net = slim.conv2d(net, 1024, [1, 1], scope='conv7')
    net = slim.batch_norm(net)

# Path: utils/custom_layers.py
# def abs_smooth(x):
# def abs_smooth_2(x):
# def l2_normalization(
#         inputs,
#         scaling=False,
#         scale_initializer=init_ops.ones_initializer(),
#         reuse=None,
#         variables_collections=None,
#         outputs_collections=None,
#         data_format='NHWC',
#         trainable=True,
#         scope=None):
# def pad2d(inputs,
#           pad=(0, 0),
#           mode='CONSTANT',
#           data_format='NHWC',
#           trainable=True,
#           scope=None):
# def channel_to_last(inputs,
#                     data_format='NHWC',
#                     scope=None):
# def dropout_with_noise(net):
# 
# Path: ssd/ssd_utils.py
# def tensor_shape(x, rank=3):
# def multibox_layer(inputs, num_classes, anchor_sizes, anchor_ratios, normalization):
# def compute_jaccard(gt_bboxes, anchors):
# def anchor_one_layer(img_shape, feat_shape, sizes, ratios, step, offset=0.5, dtype=np.float32):
# def arg_scope(weight_decay=0.0005, data_format='NHWC'):
# def bboxes_encode_layer(labels,
#                         bboxes,
#                         anchors_layer,
#                         num_classes,
#                         prior_scaling=[0.1, 0.1, 0.2, 0.2],
#                         dtype=tf.float32):
#     def jaccard_with_anchors(bbox):
#     def intersection_with_anchors(bbox):
#     def condition(i, feat_labels, feat_scores,
#                   feat_ymin, feat_xmin, feat_ymax, feat_xmax):
#     def body(i, feat_labels, feat_scores,
#              feat_ymin, feat_xmin, feat_ymax, feat_xmax):
# def _bboxes_decode_layer(feat_localizations,
#                                anchors_layer,
#                                prior_scaling=[0.1, 0.1, 0.2, 0.2]):
# def bboxes_decode(feat_localizations,
#                          anchors,
#                          prior_scaling=[0.1, 0.1, 0.2, 0.2],
#                          scope='ssd_bboxes_decode'):
# def _match_no_miss(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, gt_labels, gt_bboxes, num_anchors):
#     def cond(i, gt_anchors_labels, gt_anchors_bboxes, gt_anchors_scores):
#     def body(i, gt_anchors_labels, gt_anchors_bboxes, gt_anchors_scores):
# def match_no_labels(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, matching_threshold,
#                       gt_labels, gt_bboxes, num_anchors):
# def match_with_labels(gt_anchor_labels, gt_anchor_bboxes, gt_anchor_scores, jaccard, matching_threshold,
#                         gt_labels, gt_bboxes, num_anchors):
# def _bboxes_select_layer(predictions_layer, localizations_layer,
#                         select_threshold=None,
#                         num_classes=21,
#                         ignore_class=0,
#                         scope=None):
# def bboxes_select(predictions_net, localizations_net,
#                   select_threshold=None,
#                   num_classes=21,
#                   ignore_class=0,
#                   scope=None):


# Path: ssd/ssd_blocks.py
import tensorflow as tf
from utils import custom_layers
from ssd.ssd_utils import SSDParams

                 'mobilenet_v1_050': 'Conv2d_11_pointwise',
                 'mobilenet_v1_025': 'Conv2d_11_pointwise',
                 'xception': ''
                 }


def ssd300(net, end_points):
    """
    Implementation of the SSD300 network.

    The default features layers with 300x300 image input are:
      conv4 ==> 38 x 38
      conv7 ==> 19 x 19
      conv8 ==> 10 x 10
      conv9 ==> 5 x 5
      conv10 ==> 3 x 3
      conv11 ==> 1 x 1
    The default image size used to train this network is 300x300.

    No prediction and localization layers included!!!
    """
    # block 6: 3x3 conv
    net = slim.conv2d(net, 1024, [3, 3], rate=6, scope='conv6')
    net = slim.batch_norm(net)
    net = custom_layers.dropout_with_noise(net)
    end_points['ssd_block6'] = net

    # block 7: 1x1 conv
    net = slim.conv2d(net, 1024, [1, 1], scope='conv7')
    net = slim.batch_norm(net)

    net = custom_layers.dropout_with_noise(net)