python将图片转动漫_CartoonGAN的Pytorch和Torch测试代码,用于把现实图片转换成动漫效果的图...

本文介绍了使用Pytorch和Torch对CartoonGAN进行测试的代码。在Linux和NVIDIA GPU环境下,需安装Pytorch 0.3和Torch。文中给出了克隆代码库、下载转换模型及测试的具体步骤,还提到训练代码与流行的基于GAN的图像翻译框架类似,未包含在内。

CartoonGAN-Test-Pytorch-Torch

Pytorch and Torch testing code of CartoonGAN [Chen et al., CVPR18]. With the released pretrained models by the authors, I made these simple scripts for a quick test.

Getting started

Linux

NVIDIA GPU

Pytorch 0.3

Torch

git clone https://github.com/Yijunmaverick/CartoonGAN-Test-Pytorch-Torch

cd CartoonGAN-Test-Pytorch-Torch

Pytorch

The original pretrained models are Torch nngraph models, which cannot be loaded in Pytorch through load_lua. So I manually copy the weights (bias) layer by layer and convert them to .pth models.

Download the converted models:

sh pretrained_model/download_pth.sh

For testing:

python test.py --input_dir YourImgDir --style Hosoda --gpu 0

Torch

Working with the original models in Torch is also fine. I just convert the weights (bias) in their models from CudaTensor to FloatTensor so that cudnn is not required for loading models.

Download the converted models:

sh pretrained_model/download_t7.sh

For testing:

th test.lua -input_dir YourImgDir -style Hosoda -gpu 0

Examples (Left: input, Right: output)

Note

The training code should be similar to the popular GAN-based image-translation frameworks and thus is not included here.

Acknowledgement

Many thanks to the authors for this cool work.

Part of the codes are borrowed from DCGAN, TextureNet, AdaIN and CycleGAN.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值