CycleGAN-苹果变橘子大法

this repo based on the original implementation of CycleGAN: https://github.com/jinfagang/pytorch_cycle_gan.git, in this version I reconstruct some code and made a generate API to simply generate image from your own single image and your trained model.

CycleGAN - Generate Image Like Magic

I have trained apple2orange and horse2zebra for now, here is the real result of convert
apple -> orange:

</img>

</img>

</img>

I only trained about 50 epochs, but the result is fair enough for now. Laterly I will finish horse2zebra model, and update some more results.

Requirements

  • Python3+
  • PyTorch
  • visdom
  • PIL

Usage

  • For Train

About how to train, simply run this:

python3 train.py --dataroot ./datasets/apple2orange --name apple2orange --model cycle_gan

One things have to mention that, --name indicates the model save dir, and --model is using cycle_gan or pixel2pixel , I only tried cycle_gan.

  • For Generate

Train is very simple, but the original repo have not implement predict API, so I managed to write by myself. Here is the way to use:

python3 generate.py --image_path ./apple_test.jpg --name apple2orange --model cycle_gan --gpu_ids -1

As you can see, you only need to specific image path where stores your image to generate, and --name is the same as previous trained, as well as model type. --gpu_ids indicates we are inference using CPU.

OK, that's all.

Research and Discuss

I really love to connect to people, so if you have any question about this repo, you can find me on wechat jintianiloveu, I have some groups which discuss about GANs I will invite you in if you like.

Copyright

(c) 2017 Jin Fagang under LICENSE Apache 2.0
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 该产品体验报告从两个方面进行分析:背景介绍(产品简介、产品形态、产品阶段、定位、商业模式),设计评估(产品架构、交...
    amber金阅读 1,310评论 0 7
  • 你破窗而入,你破门而入 你从密闭的天空,从海底隧道冲出来 在我的灵魂里跳舞 沙发在跳舞 ,茶几在跳舞 米饭和面条都...
    舒严阅读 297评论 0 0
  • 混沌未分天地乱,茫茫渺渺无人见。 自从盘古破鸿蒙,开辟从兹清浊辨。 覆载群生仰至仁,发明万物皆成善。 欲知造化会元...
    Eva朱阅读 260评论 0 0