You are on page 1of 6

18th International Symposium on Symbolic and Numeric Algorithms for Scientific Computing

Censoring Sensitive Data From Images

Ştefan Postăvaru Ionuţ-Mihăiţă Pleşea


University of Bucharest mihai.plesea@gmail.com
Bitdefender
Bucharest, Romania
spostavaru@bitdefender.com

Abstract—In the recent years, the vast volume of digital coming from annotated and clean sources, while a generator
images available enabled a large range of learning methods to tries to increase the error of the discriminator. Finally, for
be applicable, while making human input obsolete for many the non-blind inpainting case with adversarial networks, we
tasks. In this paper, we are addressing the problem of removing
private information from images. When confronted with a test the same architecture presented in [12] on a common
relatively big number of pictures to be made public, one may dataset, for comparison purposes.
find the task of manual editing out sensitive regions to be
unfeasible. Ideally, we would like to use a machine learning II. R ELATED W ORK
approach to automate this task. We implement and compare The task of image anonymisation can be formalized as
different architectures based on convolutional neural networks, having the original data X, a dependent variable S, find a
with generative and discriminative models competing in an
adversarial fashion. representation R such that S cannot be deduced from R [3].
In this situation, the objective function to be minimized is:
Keywords-image censoring; convolutional neural networks;
generative adversarial network; autoencoder; L = αC(X, R) + βD(R, S), (1)
I. I NTRODUCTION where C(·) represents the cost of reconstructing the orig-
In this paper we propose several architectures with dif- inal data from its representation, and D(·) measures the
ferent training approaches, in order to solve the task of dependence between the hidden variable and the learned
removing private information from images. Our goal is to representation. In this case, the representation coincide with
create reproductions that do not contain data considered the input X, the task summarizing to finding the distribution
”sensitive” (such as the person’s name, location identifiers, of data p(X), therefore a generative model is used.
private belongings), but preserve as much information as To quantify the dependence D(·), a separate model (dis-
possible from the original images. We will refer the process criminator) is trained in parallel with the generative one,
of removing data from pictures in order to hide a certain in an adversarial fashion. The discriminator learns relations
aspect, as image anonymization. between the representation and the hidden variable S, while
In the past few years, there have been multiple methods the generator tries to minimize this dependence. Formally, if
proposed for image inpainting [1],[8] using a generative and the generative model parameters are θ and the discriminator
a discriminative model in an adversarial architecture. We has parameters ϕ, the dependence is defined as:
adapt this approach and create models for greyscale image
Dθ,ϕ (R, S) = EX,R [S log(ADV (R)) + (1 − S) log(1 − ADV (R))] (2)
anonymisation, improving upon the ideas presented in [3].
In addition, we also create new models for color images Finding the optimal parameters for both models is a min-
label removal. max problem:
A blind inpainting setup is characterized by the lack of min max Dθ,ϕ (R, S) (3)
θ ϕ
spatial information of the data that should be removed.
We first try to model the relation between annotated and In addition to alternating training, in practice it is mandatory
clean images with a convolutional denoising autoencoder to preserve balance between the generator and discriminator
(DAE), trained on aligned examples. Its prediction is further performances. A too good critique would provide weak
enhanced by training a different model to separate patches gradients for the generator, while a discriminator with poor
with text from clean ones, effectively transiting to a non- performance would produce uninformative gradients [4]. We
blind inpainting problem. Regions without labels are copied incorporate the idea presented in [3] when designing our
from the source image, while the rest are taken from deep adversarial architecture and extend it for color images
the DAE prediction. We then proceed with an adversarial as well.
architecture for color images anonymization, where a dis- An alternative method is to consider the examples as
criminator learns to distinguish between generated images samples coming from two different distributions, p(XD1 ),

2470-881X/16 $31.00 © 2016 IEEE 443


