• 首页

  • 笑一笑

  • 相册

  • 文学

  • 日志

  • 关于页面
u f a n y
u f a n y

英杰

获取中...

09
10

机器学习开源框架系列:Torch:3:图像风格迁移

发表于 2020-09-10 • 被 1,593 人看爆

这里写图片描述
这篇文章通过一个具体的例子来看一下使用torch可以做的有趣的事情。
事前准备

https://liumiaocn.blog.csdn.net/article/details/109848433

liumiaocn:fast-neural-style liumiao$ th

______ __ | Torch7
/_ / ________/ / | Scientific computing for Lua.
/ / / _ / __/ / _ \ | Type ? for help
/_/ _
// _//// | https://github.com/torch
| http://torch.ch

th>

1
2
3
4
5
6
7
8
9

步骤1: 下载图像风格迁移代码

执行 命令:git clone https://github.com/jcjohnson/fast-neural-style

liumiaocn:~ liumiao$ git clone https://github.com/jcjohnson/fast-neural-style
Cloning into ‘fast-neural-style’…
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 256 (delta 0), reused 0 (delta 0), pack-reused 253
Receiving objects: 100% (256/256), 18.65 MiB | 7.14 MiB/s, done.
Resolving deltas: 100% (109/109), done.
liumiaocn:~ liumiao$

1
2
3
4
5
6
7
8
9

步骤2: 下载预先训练好的模型

liumiaocn:~ liumiao$ cd fast-neural-style/
liumiaocn:fast-neural-style liumiao$ ls
README.md fast_neural_style.lua print_options.lua slow_neural_style.lua webcam_demo.lua
doc images requirements.txt test
fast_neural_style models scripts train.lua
liumiaocn:fast-neural-style liumiao$ sh models/download_style_transfer_models.sh
…省略
liumiaocn:fast-neural-style liumiao$ find models/ -name ‘*.t7’
models//instance_norm/mosaic.t7
models//instance_norm/candy.t7
models//instance_norm/the_scream.t7
models//instance_norm/feathers.t7
models//instance_norm/la_muse.t7
models//instance_norm/udnie.t7
models//eccv16/starry_night.t7
models//eccv16/la_muse.t7
models//eccv16/composition_vii.t7
models//eccv16/the_wave.t7
liumiaocn:fast-neural-style liumiao$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

注意:此步骤中下载脚本可能会下载失败,可以通过其他方式比如浏览器下载之后移动到相应位置即可。
结果验证
示例1: 黑猫警长

原始图片
在这里插入图片描述
执行命令:

liumiaocn:fast-neural-style liumiao$ th fast_neural_style.lua \

-model models//eccv16/starry_night.t7
-input_image liumiaocn.jpg
-output_image newstyle-liumiaocn.png
Writing output image to newstyle-liumiaocn.png
liumiaocn:fast-neural-style liumiao$

1
2
3
4
5
6

风格变换之后
在这里插入图片描述
注:图像太小,拉伸后很诡异

示例2: 芝加哥

原始图片
在这里插入图片描述
执行命令

liumiaocn:fast-neural-style liumiao$ time -p th fast_neural_style.lua \

-model models//eccv16/starry_night.t7
-input_image city.jpg
-output_image newstyle-city.png
Writing output image to newstyle-city.png
real 7.60
user 9.32
sys 4.79
liumiaocn:fast-neural-style liumiao$

1
2
3
4
5
6
7
8
9

风格变换之后

分享到:
mySQL 执行语句执行顺序
为什么89C51的串口中断只能用T1
  • 文章目录
  • 站点概览
英杰

帅哥英杰

QQ Email RSS
看爆 Top5
  • 使用 MHA 实现 MySQL 主从复制高可用 3,214次看爆
  • nginx反向代理配置去除前缀 2,961次看爆
  • 国产微服务网关-Soul(真香) 2,884次看爆
  • Kubernetes - Xshell连接虚拟机 & 搭建Kubernetes基础集群 2,663次看爆
  • 不把一切看得太重,生命才会更加洒脱 2,628次看爆

Copyright © 2025 英杰 · 冀ICP备19001756号-1

Proudly published with Halo · Theme by fyang · 站点地图