Пример #1
0
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                    level=logging.INFO,
                    stream=sys.stdout)

from tensorflow.python.framework import ops

os.environ['CUDA_VISIBLE_DEVICES'] = ''

img1 = skimage.io.imread("./test_data/tabby_cat.png")

with tf.Session() as sess:
    images = tf.placeholder(dtype=tf.float32)
    feed_dict = {images: img1}
    batch_images = tf.expand_dims(images, 0)

    vgg_fcn = fcn16_vgg.FCN16VGG()
    with tf.name_scope("content_vgg"):
        vgg_fcn.build(batch_images, debug=True)

    print('Finished building Network.')

    logging.warning("Score weights are initialized random.")
    logging.warning("Do not expect meaningful results.")

    logging.info("Start Initializing Variabels.")

    init = tf.initialize_all_variables()
    sess.run(tf.initialize_all_variables())

    print('Running the Network')
    tensors = [vgg_fcn.pred, vgg_fcn.pred_up]
Пример #2
0
        rgb_image[:, :, 1] = image - fcn16_vgg.VGG_MEAN[1]
        rgb_image[:, :, 2] = image - fcn16_vgg.VGG_MEAN[0]
        rgb_image = scipy.misc.imresize(rgb_image, (height * scale_times, width * scale_times))
        scp.misc.imsave(directory + "/" + name + "-filter-" + str(i) + ".jpg", rgb_image)


with tf.device('/cpu:0'):
    config = tf.ConfigProto(allow_soft_placement=True)
    config.gpu_options.allow_growth = True

    with tf.Session(config=config) as sess:

        input_placeholder = tf.placeholder(tf.float32, [None, height, width, num_classes])
        output_placeholder = tf.placeholder(tf.float32, [None, height, width, num_classes])

        vgg_fcn = fcn16_vgg.FCN16VGG('./vgg16.npy')

        with tf.name_scope('content_vgg'):
            vgg_fcn.build(input_placeholder, train=True, num_classes=num_classes, debug=True)

        with tf.name_scope('loss'):
            loss = loss.loss(vgg_fcn.upscore32, output_placeholder, num_classes)
            optimizer = tf.train.AdamOptimizer(0.0001).minimize(loss)

        print('Finished building Network.')

        # Initializing the variables.
        init = tf.global_variables_initializer()

        # Run initialized variables.
        sess.run(init)
Пример #3
0
#img1 = skimage.io.imread("./test_data/tabby_cat.png")

parser = argparse.ArgumentParser()
parser.add_argument('--npypath',help="path to weights",default="/scratch/gallowaa/")
parser.add_argument('--imgpath',help="path to input image",default="/scratch/gallowaa/")
args = parser.parse_args()

img1 = skimage.io.imread(args.imgpath+"2008_004499_02.png")

with tf.Session() as sess:
    images = tf.placeholder("float")
    feed_dict = {images: img1}
    batch_images = tf.expand_dims(images, 0)

    vgg_fcn = fcn16_vgg.FCN16VGG(args.npypath+"vgg16.npy")
    with tf.name_scope("content_vgg"):
        vgg_fcn.build(batch_images, debug=True)

    print('Finished building Network.')

    logging.warning("Score weights are initialized random.")
    logging.warning("Do not expect meaningful results.")

    logging.info("Start Initializing Variabels.")

    init = tf.initialize_all_variables()
    sess.run(tf.initialize_all_variables())

    print('Running the Network')
    tensors = [vgg_fcn.pred, vgg_fcn.pred_up]