DOI 10.1109/SYNASC.2016.67
p(XD2 ), and make aligned pairs for training (xD1 , xD2 ).
In this case, we are interested in modeling the conditional
P (XD2 |XD1 ). We can consider images with sensitive in-
formation to come from a different distribution than ”clean” (a) Clean image (b) Labelled image
examples, obtained by applying a stochastic corruption
process. Denoising autoencoders are generative models that Figure 1: Randomly annotated example
learn representations robust to partial corruptions of the input
[10], being a natural choice to model this relation. We are
1X
re-purposing this idea to fit our method for anonymizing L(θ) ∝ (pi (X) − pi (Yθ (X̃)))2 (9)
images with good results. n
In [1] they proposed an adversarial architecture to solve So, under these considerations, choosing the mean-squared
the image inpainting problem. A denoising autoencoder is error (MSE) as the criterion function seems reasonable.
trained to reproduce images from incomplete input, along
a discriminator that separates real from generated images, B. Denoising Autoencoder
forming a generative adversarial network (GAN [4]). This
The training set is composed of pairs (x, x̃) where x
approach requires aligned examples for training. By presum-
is a clean image and x̃ is its annotated counterpart, ob-
ing the location of empty region known, one can use the
tained by randomly applying a name over the picture (Fig.
non-blind inpainting approach as presented in [12]. Given a
1). As presented in [11], data in high dimension tend to
trained generator G and discriminator D, the following loss
concentrate near a lower-dimensional non-linear manifold.
functions are defined:
Corrupted examples x̃ are naturally further away form this
Lcontextual (z) = kM ⊙ G(z) − M ⊙ Xk (4) manifold. Training a denoising autoencoder is equivalent
Lperceptual (z) = log(1 − D(G(z))) (5) to learning to project the corrupted examples back into
the original manifold. The DAE learns on mini-batches,
Ltotal = αLcontextual + βLperceptual (6)
with labeled pictures as input and their clean counterpart as
Where z is a random noise vector and M a mask matrix examples, minimizing the MSE between them with Adam
corresponding to the hidden region. By minimizing Ltotal [6] optimized gradient descent (Fig. 2). Different tested
with respect to z, the reconstruction G(z) will converge to architectures, extended from the autoencoder presented by
a complete representation of the initial, partial data. Private [5], are detailed in subsection III-E.
information removal can be viewed as a special case of
image inpainting, where the sensitive data is discarded and
the previous method is used to generate new, plausible
information.
In the next section we will motivate the chosen learning
models and present the implemented architectures.
III. A PPROACH Figure 2: General architecture of a denoising autoencoder.
A. Choosing the loss function The annotated inputs pass through a series of N convolu-
Considering normal images as being samples from a ob- tional layers with 3x3 kernels, stride 1 and separated by
served random variable X, annotated examples are samples max-pooling layers and rectified linear unit (ReLU) transfer
from another random variable X̃, created by a stochastic layers. After 2 fully connected layers, the signal passes
corruption process C(X̃|X), adding random names uni- through a reversed architecture of the first N convolutinal
formly over pictures. We then try to predict the conditional layers. The gradient to be propagated back is computed from
P (X|X̃), i.e. reconstruct original images maximizing their the mean-squared error between the network output and the
likelihood, using a DAE. Let Y be the model prediction clean counterpart of the input.
and θ the parameters of the model, the loss function to be
minimized is:
L(θ) = − log(P (X|X̃)) (7) C. Patch Network

Considering each pixel color from every channel (pi ) We make the observation that pixels without text (un-
to be independently and normally distributed, with mean labeled) are identical in both images from a pair, so
pi (Y (X̃)) and standard deviation σ, the loss function be- p(pi (X) = pi (X̃)|pi (X̃), i ∈ U ) = 1, where U denotes the
comes: set of unlabeled pixels indexes. Let X be a fixed image,
X X1 is constructed from X by replacing a random pixel
L(θ) = − log N (pi (X)|pi (Yθ (X̃), σ 2 )) (8) with its correspondent from X̃ and Xk+1 is constructed

