fast style transfer 快速风格转换 test

原文链接: fast style transfer 快速风格转换 test

上一篇: fast style transfer 快速风格转换 train

下一篇: opencv 和scipy misc 模块 图像resize 速度比较 timeit 模块使用

测试pb文件

在人像上的效果稍微有点欠缺

读取配置文件中的pb路径,将测试图片输入进去后展示出来

素描风格

2e68403a8f331a0324b79df74e188928989.jpg

1e642360fc194bf0fdf99535b588121a361.jpg

d0c35f45ff11aa1511c6bb4f5fa7bc2eb1d.jpg

141d26a07ba31401e0b4cbaf616ac85510e.jpg

3c62adc9c3bc9f9c374487a3781c63c0e2d.jpg

76010f670f2693375526c6b1f612b6e3d4b.jpg

蒙娜丽莎的效果看起来还是有点厉害的

d69e630c8f55c26f0bf67d4e499895684ae.jpg

1745653eb6208bb80341847eba2f4f0cfd0.jpg

d9c3ab5601d3bd572806c0907e2db724557.jpgf72fa2db34f8659a617ce07ec807111341d.jpg3228de74e99151c905d36e4bdc165f8082a.jpg1db329dfaca24f43a00d58c97133e8bcdae.jpg

91e7d50c85d1637a1f3afb290fbd2203282.jpg

cf10741ab68dd3949ecede3d3f69a2a8eb7.jpg

6b8cbb82cfdc9fcc560c25fb806d76a413d.jpg

混合风格

286a3ec09b260f4ea1085a54e73821ac24a.jpg

test

import tensorflow as tf
import matplotlib.pyplot as plt
import scipy.misc as sm
from config import *

sess = tf.Session()
output_graph_def = tf.GraphDef()
with open(PB_PATH, "rb") as f:
    output_graph_def.ParseFromString(f.read())
    tf.import_graph_def(
        output_graph_def,
        name='',  # 默认name为import,类似scope
        # return_elements=['generator/mul:0']
    )
sess.run(tf.global_variables_initializer())
in_image = sess.graph.get_tensor_by_name("in_x:0")
in_height = sess.graph.get_tensor_by_name("in_height:0")
in_width = sess.graph.get_tensor_by_name("in_width:0")
output = sess.graph.get_tensor_by_name("generator/output:0")
# (1, ?, ?, 3) <unknown> <unknown> (?, ?, ?, ?)
print(in_image.shape, in_height.shape, in_width.shape, output.shape)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for path in TEST_IMAGE_PATHS:
        image = sm.imread(path, mode='RGB')
        # plt.imshow(image)
        # plt.show()
        h, w, _ = image.shape
        output_val = sess.run(
            output, {
                in_image: np.expand_dims(image.astype(np.float32), 0),
                in_height: h,
                in_width: w,
            }
        )
        # (784, 637, 3) (1, 784, 637, 1)
        print(image.shape, output_val.shape)
        output_val = np.squeeze(output_val, 0)
        output_val = np.clip(output_val, 0, 255).astype(np.uint8)
        plt.imshow(output_val)
        plt.show()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值