-
Notifications
You must be signed in to change notification settings - Fork 432
/
test_fcn16_vgg.py
executable file
·50 lines (35 loc) · 1.26 KB
/
test_fcn16_vgg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import os
import scipy as scp
import scipy.misc
import numpy as np
import logging
import tensorflow as tf
import sys
import fcn16_vgg
import utils
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level=logging.INFO,
stream=sys.stdout)
from tensorflow.python.framework import ops
img1 = scp.misc.imread("./test_data/tabby_cat.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()
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.global_variables_initializer()
sess.run(init)
print('Running the Network')
tensors = [vgg_fcn.pred, vgg_fcn.pred_up]
down, up = sess.run(tensors, feed_dict=feed_dict)
down_color = utils.color_image(down[0])
up_color = utils.color_image(up[0])
scp.misc.imsave('fcn16_downsampled.png', down_color)
scp.misc.imsave('fcn16_upsampled.png', up_color)