444
recursively from Xk . By making the assumption that pixels annotated examples. With this approach, we aim to create
are independently distributed, we have: a model able to generate clean images from annotated
Y
k+1 Y
n ones, that are indistinguishable by a good discriminator.
p(Xk+1 |X̃) = p(pi (X)|pi (X̃), i ∈ U ) p(pi (X)|pi (X̃)) (10) Compared to the DAE approach, the adversarial autoencoder
i=1 i=k+2
can be trained on a dataset without aligned examples. The
Y
k Y
n
architecture of the autoencoder is the same as the one used
p(Xk+1 |X̃) ≥ p(pi (X)|pi (X̃), i ∈ U ) p(pi (X)|pi (X̃)) (11)
i=1 i=k+1 for the denoising approach (Fig. 2). The discriminator is
a neural network with 3 convolutional layers and 2 fully
p(Xk+1 |X̃) ≥ p(Xk |X̃) (12)
connected layers (Fig. 4), trained to minimize the binary
So, an image with with more unlabeled pixels copied from cross-entropy criterion:
the input is as good if not better than the original prediction.
1X
n
For this purpose, we trained a patch classifier on regions of
BCE(o, t) = − (ti log(oi )+(1−ti ) log(1−oi )) (13)
size 8x8 cropped from the training set images. The patch size n i=1
was chosen such that the text characteristics are preserved,
clean regions are filtered and the picture can be split in In parallel, the autoencoder is trained to minimise the MSE
equal-sized regions. In [3] they proposed the same approach, with respect to its input, and maximize the discriminator
with a filter size of 5x5 pixels. Patches classified as clean error (1).
are copied directly from the annotated image, while labeled
regions are copied from the prediction. The patch classifier
is a neural network with 4 convolutional layers and 2 fully
connected layers with sigmoidal output (Fig. 3), trained with
binary cross-entropy criterion and Adam optimization.

Figure 4: Adversarial architecture. The discriminator takes


the generator output and tries to predict whether the input
is an annotated picture or not, minimizing the binary cross-
entropy criterion. The autoencoder parameters are updated
based on the gradient from the MSE criterion with its input
and the negative gradient of its output with respect to the
discriminator BCE.
Red: ReLU + MaxPooling after layer
Figure 3: Patch Network with 3x3 convolutions and ReLU
after the second and last convolution followed by two fully
connected layers with 1024 units and a Dropout layer in E. Models for greyscale and color images
between. A final Sigmoid layer assigns probabilities for one
of the two classes: “clean” and “with text/unclean”. Different architectures are used for greyscale and color
Green: ReLU transfer after layer images. In the first case, the encoder is represented by a
neural network with 6 convolutional layers grouped in 3
parts separated by max-pooling layers and ReLU transfer
D. Autoencoder with critique layers, ending with one fully connected layer. All convolu-
Although in our dataset obtaining aligned images is trivial tions have a kernel size of 3x3 with stride 1 and padding 1
that may not be so for real world examples. This makes to preserve dimensions, and all max-polling have size 2x2
reproducing the corruption process much more difficult, thus with stride 1. The decoder has the mirrored architecture of
increasing the computational expense for generating such the encoder (Fig. 5). The examples are reshaped to a tensor
examples. Ideally, we would like to train a model on a of size (64, 64, 1).
mixed dataset, without the need to make pairs (x, x̃). As For color images, the previous architecture was not com-
proposed by [3], we test an approach with two models: plex enough to reproduce tensors of size (64, 64, 3). We
an autoencoder and a critique. The discriminator learns to adjusted the denoising autoencoder (Fig. 7) to increase the
distinguish between clean and annotated images generated layers depth faster in order to learn more regularities [7].
by the autoencoder. The generator is trained to replicate The training process and the results obtained are presented
its input and also to increase the discriminator error for in the next section.

