import inputs import argparse import my_utils as mu import tensorflow as tf from model import model_fn, input_fn logger = mu.get_default_logger() parser = argparse.ArgumentParser() parser.add_argument('--data', default='cv', type=str, help='Dataset for evaluation') def main(): def eval_input_fn(): return input_fn(*data[config['data']], batch_size=config['batch_size'], shuffle=False) data = inputs.load_data(config['n_examples_for_cv']) estimator = tf.estimator.Estimator(model_fn=model_fn, params=config, model_dir=config['model_dir']) for ckpt in tf.train.get_checkpoint_state( config['model_dir']).all_model_checkpoint_paths: with mu.Timer() as timer: result = estimator.evaluate(eval_input_fn, checkpoint_path=ckpt) result['data'] = config['data'] logger.info('Done in %.fs', timer.eclipsed)
import net import my_utils import tensorflow as tf import tensorflow.contrib.slim as slim logger = my_utils.get_default_logger() def model_placeholder(config): height, width = config['input_size'] image = tf.placeholder(tf.uint8, name='image_ph', shape=(height, width, 3)) label = tf.placeholder(tf.int32, name='label_ph', shape=(height, width)) bbox = tf.placeholder(tf.int32, name='bbox_ph', shape=(4,)) return image, label, bbox class Model: def __init__(self, image, input_size): """ :param image: tf.placeholder or tf.Tensor, one single image with shape(None, None, 3) and dtype=tf.uint8 :param input_size: list or tuple, """ self.input_size = input_size logger.info('Building model graph...') self.net = net.FCN(image) with tf.name_scope('bbox'): conv6 = slim.conv2d(self.net.endpoints['conv5'], num_outputs=64, kernel_size=(5, 5), stride=1)