๐ŸŒท My GAN Gave Me Flowers

๐ŸŒท My GAN Gave Me Flowers

Not very long ago, I began working with GANs. After about 10 min into my first project, and I was already in love. And for me, it is not about what I can make with it as much as having the visual representation that shows me every epoch along the way what the network sees and how it responds to what it sees. That part, I find utterly fascinating.

This post covers my third GAN project. My first was a simple one that gave pretty flawless results rather quickly - anime faces. The data was very clean, had a wide variety while remaining structurally uniform, and there were a very large number of inputs to work with.That is easy, I now see, especially after trying some ideas that were the other end of the challenge spectrum.

After learning how it all works, I wanted to practice with as many projects as possible in order to make it second nature for myself, the whole data configuration and training process. So I found many gigabytes of impressionist art and fed it to a GAN. Well, that was not quite as rewarding. Firstly, the model was fed images of pretty much EVERYTHING an impressionist painter might choose to paint. Secondly, the everything was...impressionist. So some of them look like the thing they are, and some of them look like the thing they are but 15 feet below the surface of a pool or deeply buried in a thick fog. So that was fun.

My impressionism attempt was not a failure, however, because I learned. It actually taught me, even more than the successful projects, what it is the model is doing in a more concrete sense that my brain could fully conceptualize. And that has made this process even more enjoyable for me. ย So after that little epic fail (not sure if I thought I was gonna get a Monet-Renoir lovechild or what), I decided to work with something more simple โ€“ flowers!

For this project, I used the 102 Flower Category Dataset, which is generally meant for flower classification, but it also has perfect perspectives of the blooms of flowers, which is exactly what I wanted as the subject matter for this project. My main objective was to choose an object for which I knew I could find a high quality dataset containing an extremely high number of variations on the theme of that object. And while I am not really a flower person, per se, they seemed like the perfect choice given the fact that this dataset is so readily available. And the variation is a huge across this set.

The flowers range quite widely in size, color, shape, configuration, etc. So I was not sure if this would be closer to the results of my lovely little anime faces project or if it would fall flat like my impressionist dreams. I had a suspicion it would work pretty well though. ย I try to walk into just about any project with no expectations and just do the very best I can. But I definitely had high hopes on this one. I could not help it. And the results are just about what I had hoped for, aside from the aspects that a great deal more training time would supply. The point is: I found the right track.

The only issue I ran into on this project was with normalization. I was originally working with the mean and standard deviation values that I had written a function to determine from across the entire dataset. However, these values caused a surprise issue with my generator, of which I have yet to discern the cause. The values I did end up using worked well though, and I arrived at good results.

This is an example of one of the images with the normalization settings I used:

My discriminator and generator architecture sticks very close to the GANs handbook, in a manner of speaking. Since this is still fairly new to me, I did not stray from the norm there, as I am trying to ease my way into evolving my approach and hoping the keep successes all along the way. Road blocks and time wasted with projects like the impressionist paintings can really knock a girl down!

Here is the video slideshow of the model-generated images over the course of the 200 epochs of training:

Video slideshow of GAN-generated flowers over 200 epochs of training.

Below are scrollable Jupyter notebook excerpts of the entire project, broken up into its sections. You can also use the interactive Jupyter notebook or click here for a PDF version of the project.

Data Preparation:


Model Training @ 100 epochs:

Results @ 100 epochs:

Losses and Scores @ 100 epochs:

Model Training @ 200 epochs:

Results @ 200 epochs: