

You should also check out a similar project on GitHub: DeOldify.Ī huge thanks to Sam Miserendino for proofreading this post! Thanks for reading If you liked this tutorial, you should definitely read the original GAN paper. If you recongize your image in this post, please tweet me and I’ll add credit. Because I downloaded so many images, I couldn’t keep track of which images are in the post. The left image is the input, the middle image is the output and the right image is the training image. fit ( 20, lr ) Looking at the resultsĪfter only half an hour of training on only 1000 images (nothing compared to datasets owned by Google and Facebook), the model is working surprisingly well as you can see in the images below. The configuration for the generator learner: If this the generator were not trained in advance, it would be virtually impossible for it to learn and it would take a very long time to train the GAN. A simple generatorīefore starting criticizing the images, it’s important to have a simple generator so it knows a little bit about the dataset before perfecting itself. If this were not the case, the generator would create great images, but they wouldn’t fit in the desired category. During training, however, it’s very important the discriminator penalizes generated images that do not look like images from the dataset. The generator can be trained using transfer learning so it starts with a basic understanding of what images look like. As training progresses, the discriminator gets better at this task after which the generator learns to create more convincing images etc. It tries to distinguish between real images (from the training set) and images trained by the generator. The critic, or discriminator, is a binary classifier as we’ve seen before. The generator is the model that generates any kind of media. You can approach GANs by seeing them as a virtual cat and mouse game.

GANs consist of two neural networks trained simultaneously: the generator and the critic. As you’ll learn in a minute, this is the way these networks learn. Adversarial means involving opposition/conflicts. Generative is creating new things, the main application of GANs. The crappy images next to the original images ( data_gen.show_batch(4)):Īs mentioned in the introduction, GAN stands for Generative Adversarial Network. split_by_rand_pct ( 0.1, seed = 42 ) data_gen = get_data ( bs = 8, size = 128 )

normalize ( imagenet_stats, do_y = True )) data. transform ( get_transforms ( max_zoom = 2. label_from_func ( lambda x : Path ( 'images' ) / x. Def get_data ( bs, size ): data = ( src.