445
Figure 7: DAE Color architecture with Encoder + Decoder.
Every convolution is followed by a ReLU transfer layer. Af-
Figure 5: DAE architecture for greyscale images, En- ter the second convolution layer we add 2x2 Pooling layers
coder+Decoder. Having an annotated image is input, it tries after convolutional layers. Last layer is fully connected with
to reproduce its clean output, minimizing the MSE criterion. 8*8*256 parameters.
Green: ReLU transfer after layer Green: ReLU transfer after layer
Red: ReLU + MaxPooling (Encoder)/MaxUnpooling (De- Red: ReLU + MaxPooling (Encoder)/MaxUnpooling (De-
coder) after layer coder) after layer

F. Non-blind Inpainting Table I: Greyscale examples


Labeled input DAE output Patched DAE output

(a) Generator (as presented in [9])

(b) Discriminator (as presented in [9])


IV. E XPERIMENTS
For comparison purposes, we implemented the architec-
ture presented in [12] and trained a generator (6a) that pro-
duces images with faces from random noise and a discrim- We used images from 10k US Adult Faces Database [2] to
inator (6b) that distinguish between samples coming from train and test our models. After the pictures were resized to
the distribution of real images and the ones coming from the 64x64 pixels, we generated labeled examples for each image
distribution of the generator. The rectangular regions corre- by randomly adding a name over it (Fig. 1). We created a
sponding to annotations were cropped and new information separate set by translating images to greyscale using ITU-R
299 587 114
was generated based on the remaining contextual data. 601-2 luma transform R 1000 + G 1000 + B 1000 .

446
A. Greyscale Images Table II: Color examples
We aligned annotated images with their normal counter- Input DAE Patched Adversarial
parts and trained a denoising autoencoder on these pairs. In
this case, the examples are tensors with shape (64, 64, 1),
and the implemented architecture is presented in Fig. 5. We
used 7000 examples for training, 2000 for validation and
1000 for the test set. The hyper-parameters were chosen
empirically and are set to: batch size 64, learning rate 0.1
and default Adam. Processed images from the test set have
the annotation removed but do present some noise (Table I,
Column 2).
A patch classifier was also trained to distinguish regions
with text (Fig. 3). For this model, the training set consists
of 10k cropped regions from annotated images, with a 1:1
ratio of patches with and without text. The empirically
validated hyper-parameters are: batch size 256 and learning
rate 0.001. To generate the final output, regions ”corrupted”
with annotations are copied from the denoising autoencoder error, in order to adjust the learning accordingly. By setting
output, while clean patches are copied from the input image a constant threshold (φ = 0.3 empirically chosen) we can
(Table I, Column 3). The produced results are similar to the stop the generator training if the discriminator accuracy on
ones obtained by [3] (Fig. 8). labeled examples is bellow this margin, i.e. the discrim-
inator can’t detect reproduced images with text. Also, if
the discriminator accuracy is higher than 1 − φ, we stop
its training and let the generator improve its predictions.
However, we couldn’t find a satisfactory balance between
good input reproduction and text-removal (Table II, Column
4). It seems that the gradient coming from the adversarial
loss (D(R, S)), into the generator, tends to attenuate all
particularities of a picture, not just the annotations. On the
other side, assigning a bigger weight to the input replication
Figure 8: Results obtained by [3], with an adversarial cost (C(X, R)) would make the generator reproduce the
autoencoder and patch filtering sensitive information. The results are oscillating between a
constant output (Fig. 9a) and images with clear captions
B. Color Images (Fig. 9b).
1) Denoising Autoencoder: For color images, we first
implemented denoising autoencoder architecture presented
in Fig. 7. Again, we used 7000 aligned examples for training,
2000 for validation and 1000 for test, minimizing the mean-
squared error with gradient descent and Adam optimization.
The empirically chosen hyper-parameters are: batch size (a) Constant output (b) Annotations remain
64 and learning rate 0.0001. As in the greyscale case, the Figure 9: Different adversarial hyper-parameters results.
reproduced images do not contain the annotations, but are
noisy (Table II, Column 2).
We adjusted the previous patch classifier (Fig. 3) to accept C. Non-blind Inpainting
color images and trained it on the new set. Constructing The generator and discriminator were trained on 9000
patched images by filtering clean regions does provide better examples. On the remaining images, we cropped the rect-
results (Table II, Column 3). angles with annotations and obtained a reconstruction of
2) Autoencoder with critique: We conducted next exper- the original data by minimizing equation 4 with stochastic
iments with an adversarial strategy. Captioned and clean gradient descent and momentum. The final output is com-
images are mixed in the training set and labeled accordingly posed from clean regions of the input and generated regions
in order to train the discriminator (Fig. 4). During training, corresponding to the missing information. The results (Table
we watched the discriminator classification performance for III) present plausible representations, but given the higher
the two types of images and the autoencoder reproduction loss of information during the masking process, in most

