Generating Your Own Fashion Line in 1 Click

Egor Dezhic
Towards Data Science
2 min readSep 20, 2017

--

I want to share a toy project I was working on for the last week — Fashion Generator. Why? Because GANs are awesome, and, as Yann LeCun said:

Adversarial training is the coolest thing since sliced bread

And this generative network is working right inside your browser with GPU-acceleration. Live demo here — Fashion GAN, source code here — github. Maybe by tweaking inputs long enough you will create a new famous fashion line(probability is quite low, but anyway email me in case this happens).

Fashion GAN Recipe

First of all, we need the fashion-mnist dataset, which is a nice alternative to the tired mnist. It comes in the same package and works as a drop-in replacement. There are also 10 classes: T-shirt/top, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker, Bag and Ankle boot, which are sometimes quite hard to discern, especially Pullovers and Coats.

Then, we need some frameworks: Tensorflow to train the model and deeplearnjs to run it in browser with GPU acceleration. There is nothing to say about TF part, except for the YellowFin, which I added because I like the idea of self-tuning optimizers. About deeplearnjs: it is a complete js framework for training and inference of ML models(or any linear algebra) with tensorflow-like API. I can hardly imagine real world scenarios for training NNs in browser, but it may be useful for client-side inference. Nevertheless, it is still in early beta.

Next thing is the model. I’ve took original GAN from this repo and modified it slightly. Architecture of the Generator:

z > (FC > BN > ReLU)*3 > DeConv > BN > ReLU > DeConv > Sigmoid > image

*FC — Fully Connected, BN — Batch Normalization, DeConv — Transposed Convolution(“Deconvolution”)

After few hours of training on gtx770, I got ~27mb of weights ready to be ported into dl.js. Finishing touch is to re-create this architecture using math operations(because graph API in dl.js lacking transposed convolution right now) and write a simple UI: inputs controls and some buttons. The dish is ready!

fashion generator example

And I can’t help but to watch this video again and again:

Originally published at Cognitive Chaos.

--

--