예제 #1
0
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    num_classes = 2  # does not influence training what so ever
    vgg_fcn.wd = hypes['wd']

    vgg_fcn.build(images, train=train, num_classes=num_classes,
                  random_init_fc8=True)

    vgg_dict = {'unpooled': vgg_fcn.conv5_3,
                'deep_feat': vgg_fcn.pool5,
                'deep_feat_channels': 512,
                'early_feat': vgg_fcn.conv4_3,
                'scored_feat': vgg_fcn.score_fr}

    return vgg_dict
예제 #2
0
파일: vgg.py 프로젝트: lihua213/KittiBox
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    num_classes = 3  # does not influence training what so ever
    vgg_fcn.wd = hypes['wd']

    vgg_fcn.build(images,
                  train=train,
                  num_classes=num_classes,
                  random_init_fc8=True)

    if hypes['arch']['deep_feat'] == "pool5":
        deep_feat = vgg_fcn.pool5
    elif hypes['arch']['deep_feat'] == "fc7":
        deep_feat = vgg_fcn.fc7
    else:
        raise NotImplementedError

    vgg_dict = {'deep_feat': deep_feat, 'early_feat': vgg_fcn.conv4_3}

    return vgg_dict
예제 #3
0
파일: vgg.py 프로젝트: zyg11/YicongPeng
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], "model_2D.pkl")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)
    '''
    num_classes does not influence training when KittiBox is used alone.
    However, if you wish to use MultiNet with custom submodules, 
    e.g., if KittiSeg is customized for != 2 classes, this value must
    reflect num_classes in KittiSeg, since MultiNet will try to share 
    variable score_fr/weights
    '''
    num_classes = 2
    vgg_fcn.wd = hypes['wd']

    vgg_fcn.build(images,
                  train=train,
                  num_classes=num_classes,
                  random_init_fc8=True)

    if hypes['arch']['deep_feat'] == "pool5":
        deep_feat = vgg_fcn.pool5
    elif hypes['arch']['deep_feat'] == "fc7":
        deep_feat = vgg_fcn.fc7
    else:
        raise NotImplementedError

    vgg_dict = {
        'deep_feat': deep_feat,
        'early_feat': vgg_fcn.conv4_3,
        'depth_early_feat': vgg_fcn.conv4_depth,
        'depth_deep_feat': vgg_fcn.pool5_depth,
        'location_early_feat': vgg_fcn.conv4_location,
        'location_deep_feat': vgg_fcn.pool5_location,
        'corner_early_feat': vgg_fcn.conv4_corner,
        'corner_deep_feat': vgg_fcn.pool5_corner
    }

    return vgg_dict
예제 #4
0
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], 'weights',
                                  "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    vgg_fcn.wd = hypes['wd']

    num_classes = hypes['arch']['num_classes']

    vgg_fcn.build(images,
                  train=train,
                  num_classes=num_classes,
                  random_init_fc8=True)

    logits = {}

    logits['images'] = images

    if hypes['arch']['fcn_in'] == 'pool5':
        logits['fcn_in'] = vgg_fcn.pool5
    elif hypes['arch']['fcn_in'] == 'fc7':
        logits['fcn_in'] = vgg_fcn.fc7
    else:
        raise NotImplementedError

    logits['feed2'] = vgg_fcn.pool4
    logits['feed4'] = vgg_fcn.pool3

    logits['feed4'] = vgg_fcn.pool3

    logits['fcn_logits'] = vgg_fcn.upscore32

    logits['deep_feat'] = vgg_fcn.pool5
    logits['early_feat'] = vgg_fcn.conv4_3

    return logits
예제 #5
0
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    vgg_fcn.wd = hypes['wd']

    vgg_fcn.build(images, train=train, num_classes=2, random_init_fc8=True)

    return vgg_fcn.upscore32
예제 #6
0
def inference(hypes, images, train=True):
    """Build the MNIST model up to where it may be used for inference.

    Args:
      images: Images placeholder, from inputs().
      train: whether the network is used for train of inference

    Returns:
      softmax_linear: Output tensor with the computed logits.
    """
    vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], 'weights',
                                  "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    vgg_fcn.wd = hypes['wd']

    num_classes = hypes['arch']['num_classes']
    vgg_fcn.build(images, train=train, num_classes=num_classes, random_init_fc8=True)

    logits = {}

    logits['images'] = images

    if hypes['arch']['fcn_in'] == 'pool5':
        logits['fcn_in'] = vgg_fcn.pool5
    elif hypes['arch']['fcn_in'] == 'fc7':
        logits['fcn_in'] = vgg_fcn.fc7
    else:
        raise NotImplementedError

    logits['feed2'] = vgg_fcn.pool4
    logits['feed4'] = vgg_fcn.pool3

    logits['fcn_logits'] = vgg_fcn.upscore32

    logits['deep_feat'] = vgg_fcn.pool5
    logits['early_feat'] = vgg_fcn.conv4_3

    # List what variables to save and restore for finetuning
    """
    vars_to_save = {"conv1_1": vgg_fcn.conv1_1, "conv1_2": vgg_fcn.conv1_2,
                    "pool1": vgg_fcn.pool1,
                    "conv2_1": vgg_fcn.conv2_1, "conv2_2": vgg_fcn.conv2_2,
                    "pool2": vgg_fcn.pool2,
                    "conv3_1": vgg_fcn.conv3_1, "conv3_2": vgg_fcn.conv3_2,
                    "conv3_3": vgg_fcn.conv3_3, "pool3": vgg_fcn.pool3,
                    "conv4_1": vgg_fcn.conv4_1, "conv4_2": vgg_fcn.conv4_2,
                    "conv4_3":  vgg_fcn.conv4_3, "pool4": vgg_fcn.pool4,
                    "conv5_1": vgg_fcn.conv5_1, "conv5_2": vgg_fcn.conv5_2,
                    "conv5_3": vgg_fcn.conv5_3, "pool5": vgg_fcn.pool5,
                    "fc6": vgg_fcn.fc6, "fc7": vgg_fcn.fc7}
    """
    vars_to_save = (vgg_fcn.conv1_1, vgg_fcn.conv1_2,
                    vgg_fcn.conv2_1, vgg_fcn.conv2_2,
                    vgg_fcn.conv3_1, vgg_fcn.conv3_2, vgg_fcn.conv3_3,
                    vgg_fcn.conv4_1, vgg_fcn.conv4_2, vgg_fcn.conv4_3,
                    vgg_fcn.conv5_1, vgg_fcn.conv5_2, vgg_fcn.conv5_3,
                    vgg_fcn.fc6, vgg_fcn.fc7)

    logits['saving_vars'] = vars_to_save

    return logits
예제 #7
0
import tensorflow as tf

import os


def inference(hypes, images, train=True):
    #Build the MNIST model up to where it may be used for inference.

    #Args:
    #  images: Images placeholder, from inputs().
    #  train: whether the network is used for train of inference

    #Returns:
    #  softmax_linear: Output tensor with the computed logits.
    
	#vgg16
	vgg16_npy_path = os.path.join(hypes['dirs']['data_dir'], "vgg16.npy")
    vgg_fcn = fcn8_vgg.FCN8VGG(vgg16_npy_path=vgg16_npy_path)

    num_classes = 2
    vgg_fcn.build(images, train=train, num_classes=num_classes,
                  random_init_fc8=True)

    vgg_dict = {'unpooled': vgg_fcn.conv5_3,
                'deep_feat': vgg_fcn.pool5,
                'deep_feat_channels': 512,
                'early_feat': vgg_fcn.conv4_3}

    return vgg_dict