← 开源
Yijunmaverick

CartoonGAN-Test-Pytorch-Torch

Pytorch and Torch testing code of CartoonGAN [Chen et al., CVPR18]

Model DevelopmentArchitecturePython
在 GitHub 打开
增长势头
+124 小时新增 Star+0.1%
689
Star
201
Fork
+0
本周
1
贡献者
创建于 2018-06-15 · 更新于 2026-10-06 · 今日第 6366 名
主要开发者
README

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.

 ![](test_output/demo_ori.gif) 
 ![](test_output/demo.gif) 

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)

 ![](test_img/in2.png) 
 ![](test_output/in2_Hayao.png) 





 ![](test_img/in3.png) 
 ![](test_output/in3_Hayao.png) 





 ![](test_img/5--26.jpg) 
 ![](test_output/5--26_Hosoda.jpg) 





 ![](test_img/7--136.jpg) 
 ![](test_output/7--136_Hayao.jpg) 





 ![](test_img/15--324.jpg) 
 ![](test_output/15--324_Hosoda.jpg) 

Note

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

Acknowledgement