WritingScalewayScalewaypublished Jul 21, 2020seen 5d

Introducing GPU Instances: Using Deep Learning to Obtain Frontal Rendering of Facial Images

Open original ↗

Captured source

source ↗

Introducing GPU Instances: Using Deep Learning to Obtain Frontal Rendering of Facial Images Build • Olga Petrova • 21/07/20 • 10 min read

We just released GPU Instances , our first servers equipped with graphical processing units (GPUs). Powered by high-end 16-GB NVIDIA Tesla P100 cards and highly efficient Intel Xeon Gold 6148 CPUs, they are ideal for data processing, artificial intelligence, rendering, and video encoding. In addition to the dedicated GPU and 10 Intel Xeon Gold cores, each instance comes with 45 GB of memory, 400 GB of local NVMe SSD storage, and is billed €1 per hour or €500 per month.

Today, we present you with a concrete use case for GPU Instances using deep learning to obtain a frontal rendering of facial images. Feel free to try it too. To do so, visit the Scaleway console to ask for quotas before creating your first GPU Instance.

GPU Overview

Graphical processing unit (GPU) became a go-to term for the specialized electronic circuit designed to power graphics on a machine in the late 1990s, when it was popularized by the chip manufacturer NVIDIA.

GPUs were originally produced primarily to drive high-quality gaming experiences, producing life-like digital graphics. Today, those capabilities are being harnessed more broadly to accelerate computational workloads in areas such as artificial intelligence, machine learning and complex modeling.

GPU Instances at Scaleway were designed to be optimized for taking huge batches of data and performing the same operation over and over very quickly. The combination of an efficient CPU with a powerful GPU will deliver the best value of system performance and price for your deep learning applications.

Writing Your Own Face Frontalization Software from Scratch

Screenwriters never cease to amuse us with bizarre portrayals of the tech industry, ranging from cringeworthy to hilarious . With the current advances in artificial intelligence, however, some of the most unrealistic technologies from the TV screens are coming to life.

For example, the Enhance software from CSI: NY (or Les Experts : Manhattan for our francophone readers) has already been outshone by the state-of-the-art Super Resolution neural networks . On a more extreme side of the imagination, there is Enemy of the state :

“ Rotating [a video surveillance footage] 75 degrees around the vertical ” must have seemed completely nonsensical long after 1998 when the movie came out, evinced by the YouTube comments below this particular excerpt:

Despite the apparent pessimism of the audience, thanks to machine learning today anyone with a little bit of Python knowledge, a large enough dataset, and a Scaleway account can take a stab at writing a sci-fi drama worthy program.

Introduction

Forget MNIST , forget the boring cat vs. dog classifiers, today we are going to learn how to do something far more exciting! This article is inspired by the impressive work by R. Huang et al. ( Beyond Face Rotation: Global and Local Perception GAN for Photorealistic and Identity Preserving Frontal View Synthesis ), in which the authors synthesise frontal views of people’s faces given their images at various angles.

We are not going to try to reproduce the state-of-the-art model by R. Huang et al. You will learn:

How to use NVIDIA’s DALI library for highly optimized pre-processing of images on the GPU and feeding them into a deep learning model.

How to code a Generative Adversarial Network, praised as “ the most interesting idea in the last ten years in Machine Learning ” by Yann LeCun, the director of Facebook AI, in PyTorch

You will also have your very own Generative Adversarial Network set up to be trained on a dataset of your choice. Without further ado, let’s dig in!

Step 1: Starting and Configuring a Gpu Instance on Scaleway

If you have not already gotten yourself a GPU instance hosted by Scaleway, you may do so by:

Logging in to your Scaleway console .

Selecting the Compute tab on the left sidebar and clicking on the green + Create a server button.

Choose the tab GPU OS in Choose an Image and GPU in Select a Server .

For this project, feel free to choose either of the two GPU OS images currently available ( 10.1 and 9.2 refer to the corresponding versions of CUDA ) and select RENDER-S as your server.

4 . Click on the green Create a new server button at the bottom of the page, and within seconds, your very own GPU Instance will be up and running!

5 . You can now ssh to it using the IP Address that you read off your list of instances under the Compute tab:

ssh root@[YOUR GPU INSTANCE IP ADDRESS] CopyContentIcon Copy code 6a. The Docker way:

If you are familiar with Docker , a convenient containerization platform that allows to package up applications together with all their dependencies, go ahead and pull our Docker image containing all the packages and the code needed for the Frontalization project, as well as a small sample dataset:

nvidia-docker run -it rg.fr-par.scw.cloud/opetrova/frontalization:tutorial root@b272693df1ca:/Frontalization# ls Dockerfile data.py main.py network.py test.py training_set CopyContentIcon Copy code (Note that you have to use nvidia-docker rather than the regular docker command due to the presence of a GPU.) You are now inside the Frontalization directory containing the four Python files whose contents we’ll go over below, and the training_set directory containing a sample training dataset. Great start, you can now proceed to Step 2!

6b. The native way:

If you are not familiar with Docker , no problem, you can easily set up the environment by hand. Scaleway GPU instances come with CUDA , Python and conda already installed, but at the time of writing, you have to downgrade the Python version to Python 3.6 in order for Nvidia’s DALI library to function:

conda install -y python==3.6.7 conda install -y pytorch torchvision pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali==0.6.1 CopyContentIcon Copy code You can upload your own training set onto your GPU instance via:

scp -r path/to/local/training_set root@[YOUR GPU INSTANCE IP ADDRESS]:/root/Frontalization CopyContentIcon Copy code and save the Python code that you will see below inside the Frontalization directory using your terminal text editor of choice (e.g. nano or vim , both of which are already installed). Alternatively, you may clone Scaleway’s GitHub repository for this project .

Step 2: Setting Up Your Data

At the heart…

Excerpt shown — open the source for the full document.

Additional captured pages

[1406.2661] Generative Adversarial Nets Generative Adversarial Nets Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, Yoshua Bengio Département d’informatique et de recherche opérationnelle Université de Montréal…