StyleGAN2 Distillation for Feed-Forward Image Manipulation
I recently had an idea for training StyleGAN without a discriminator:<p>StyleGAN2 FFHQ 1024x1024 is somewhat limited. In many cases, 256x256 would be fine. It would generate 16x faster, which is important for e.g. video thumbnails. But you can&#x27;t generate 256x256 images with stylegan FFHQ. You can only generate 1024x1024, then downsample.<p>Suppose you wanted to train a StyleGAN 256x256 on FFHQ. (FFHQ is just &quot;what people normally think of as stylegan&quot; -- the human faces model.) You can do this now, and in fact we recently did a 512x512 model in &lt;24 hours on a TPU pod: <a href="https:&#x2F;&#x2F;github.com&#x2F;sheminusminus&#x2F;modelbattle" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sheminusminus&#x2F;modelbattle</a><p>The problem is the latent space. You know how you can change your age, gender, etc with stylegan &quot;sliders&quot;? Those are directions discovered in stylegan&#x27;s latent space. You train a classifier to predict &quot;older&quot; or &quot;younger&quot; faces, then classify ~50k images, and fit a straight line through the latent space. Now you have an age direction that works on any photo.<p>If you retrain the model from scratch, every single direction you discovered in 1024x1024 stylegan is immediately invalid. Bye bye, effort. And yes, you could rediscover the directions in your new model. But now if you want N resolutions (and perhaps M different aspect ratios of each resolution?) you&#x27;ll need to keep track of NxM latent vectors, one for each model. This is a pain, to say the least.<p>The training process is modified as follows. Generate a random latent, Z. Pass this latent through your new model, and through the original StyleGAN 1024x1024 model. Minimize the perceptual distance between the images.<p>Done.<p>Yes, it&#x27;s really that simple. And somewhat shockingly, I&#x27;ve run it by a few 4+ year veterans and they can&#x27;t really see why it wouldn&#x27;t work, nor can they think of other projects that have already done that.<p>There are a few close ones, but I&#x27;m not trying to claim this is <i>novel</i>, just that it&#x27;s <i>effective</i>. You&#x27;ll end up with a 256x256 FFHQ model with identical latent structure. All the directions on 1024x1024 will work fine on your new model. At least, I think this is what will happen – it&#x27;s hard to predict anything in ML.<p>There are a bunch of interesting variations on this, too. You can train two models simultaneously, on two different datasets. Then at each training step, force the weights of both models to average together. i.e. force them to learn both objectives simultaneously. What will happen? Who knows? Something will happen, and it&#x27;s sure to be interesting.<p>Another neat variation would be to train a single model, conditioned on two different datasets. Suppose you have an animefaces stylegan model and an FFHQ model. You can do the training process described above, but pass the latent through both models, then add a label to the latent (0 = animefaces, 1 = ffhq) and minimize the perceptual distance to each class, in a single model. You should end up with a final model that can generate both animefaces and ffhq faces just by toggling the labels.<p>This isn&#x27;t quite the same thing as simply training on two different datasets and using labels to classify them. You&#x27;re memorizing the latent structure of two existing models. When you set label to 0, you&#x27;re saying &quot;the rest of the latent vector is identical to the animefaces model&quot;. When label is 1, ditto, but for ffhq.<p>So the neat question is, what happens when you try to interpolate label 0 to label 1? Something will happen. And it&#x27;s sure to be interesting. Not necessarily useful, but interesting.