forked from MarvinTeichmann/tensorflow-fcn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_fcn32_vgg.py
executable file
·45 lines (31 loc) · 1.04 KB
/
test_fcn32_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
#!/usr/bin/env python
import skimage
import skimage.io
import skimage.transform
import os
import scipy as scp
import scipy.misc
import numpy as np
import tensorflow as tf
import fcn32_vgg
import utils
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("float")
feed_dict = {images: img1}
batch_images = tf.expand_dims(images, 0)
vgg_fcn = fcn32_vgg.FCN32VGG()
with tf.name_scope("content_vgg"):
vgg_fcn.build(batch_images, debug=True)
print('Finished building Network.')
init = tf.initialize_all_variables()
sess.run(tf.initialize_all_variables())
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('fcn32_downsampled.png', down_color)
scp.misc.imsave('fcn32_upsampled.png', up_color)