iML Week 14: Final Project – Ivy Shi

Concept 

Tattoo Generation 

My final project is a continuation of the midterm project to work on tattoo image generation using GAN. I was inspired by the project named this person does not exist which is a website that displays random generative human faces based on real face images dataset it was trained on. My goal is to train a DCGAN model and creates a front-end interface that allows user to generate random tattoos. 

Process

Data Collection: I started out by data collection since there are no existing dataset for tattoo images. The approach is to use the python script called “Google Images Download”  with chromedriver which scrapes Google Images based on search keywords/key-phrases on Google Images to my computer. For this project, I specifically searched for  “tattoo stock images” as they have clean background that will create less distractions for the model. There is a limitation to the tool so I could only download around 400 images at a time. After running it 10 times and manually filtered out photos, I obtained 2560 images for my tattoo dataset. 

Training: I used a DCGAN model on GitHub for training. Since images are different size, I had to pre-process them by center-cropping. I started out with 64×64 pixels images as they are faster to train and I can inference the results rather quickly. 

One problem I encountered during training was the dataset. The program would crash during random interactions within the first epoch. I decreased the batch size to check for the error. After some experiments, I found out that there was one corrupted image in my original dataset. After deleting it, everything started training smoothly. 

 

Result

Then I used the python script to inference on the checkpoints generated. Here are some of the results I got: 

After getting satisfiable results, I wanted improve the output image quality. So I repeated the same process with 256×256 pixel images. The training took a lot longer than the first time, therefore I was only able to around 8500 iterations. The results are still worth noting here: 

Inference with TensorFlowJS: With good results from the python script, I  also want to experiment with inferencing in TensorFlow. Using the freeze flag, I obtained a frozen graph from the most recent checkpoint from the Intel Dev Cloud. Following Aven’s tutorial on converting CycleGAN model from week12, I modified the file by inputting the generator’s name which is generator_1/Tanh. Aven also showed this APP called

With good results from the python script, I  also want to experiment with inferencing in TensorFlow. Using the freeze flag, I obtained a frozen graph from the most recent checkpoint from the Intel Dev Cloud. Following Aven’s tutorial on converting CycleGAN model from week12, I modified the file by inputting the generator’s name which is generator_1/Tanh. Aven also showed this APP called Netron – a visualizer for neural network and machine learning models. It details how inputs are being converted in the model and what types of activation functions are used. In the case of DCGAN, it starts with input dimension Z. Since it is a very long graph, I included a snippet of the visual. 

Converting the model was quite difficult to do. Basically I followed the python script and tried to find exact same ways to do so in TensorflowJS. With much help, I eventually employed the right distribution function and obtained the right dimension for my tensor which then I can output on the HTML page in my front-end implementation. Right now, the front-end is quite minimal with an option for users to click and generate new tattoo images. Here is a demo and some example output: 

Something worth mentioning is for some reason, the tensorflowJS model produces much worse output images than the python script. I am not sure the exact reason and would like to look more into it.

Future Improvement 

Here are some areas I can improve on for the future. 

1) Upsize the dataset to improve model output 

2) Improve output image quality for better visuals 

3) Enhance front end functionalities with more user interactions

4)Experiment with other GAN or machine learnings models to allow tattoo generation based on user input sketches rather than random generation. 

Leave a Reply