447
Table III: Non-blind Inpainting Edinburgh, Department of Informatics, Edinburgh, UK,
Input Masked Image Output EH8 9AB, 2016.
[4] I. J. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu,
D. Warde-Farley, S. Ozair, A. Courville, and Y. Ben-
gio. Generative adversarial nets. Technical report,
Universite de Montreal, Departement d’informatique et
de recherche operationnelle, Montreal, QC H3C 3J7,
2014.
[5] S. Khallaghi. Training autoencoders on imagenet using
torch 7, 2016. http://siavashk.github.io/2016/02/22/
autoencoder-imagenet/.
[6] D. Kingma and J. Ba. Adam: A method for stochastic
optimization, 2015.
[7] F.-F. Li, A. Karpathy, and J. Johnson. Convolutional
neural networks for visual recognition, 2016. http://
cs231n.stanford.edu/.
[8] D. Pathak, P. Krahenbuhl, J. Donahue, T. Darrell, and
cases the contextual information does not suffice to uniquely A. A. Efros. Context encoders: Feature learning by
determine the original input. inpainting, 2016. https://arxiv.org/abs/1604.07379.
[9] A. Radford, L. Metz, and S. Chintala. Unsupervised
V. C ONCLUSION AND F UTURE W ORK representation learning with deep convolutional gener-
This work presented different approaches to censor ative adversarial networks, 2016.
sensitive information from greyscale and color images. [10] P. Vincent, H. Larochelle, Y. Bengio, and P.-A. Man-
Using a DAE architecture with aligned examples, the zagol. Extracting and composing robust features with
private data is removed, but the reconstructed images denoising autoencoders. Technical report, Universite
contain artifacts. We showed that if the sensitive regions de Montreal, 2008.
can be detected with a high probability, for a specific [11] P. Vincent, H. Larochelle, I. Lajoie, Y. Bengio, and P.-
problem, copying ”clean” regions from the original image A. Manzagol. Stacked denoising autoencoders: Learn-
does always improve the generated prediction. A step ing useful representations in a deep network with a
forward would be detecting and replacing irregular shapes, local denoising criterion. Journal of Machine Learning
instead of fixed rectangular patches. This approach has Research, 2010.
a clear limitation, being unable to generalize beyond the [12] R. Yeh, C. Chen, T. Y. Lim, M. Hasegawa-Johnson, and
type of corruption learned from the training set. Another M. N. Do. Semantic image inpainting with perceptual
addition can be separating the sensitive parts into a new and contextual losses. Technical report, Dept. of
image, the model producing two outputs in this case. Electrical and Computer Engineering, University of
Illinois, 2016.
In the adversarial setup where the discriminator input
is given only by samples coming from the generator, the
later one tends to collapse the original bi-modal distribution
(label/unlabeled examples) to a singularity (constant
output), or to preserve both modes. We concluded that
better results can be produced if the discriminator does not
only learn from the generator distribution, but also from
the distribution of real examples, forcing the generator to
fit the later one.
R EFERENCES
[1] A. Allen and W. Li. Generative adversarial denoising
autoencoder for face completion, 2016. http://www.cc.
gatech.edu/∼hays/7476/projects/Avery Wenchen/.
[2] W. Bainbridge. 10k us adult faces database. http://
wilmabainbridge.com/facememorability2.html.
[3] H. Edwards and A. Storkey. Censoring representations
with an adversary. Technical report, University of

448

You might also like