Cyclegan example in fastai2

Does anyone know of a cyclegan implementation in fastai2?

To my knowledge nothing has been done yet.

I Implemented U-GAT-IT in Fastai2 which is in the same family. You best bet is to use the code for regular gans: https://github.com/fastai/fastai2/blob/master/nbs/24_vision.gan.ipynb

You can adopt most of the code here and make something that works. I started before this notebook was really added, so my code diverged a lot from the fastai code base. Overall you will probably follow the same pattern of Train Generator -> Train Discriminator -> Train Generator ->…, but you now have a “generator” that accepts two images as inputs. Similar situation with the discriminator. Custom loss function will also be a must, as well as updating the dataloader.

This will definitely take a bit of your own code. I expect the fastai2 starting notebook will help a lot. When I wrote my own notebook doing cycle gan from scratch(no gan notebook) it probably took ~1 month.

2 Likes

If you are not aware, there is a fastai v1 implementation here.

If people are interested, I may write up a blog post on my fastai2 port of the cycleGAN (with lots of help from @ashaw) and share code (have been using for a research project).

4 Likes

I was going to just use the v1 version until I determine if I get results good enough to justify porting it to v2. Do you have a github repo of your implementation?

I have my implementation here and a talk here (with plans to introduce other models as well). A blog post will also come soon and I will share as well if you are interested.

9 Likes

Has anybody read

Hands-On Image Generation with TensorFlow: A practical guide to generating images and videos by Soon Yau Cheong Dec 2020?

I replicated Jeremy’s 2018 Horses and Zebra but that uses TF.and I would like a good book to read.