B EYOND P IXEL N ORM -B ALLS : P ARAMETRIC A DVERSARIES USING AN A NALYTICALLY D IFFERENTIABLE R ENDERER
Anonymous authors
Paper under double-blind review
A BSTRACT
Many machine learning image classiﬁers are vulnerable to adversarial attacks, inputs with perturbations designed to intentionally trigger misclassiﬁcation.
Current adversarial methods directly alter pixel colors and evaluate against pixel norm-balls : pixel perturbations smaller than a speciﬁed magnitude, according to a measurement norm.
This evaluation, however, has limited practical utility since perturbations in the pixel space do not correspond to underlying real-world phenomena of image formation that lead to them and has no security motivation attached.
Pixels in natural images are measurements of light that has interacted with the geometry of a physical scene.
As such, we propose a novel evaluation measure, parametric normballs , by directly perturbing physical parameters that underly image formation.
One enabling contribution we present is a physically-based differentiable renderer that allows us to propagate pixel gradients to the parametric space of lighting and geometry.
Our approach enables physically-based adversarial attacks, and our differentiable renderer leverages models from the interactive rendering literature to balance the performance and accuracy trade-offs necessary for a memory-efﬁcient and scalable adversarial data augmentation workﬂow.
I NTRODUCTION
Research in adversarial examples continues to contribute to the development of robust (semi-)supervised learning (Miyato et al., 2018), data augmentation (Goodfellow et al., 2015; Sun et al., 2018), and machine learning understanding (Kanbak et al., 2018).
One important caveat of the approach pursued by much of the literature in adversarial machine learning, as discussed recently (Goodfellow, 2018; Gilmer et al., 2018), is the reliance on overly simpliﬁed attack metrics: namely, the use of pixel value differences between an adversary and an input image, also referred to as the pixel norm-balls .
The pixel norm-balls game considers pixel perturbations of norm-constrained magnitude (Goodfellow et al., 2015), and is used to develop adversarial attackers, defenders and training strategies.
The pixel norm-ball game is attractive from a research perspective due to its simplicity and well-posedness: no knowledge of image formation is required and any arbitrary pixel perturbation remains eligible (so long as it is “small”, in the perceptual sense).
Although the pixel norm-ball is useful for research purposes, it only captures limited real-world security scenarios.
[Figure] [Figure]
Despite the ability to devise effective adversarial methods through the direct employment of optimizations using the pixel norm-balls measure, the pixel manipulations they promote are divorced from the types of variations present in the real world, limiting their usefulness “in the wild”.
Moreover, this methodology leads to defenders that are only effective when defending against unrealistic images/attacks, not generalizing outside of the space constrained by pixel norm-balls.
In order to consider conditions that enable adversarial attacks in the real world, we advocate for a new measurement norm that is rooted in the physical processes that underly realistic image synthesis, moving away from overly simpliﬁed metrics, e.g., pixel norm-balls.
Our proposed solution – parametric norm-balls – rely on perturbations of physical parameters of a synthetic image formation model, instead of pixel color perturbations (Figure 2).
To achieve this, we use a physically-based differentiable renderer which allows us to perturb the underlying parameters of the image formation process.
Since these parameters indirectly control pixel colors, perturbations in this parametric space implicitly span the space of natural images.
We will demonstrate two advantages that fall from considering perturbations in this parametric space: (1) they enable adversarial approaches that more readily apply to real-world applications, and (2) they permit the use of much more signiﬁcant perturbations (compared to pixel norms), without invalidating the realism of the resulting image (Figure 1).
We validate that parametric norm-balls game playing is critical for a variety of important adversarial tasks, such as building defenders robust to perturbations that can occur naturally in the real world.
We perform perturbations in the underlying image formation parameter space using a novel physicallybased differentiable renderer.
Our renderer analytically computes the derivatives of pixel color with respect to these physical parameters, allowing us to extend traditional pixel norm-balls to physicallyvalid parametric norm-balls.
Notably, we demonstrate perturbations on an environment’s lighting and on the shape of the 3D geometry it shades.
Our differentiable renderer achieves state-of-the-art performance in speed and scalability (Section 3) and is fast enough for rendered adversarial data augmentation (Section 5): training augmented with adversarial images generated with a renderer.
Existing differentiable renders are slow and do not scalable to the volume of high-quality, highresolutions images needed to make adversarial data augmentation tractable (Section 2).
Given our analytically-differentiable renderer (Section 3), we are able to demonstrate the efﬁcacy of parametric space perturbations for generating adversarial examples.
These adversaries are based on a substantially different phenomenology than their pixel norm-balls counterparts (Section 4).
Ours is among the ﬁrst steps towards the deployment of rendered adversarial data augmentation in real-world applications: we train a classiﬁer with computer-generated adversarial images, evaluating the performance of the training against real photographs (i.e., captured using cameras; Section 5).
We test on real photos to show the parametric adversarial data augmentation increases the classiﬁer’s robustness to “deformations” happened in the real world.
Our evaluation differs from the majority of existing literature which evaluates against computer-generated adversarial images, since our parametric space perturbation is no-longer a wholly idealized representation of the image formation model but, instead, modeled against of theory of realistic image generation.
R ELATED W ORK
Our work is built upon the fact that simulated or rendered images can participate in computer vision and machine learning on real-world tasks.
Many previous works use rendered (simulated) data to train deep networks, and those networks can be deployed to real-world or even outperform the state-of-the-art networks trained on real photos (Movshovitz-Attias et al., 2016; Chen et al., 2016;
Varol et al., 2017; Su et al., 2015; Johnson-Roberson et al., 2017; Veeravasarapu et al., 2017b; Sadeghi & Levine, 2016; James & Johns, 2016). For instance, Veeravasarapu et al. (2017a) show that training with and 90 % data can reach the level training with Tremblay et al.
(2018) even demonstrate that the network trained on synthetic data yields a better performance than using real data alone.
As rendering can cheaply provide a theoretically inﬁnite supply of annotated input data, it can generate data which is orders of magnitude larger than existing datasets.
This emerging trend of training on synthetic data provides an exciting direction for future machine learning development.
Our work complements these works.
We demonstrate the utility of rendering can be used to study the potential danger lurking in misclassiﬁcation due to subtle changes to geometry and lighting.
This provides a future direction of combining with synthetic data generation pipelines to perform physically based adversarial training on synthetic data .
Adversarial Examples Szegedy et al.
(2014) expose the vulnerability of modern deep neural nets using purposefully-manipulated images with human-imperceptible misclassiﬁcation-inducing noise.
Goodfellow et al.
(2015) introduce a fast method to harness adversarial examples, leading to the idea of pixel norm-balls for evaluating adversarial attackers/defenders.
Since then, many signiﬁcant developments in adversarial techniques have been proposed (Akhtar & Mian, 2018; Szegedy et al., 2014; Rozsa et al., 2016; Kurakin et al., 2017; Moosavi Dezfooli et al., 2016; Dong et al., 2018;
Papernot et al., 2017; Moosavi-Dezfooli et al., 2017; Chen et al., 2017; Su et al., 2017).
Our work extends this progression in constructing adversarial examples, a problem that lies at the foundation of adversarial machine learning.
Kurakin et al.
(2016) study the transferability of attacks to the physical world by printing then photographing adversarial images .
Athalye & Sutskever (2017) and Eykholt et al.
(2018) propose extensions to non-planar (yet, still ﬁxed) geometry and multiple viewing angles.
These works still rely fundamentally on the direct pixel or texture manipulation on physical objects.
Since these methods assume independence between pixels in the image or texture space they remain variants of pixel norm-balls.
This leads to unrealistic attack images that cannot model real-world scenarios (Goodfellow, 2018; Hendrycks & Dietterich, 2018; Gilmer et al., 2018).
Zeng et al.
(2017) generate adversarial examples by altering physical parameters using a rendering network (Liu et al., 2017) trained to approximate the physics of realistic image formation.
This data-driven approach leads to an image formation model biased towards the rendering style present in the training data.
This method also relies on differentiation through the rendering network in order to compute adversaries, which requires high-quality training on a large amount of data. Even with perfect training, in their reported performance, it still requires 12 minutes on average to ﬁnd new adversaries, we only take a few seconds Section 4.1.
Our approach is based on a differentiable physically-based renderer that directly (and, so, more convincingly) models the image formation process, allowing us to alter physical parameters – like geometry and lighting – and compute
[Table]
derivatives (and adversarial examples) much more rapidly compared to the (Zeng et al., 2017).
We summarize the difference between our approach and the previous non-image adversarial attacks in Table 1.
[Table] 14) (cid:88) (cid:88)
Analytical (Ours) (cid:88) (cid:88) (cid:88)
Differentiable Renderer Applying parametric norm-balls requires that we differentiate the image formation model with respect to the physical parameters of the image formation model.
Modern realistic computer graphics models do not expose facilities to directly accommodate the computation of derivatives or automatic differentiation of pixel colors with respect to geometry and lighting variables.
A physically-based differentiable renderer is fundamental to computing derivative of pixel colors with respect to scene parameters and can beneﬁt machine learning in several ways, including promoting the development of novel network architectures (Liu et al., 2017), in computing adversarial examples (Athalye & Sutskever, 2017; Zeng et al., 2017), and in generalizing neural style transfer to a 3D context (Kato et al., 2018;
Liu et al., 2018).
Recently, various techniques have been proposed to obtain these derivatives: Wu et al.
; Liu et al.
Eslami et al.
(2016) use neural networks to learn the image formation process provided a large amount of input/output pairs.
This introduces unnecessary bias in favor of the training data distribution, leading to inaccurate derivatives due to imperfect learning.
Kato et al.
(2018) propose a differentiable renderer based on a simpliﬁed image formation model and an underlying linear approximation to obtain derivatives.
Their approach requires no training and is unbiased, but their approximation introduces errors in the derivative computation.
For the sake of obtaining derivatives Loper & Black (2014)
; Genova et al.
(2018) use automatic differentiation to build fully differentiable renderers.
These renderers, however, are expensive to evaluate, requiring orders of magnitude more compute and much larger memory footprints compared to the approximate method.
Our novel differentiable renderer overcomes these limitations by efﬁciently computing accurate (analytical) derivatives of a physically-based image formation model.
We model image variations by changing geometry and realistic lighting conditions in an analytically differentiable manner, relying on an accurate model of diffuse image formation that extend spherical harmonics-based shading methods (Appendix C).
Our analytic derivatives are efﬁcient to evaluate, have scalable memory consumption, are unbiased, and are accurate by construction (Table 2).
Our renderer explicitly models the physics of the image formation processes, and so the images it generates are realistic enough to illicit correct classiﬁcations from networks trained on real-world photographs.
A DVERSARIAL A TTACKS IN P ARAMETRIC S PACES
Adversarial attacks based on pixel norm-balls typically generate adversarial examples by deﬁning a cost function over the space of images C : I → R that enforces some intuition of what failure should look like, typically using variants of gradient descent where the gradient ∂ C / ∂I is accessible by differentiating through networks (Szegedy et al., 2014; Goodfellow et al., 2015; Rozsa et al., 2016;
Kurakin et al., 2017; Moosavi Dezfooli et al., 2016; Dong et al., 2018).
The choices for C include increasing the cross-entropy loss of the correct class (Goodfellow et al., 2015), decreasing the cross-entropy loss of the least-likely class (Kurakin et al., 2017), using a combination of cross-entropies (Moosavi Dezfooli et al., 2016), and more (Szegedy et al., 2014;
Rozsa et al., 2016; Dong et al., 2018; Tramèr et al., 2017).
We combine of cross-entropies to provide ﬂexibility for choosing untargeted and targeted attacks by specifying a different set of labels:
[Equation]
where I is the image, f ( I ) is the output of the classiﬁer, L d , L i are labels which a user wants to decrease and increase the predicted conﬁdences respectively.
In our experiments, L d is the correct class and L i is either ignored or chosen according to user preference.
Our adversarial attacks in the parametric space consider an image
I ( U, V ) is the function of physical parameters of the image formation model, including the lighting U and the geometry V .
Adversarial examples constructed by perturbing physical parameters can then be computed via the chain rule
[Equation]
where ∂I / ∂U , ∂I / ∂V are derivatives with respect to the physical parameters and we evaluate using our physically based differentiable renderer.
In our experiments, we use gradient descent for ﬁnding parametric adversarial examples where the gradient is the direction of ∂I / ∂U , ∂I / ∂V .
3. P HYSICALLY B ASED D IFFERENTIABLE R ENDERER
[Figure]
than the previous method.
Rendering is the process of generating a 2D image from a 3D scene by simulating the physics of light.
Light sources in the scene emit photons that then interact with objects in the scene.
At each interaction, photons are either reﬂected, transmitted or absorbed, changing trajectory and repeating until arriving at a sensor such as a camera.
A physically based renderer models the interactions mathematically (Pharr et al., 2016), and our task is to analytically differentiate the physical process.
We develop our differentiable renderer with common assumptions in real-time rendering (Akenine-Moller et al., 2008) – diffuse material, local illumination, and distant light sources.
Our diffuse material assumption considers materials which reﬂect lights uniformly for all directions, equivalent to considering non-specular objects.
We assume that variations in the material (texture) [Figure] [Figure] are piece-wise constant with respect to our triangle mesh discretization.
The local illumination assumption only considers lights that bounce directly from the light source to the camera.
Lastly, we assume light sources are far away from the scene, allowing us to represent lighting with one spherical function.
For a more detailed rationale of our assumptions, we refer readers to Appendix B).
These assumptions simplify the complicated integral required for rendering (Kajiya, 1986) and allow us to represent lighting in terms of spherical harmonics , an orthonormal basis for spherical functions analogous to Fourier transformation.
Thus, we can analytically differentiate the rendering equation to acquire derivatives with respect to lighting, geometry, and texture (derivations found in Appendix C).
Using analytical derivatives avoids pitfalls of previous differentiable renderers (see Section 2) and make our differentiable renderer orders of magnitude faster than the previous fully differentiable renderer O PEN DR (Loper & Black, 2014)
(see Figure 3).
In terms of scalability, our approach can handle problems with more than 100,000 variables, while O PEN DR runs out of memory for problems with more than 3,500 variables.
3. A DVERSARIAL L IGHTING AND G EOMETRY
Adversarial lighting denotes adversarial examples generated by changing the spherical harmonics
lighting coefﬁcients U (Green, 2003).
As our differentiable renderer allows us to compute ∂I / ∂U analytically (derivation is provided in Appendix C.4), we can simply apply the chain rule:
U ← U
[Equation]
where ∂ C / ∂I is the derivative of the cost function with respect to pixel colors and can be obtained by differentiating through the network.
Spherical harmonics act as an implicit constraint to prevent unrealistic lighting because natural lighting environments everyday life are dominated by lowfrequency signals.
For instance, rendering of diffuse materials can be approximated with only 1 % pixel intensity error by the ﬁrst 2 orders of spherical harmonics (Ramamoorthi & Hanrahan, 2001).
As computers can only represent a ﬁnite number of coefﬁcients, using spherical harmonics for lighting implicitly ﬁlters out high-frequency, unrealistic lightings.
Thus, perturbing the parametric space of spherical harmonics lighting gives us more realistic compared to image-pixel perturbations Figure 1.
Adversarial geometry is a adversarial example computed by changes the position of the shape’s surface.
The shape is encoded as a triangle mesh with | V | vertices and | F | faces, surface points are vertex positions V ∈ R | V |× 3 which determine per-face normals N ∈ R | F |× 3 which in turn determine the shading of the surface.
We can compute adversarial shapes by applying the chain rule:
[Equation]
[Figure] [Figure] [Equation] where ∂I / ∂N is computed via a derivation in Appendix E. Each triangle only has one normal on its face, making ∂N / ∂V computable analytically.
In particular, the 3 × 3 Jacobian of a unit face normal vector n i ∈ R 3 of the j th face of the triangle mesh V with respect to one of its corner vertices v j ∈ R 3 is
[Equation]
where h ij ∈ R 3 is the height vector: the shortest vector to the corner v j from the opposite edge.
R ESULTS AND E VALUATION
We have described how to compute adversarial examples by parametric perturbations, including lighting and geometry.
In this section, we show that adversarial examples exist in the parametric spaces, then we analyze the characteristics of those adversaries and parametric norm-balls.
We use 49 × 3 spherical harmonics coefﬁcients to represent environment lighting, with an initial realworld lighting condition (Ramamoorthi & Hanrahan, 2001).
Camera parameters and the background images are empirically chosen to have correct initial classiﬁcations and avoid synonym sets.
In
Figure 4 we show that single-view adversarial lighting attack can fool the classiﬁer (pre-trained
ResNet-101 on ImageNet (He et al., 2016)).
Figure 5 shows multi-view adversarial lighting, which optimizes the summation of the cost functions for each view, thus the gradient is computed as the summation over all camera views:
[Equation]
[Figure] [Equation] [Figure] If one is interested in a more speciﬁc subspace, such as outdoor lighting conditions governed by sunlight and weather, our adversarial lighting can adapt to it.
In Figure 7, we compute adversarial lights over the space of skylights by applying one more chain rule to the Preetham skylight parameters (Preetham et al., 1999; Habel et al., 2008).
Details about taking these derivatives are provided in Appendix D. Although adversarial skylight exists, its low degrees of freedom (only three parameters) makes it more difﬁcult to ﬁnd adversaries.
In Figure 8 and Figure 9 we show the existence of adversarial geometry in both single-view and multi-view cases.
Note that we upsample meshes to have > 10K vertices as a preprocessing step to increase the degrees of freedom available for perturbations.
Multiview adversarial geometry enables us to perturb the same 3D shape from different viewing directions,
[Table] [Table]
[Table]
which enables us to construct a deep optical illusion : The same 3D shape are classiﬁed differently from different angles.
To create the optical illusion in Figure 6, we only need to specify the L i in
Equation (1) to be a dog and a cat for two different views.
4. P ROPERTIES OF P ARAMETRIC N ORM -B ALLS AND A DVERSARIES
To further understand parametric adversaries we analyze how do parametric adversarial examples generalize to black-box models.
In Table we test 5,000 ResNet parametric adversaries on unseen networks including AlexNet (Krizhevsky et al., 2012), DenseNet (Huang et al., 2017), SqueezeNet (Iandola et al., 2016) and VGG (Simonyan & Zisserman, 2014).
Our result shows that parametric adversarial examples also share across models.
In addition to different models, we evaluate parametric adversaries on black-box viewing directions.
This evaluation mimics the real-world scenario that a self-driving car would “see” a stop sign from different angles while driving.
In Table 4, we randomly sample 500 correctly classiﬁed views for a given shape and perform adversarial lighting and geometry algorithms only on a subset of views, then evaluate the resulting adversarial lights/shapes on all the views.
The results show that adversarial lights are more generalizable to fool unseen views; adversarial shapes, yet, are less generalizable.
[Figure]
Switching from pixel norm-balls to parametric norm-balls only requires to change the normconstraint from the pixel color space to the parametric space.
For instance, we can perform a quantitative comparison between parametric adversarial and random perturbations in Figure 10.
We use L ∞ -norm = 0 .
1 to constraint the perturbed magnitude of each lighting coefﬁcient, and L ∞ -norm = {+
+}
.to constrain the maximum displacement of surface points along each axis.
The results show how many parametric adversaries can fool the classiﬁer out of 10,000 adversarial lights and shapes respectively.
Not only do the parametric norm-balls show the effectiveness of adversarial perturbation, evaluating robustness using parametric norm-balls has real-world implications.
[Figure]
Runtime The inset presents our runtime per iteration for computing derivatives.
An adversary normally requires less than 10 iterations, thus takes a few seconds.
We evaluate our CPU P YTHON implementation, except the rendering is implemented using O PEN GL, on an
Intel Xeon 3.5GHz CPU with 64GB of RAM and an NVIDIA GeForce GTX 1080.
Our runtime mainly depends on the number of pixels requiring derivatives.
R ENDERED A DVERSARIAL D ATA A UGMENTATION A GAINST R EAL P HOTOS
We inject adversarial examples, generated using our differentiable renderer, into the training process of modern image classiﬁers.
Our goal is to increase the robustness of these classiﬁers to real-world perturbations.
Traditionally, adversarial training is evaluated against computer-generated adversarial images (Kurakin et al., 2017; Madry et al., 2018; Tramèr et al., 2017).
In contrast, our evaluation differs from the majority of the literature, as we evaluate performance against real photos (i.e., images captured using a camera), and not computer-generated images.
This evaluation method is motivated by our goal of increasing a classiﬁer’s robustness to “perturbations” that occur in the real world and result from the physical processes underlying real-world image formation.
We present preliminary steps towards this objective, resolving the lack of realism of pixel norm-balls and evaluating our augmented classiﬁers (i.e., those trained using our rendered adversaries) against real photographs.
Training We train the WideResNet (16 layers, 4 wide factor) (Zagoruyko & Komodakis, 2016) on CIFAR-100 (Krizhevsky & Hinton, 2009) augmented with adversarial lighting examples.
We apply a common adversarial training method that adds a ﬁxed number of adversarial examples each epoch (Goodfellow et al., 2015; Kurakin et al., 2017).
We refer readers to Appendix F for the training detail.
In our experiments, we compare three training scenarios: (1) CIFAR-100, (2) CIFAR-
+ 100 images under random lighting, and (3) CIFAR-100 + 100 images under adversarial lighting.
Comparing to the accuracy reported in (Zagoruyko & Komodakis, 2016), WideResNets trained on these three cases all have comparable performance ( ≈ 77 % ) on the CIFAR-100 test set.
evaluate against real photos (captured by a camera), not computergenerated images. This illustrates a subset of our test data.
Testing We create a test set of real photos, captured in a laboratory setting with controlled lighting and camera parameters: we photographed oranges using a calibrated Prosilica GTcamera under different lighting conditions, each generated by projecting different lighting patterns using an LG PH550 projector.
This hardware lighting setup projects lighting patterns from a ﬁxed solid angle of directions onto the scene objects.
Figureillustrates samples from the 500 real photographs of our dataset.
We evaluate the robustness of our classiﬁer models according to test accuracy.
Of note, average prediction accuracies over ﬁve trained WideResNets on our test data under the three training cases are (1) 4.6 % , (2) 40.4 % , and (3) 65.8 % .
This result supports the fact that training on rendered images can improve the networks’ performance on real photographs.
Our preliminary experiments motivate the potential of relying on rendered adversarial training to increase the robustness to visual phenomena present in the real-world inputs.
L IMITATIONS & F UTURE W ORK
Using parametric norm-balls to remove the lack of realism of pixel norm-balls is only the ﬁrst step to bring adversarial machine learning to real-world.
Coupling the differentiable renderer with methods for reconstructing 3D scenes, such as (Veeravasarapu et al., 2017b; Tremblay et al., 2018), has the potential to develop a complete pipeline for rendered adversarial training.
We can take a small set of real images, constructing 3D virtual scenes which have real image statistics, using our approach to manipulate the predicted parameters to construct the parametric adversarial examples, then perform rendered adversarial training.
This direction has the potential to produce limitless simulated adversarial data augmentation for real-world tasks.
Our differentiable renderer models the change of realistic environment lighting and geometry.
Incorporating real-time rendering techniques from the graphics community could further improve the quality of rendering.
Removing the locally constant texture assumption could improve our results.
Extending the derivative computation to materials could enable “adversarial materials”.
Propagating gradient information to shape skeleton could also create “adversarial poses”.
These extensions offer a set of tools for modeling real security scenarios.
For instance, we can train a self-driving car classiﬁer that can robustly recognize pedestrians under different poses, lightings, and cloth deformations.
Supplementary Material A C OMPARISON B ETWEEN P ERTURBATION S PACES
We extend our comparisons against pixel norm-balls methods (Figure 1) by visualizing the results and the generated perturbations (Figure 12).
We hope this ﬁgure elucidates that our parametric perturbation are more realistic several scales of perturbations.
[Figure]
B P HYSICALLY B ASED R ENDERING
[Figure]
Figure PBR models the physics of light that emitted from the light source, interact with the scene, then arrive a camera.
Physically based rendering (PBR) seeks to model the ﬂow of light, typically the assumption that there exists a collection of light sources that generate light; a camera that receives this light; and a scene that modulates the ﬂow light between the light sources and camera (Pharr et al., 2016).
What follows is a brief discussion of the general task of rendering an image from a scene description and the approximations we take in order to make our renderer efﬁcient yet differentiable.
Computer graphics has dedicated decades of effort into developing methods and technologies to enable PBR to synthesize of photorealistic images under a large gamut of performance requirements.
Much of this work is focused around taking approximations of the cherished Rendering equation (Kajiya, 1986), which describes the propagation of light through a point in space.
If we let u o be the output radiance, p be the point in space, ω
o be the output direction, u e be the emitted radiance, u i be incoming radiance, ω
i be the incoming angle, f r be the way light be reﬂected off the material at that given point in space we have:
[Equation]
From now on we will ignore the emission term u e as it is not pertinent to our discussion.
Furthermore, because the speed of light is substantially faster than the exposure time of our eyes, what we perceive is not the propagation of light at an instant, but the steady state solution to the rendering equation evaluated at every point in space.
Explicitly computing this steady state is intractable for our applications and will mainly serve as a reference for which to place a plethora of assumptions and simpliﬁcations we will make for the sake of tractability.
Many of these methods focus on ignoring light with nominal effects on the ﬁnal rendered image vis a vis assumptions on the way light travels.
For instance, light is usually assumed to have nominal interacts with air, which is described as the assumption that the space between objects is a vacuum, which constrains the interactions of light to the objects in a scene.
Another common assumption is that light does not penetrate objects, which makes it difﬁcult to render objects like milk and human skin 1 .
This constrains the complexity of light propagation to the behavior of light bouncing off of object surfaces.
B. L OCAL I LLUMINATION
It is common to see assumptions that limit number of bounces light is allowed.
In our case we chose to assume that the steady state is sufﬁciently approximated by an extremely low number of iterations: one.
This means that it seems sufﬁcient to model the lighting of a point in space by the light sent to it directly by light sources.
Working with such a strong simpliﬁcation does, of course, lead to a few artifacts.
For instance, light occluded by other objects is ignored so shadows disappear and auxiliary techniques are usually employed to evaluate shadows (Williams, 1978; Miller, 1994).
When this assumption is coupled with a camera we approach what is used in standard rasterization systems such as O PEN GL (Shreiner & Group, 2009), which is what we use.
These systems compute the illumination of a single pixel by determining the fragment of an object visible through that pixel and only computing the light that traverses directly from the light sources, through that fragment, to that pixel.
The lighting of a fragment is therefore determined by a point and the surface normal at that point, so we write the fragment’s radiance as R ( p, n , ω
[Equation]
B. L AMBERTIAN M ATERIAL
[Figure]
Each point on an object has a model approximating the transfer of incoming light to a given output direction f r , which is usually called the material.
On a single object the material parameters may vary quite a bit and the correspondence between points and material parameters is usually called the texture map which forms the texture of an object.
There exists a wide gamut of material models, from mirror materials that transport light from a single input direction to a single output direction, to materials that reﬂect light evenly in all directions, to materials liked brushed metal that reﬂect differently along different angles.
For the sake of document we only consider diffuse materials, also called Lambertian materials, where we assume that incoming light is reﬂected uniformly, i.e f r is a constant function with respect to angle, which we denote f r ( p, ω i , ω o )
=
ρ ( p ) :
[Equation]
This function ρ is usually called the albedo , which can be perceived as color on the surface for diffuse material, and we reduce our integration domain to the upper hemisphere Ω( n ) in order to model light not bouncing through objects.
Furthermore, since only the only ω and u are the incoming ones we can now suppress the “incoming” in our notation and just use ω and u respectively.
B. E NVIRONMENT M APPING
The illumination of static, distant objects such as the ground, the sky, or mountains do not change in any noticeable fashion when objects in a scene are moved around, so u can be written entirely in terms of ω , u ( p, ω )
=
u ( ω ) .
If their illumination forms a constant it seems prudent to pre-compute or cache their contributions to the illumination of a scene.
This is what is usually called environment mapping and they ﬁt in the rendering equation as a representation for the total lighting of a scene, i.e the total incoming radiance u i .
Because the environment is distant, it is common to also assume that the position of the object receiving light from an environment map does not matter so this simpliﬁes
u i to be independent of position:
[Equation]
B. S PHERICAL H ARMONICS
Despite all of our simpliﬁcations, the inner integral is still a fairly generic function over S 2 .
Many techniques for numerically integrating the rendering equation have emerged in the graphics community and we choose one which enables us to perform pre-computation and select a desired spectral accuracy: spherical harmonics .
Spherical harmonics are a basis on S 2 so, given a spherical harmonics expansion of the integrand, the evaluation of the above integral can be reduced to a weighted product of coefﬁcients.
This particular basis is chosen because it acts as a sort of Fourier basis for functions on the sphere and so the bases are each associated with a frequency, which leads to a convenient multi-resolution structure.
In fact, the rendering of diffuse objects under distant lighting can be 99 % approximated by just the ﬁrst few spherical harmonics bases (Ramamoorthi & Hanrahan, 2001).
We will only need to note that the spherical harmonics bases Y ml are denoted with the subscript with l as the frequency and that there are 2 l + 1 functions per frequency, denoted by superscripts m between − l to l inclusively.
For further details on them please take a glance at Appendix C.
If we approximate a function f in terms of spherical harmonics coefﬁcients f ≈ (cid:80) lm f l,m Y ml
the integral can be precomputed as
[Equation]
Thus we have deﬁned a reduced rendering equation that can be efﬁciently evaluated using O PEN GL while maintaining differentiability with respect to lighting and vertices.
In the following appendix we will derive the derivatives necessary to implement our system.
C D IFFERENTIABLE R ENDERER
Rendering computes an image of a 3D shape given lighting conditions and the prescribed material properties on the surface of the shape.
Our differentiable renderer assumes Lambertian reﬂectance, distant light sources, local illumination, and piece-wise constant textures.
We will discuss how to explicitly compute the derivatives used in the main body of this text.
Here we give a detailed discussion about spherical harmonics and their advantages.
C. S PHERICAL H ARMONICS
Spherical harmonics are usually deﬁned in terms of the Legendre polynomials, which are a class of orthogonal polynomials deﬁned by the recurrence relation
[Equation]
The associated Legendre polynomials are a generalization of the Legendre polynomials and can be fully deﬁned by the relations
[Equation]
Using the associated Legendre polynomials P ml we can deﬁne the spherical harmonics basis as
[Equation]
where K
[Equation]
=
[Equation]
We will use the fact that the associated Legendre polynomials correspond to the spherical harmonics bases that are rotationally symmetric along the z axis ( m = 0 ).
In order to incorporate spherical harmonics into Equation
[Equation]
we change the integral domain from the upper hemisphere Ω( n ) back to S 2 via a max operation
[Equation]
We see that the integral is comprised of two components: a lighting component u ( ω ) and a component that depends on the normal max( ω · n , 0) .
The strategy is to pre-compute the two components by projecting onto spherical harmonics, and evaluating the integral via a dot product at runtime, as we will now derive.
C. L IGHTING IN S PHERICAL H ARMONICS
Approximating the lighting component u ( ω ) in Equation 19 using spherical harmonics Y ml up to band n can be written as
[Equation]
where U l,m ∈ R are coefﬁcients.
By using the orthogonality of spherical harmonics we can use evaluate these coefﬁcients as an integral between u ( ω ) and Y ml ( ω )
[Equation]
which can be evaluated via quadrature.
C. C LAMPED C OSINE IN S PHERICAL H ARMONICS
So far, we have projected the lighting term u ( ω ) onto the spherical harmonics basis.
To complete evaluating Equation 19 we also need to approximate the second component max( ω · n , 0) in spherical harmonics.
This is the so-called the clamped cosine function.
[Equation]
where G l,m ( n ) ∈ R can be computed by projecting g ( ω, n ) onto Y ml ( ω )
G l,m ( n
[Equation]
Unfortunately, this formulation turns out to be tricky to compute.
Instead, the common practice is to analytically compute the coefﬁcients for unit z direction ˜ G l,m =
G l,m ( n z ) =
G l,m ([0 , 0 , 1] (cid:124) ) and evaluate the coefﬁcients for different normals G l,m ( n ) by rotating ˜ G l,m .
This rotation, ˜ G l,m , can be computed analytically:
[Equation]
In fact, because max( ω · n z , 0) is rotationally symmetric around the z -axis, its projection onto Y ml ( ω ) will have many zeros except the rotationally symmetric spherical harmonics Y 0 l .
In other words, ˜ G l,m is non-zero only when m = 0 .
So we can simplify Equation 20 to
[Equation]
The evaluation of this integral can be found in Appendix A in (Basri & Jacobs, 2003).
We provide this here as well:
[Equation]
The spherical harmonics coefﬁcients G l,m ( n ) of the clamped cosine function g ( ω, n ) can be computed by rotating ˜ G l (Sloan et al., 2005) using this formula
[Equation]
So far we have projected the two terms in Equation 19 into the spherical harmonics basis.
Orthogonality of spherical harmonics makes the evaluation of this integral straightforward:
[Equation]
This, in conjunction with Equation 21allows us to derive the rendering equation using spherical harmonics lighting for Lambertian objects:
[Equation]
So far we have only considered the shading of a speciﬁc point p with surface normal n .
If we consider the rendered image I given a shape V , lighting U , and camera parameters η , the image I is the evaluation of the rendering equation R of each point in V visible through each pixel in the image.
This pixel to point mapping is determined by η .
Therefore, we can write I as
[Equation]
where N ( V ) is the surface normal.
We exploit the notation and use ρ ( V, η ) to represent the texture of V mapped to the image space through η .
C. L IGHTING AND T EXTURE D ERIVATIVES
For our applications we must differentiate Equation 25 with respect to lighting and material parameters.
The derivative with respect to the lighting coefﬁcients U can be obtained by
[Equation]
[Equation]
[Equation]
This is the Jacobian matrix that maps from spherical harmonics coefﬁcients to pixels.
The term ∂F / ∂U l,m can then be computed as
[Equation]
The derivative with respect to texture is deﬁned by
[Equation]
Note that we assume texture variations are piece-wise constant with respect to our triangle mesh discretization.
D D IFFERENTIATING S KYLIGHT P ARAMETERS
To model possible outdoor daylight conditions, we use the analytical Preetham skylight model (Preetham et al., 1999).
This model is calibrated by atmospheric data and parameterized by two intuitive parameters: turbidity τ , which describes the cloudiness of the atmosphere, and two polar angles θ s ∈ [0 , π/ 2] , φ s ∈ [0 , 2 π ] , which are encode the direction of the sun.
Note that θ s , φ s are not the polar angles θ, φ for representing incoming light direction ω in u ( ω ) .
The spherical harmonics representation of the Preetham skylight is presented in (Habel et al., 2008) as
[Equation]
This is derived by ﬁrst performing a non-linear least squares ﬁt to write U l,m as a polynomial of θ s and τ which lets them solve for ˜
U l,m ( θ s , τ ) =
U l,m ( θ s , 0 , τ ) ˜
U l,m ( θ s , τ ) = 13 (cid:88) i = 7 (cid:88)
j = ( p l,m ) i,j θ is τ j , where ( p l,m ) i,j are scalar coefﬁcients, then U l,m ( θ s , φ s , τ ) can be computed by applying a spherical harmonics rotation with φ s using
[Equation]
We refer the reader to (Preetham et al., 1999) for more detail.
For the purposes of this article we just need the above form to compute the derivatives.
D. D ERIVATIVES
The derivatives of the lighting with respect to the skylight parameters ( θ s , φ s , τ ) are
[Equation]
E D ERIVATIVES OF S URFACE N ORMALS
Taking the derivative of the rendered image I with respect to surface normals N is an essential task for computing the derivative of I with respect to the geometry V .
Speciﬁcally, the derivative of the rendering equation Equation 25 with respect to V is
[Equation]
We assume the texture variations are piece-wise constant with respect to our triangle mesh discretization and omit the ﬁrst term ∂ρ/∂V as the magnitude is zero.
Computing ∂N / ∂V is provided in
Section 3.2.
Computing ∂F / ∂N i on face i is
[Equation]
where the ∂Y ml / ∂N i is the derivative of the spherical harmonics with respect to the face normal N i .
To begin this derivation recall the relationship between a unit normal vector n = ( n x , n y , n z ) and its corresponding polar angles θ, φ
[Equation]
we can compute the derivative of spherical harmonics with respect to the normal vector through
[Equation]
Note that the derivative of the associated Legendre polynomials P ml (cos θ ) can be computed by applying the recurrence formula Dunster (2010)
[Equation]
Thus the derivatives of polar angles ( θ, φ ) with respect to surface normals n = [ n x , n y , n z ] are [Equation] In summary
[Equation]
the results of Equation [Equation] Equation 38, Equation
[Equation]
and Equation 40 tell us how to compute ∂Y ml / ∂N i .
Then the derivative of the pixel j with respect to vertex p which belongs to face i can be computed as
[Equation]
F A DVERSARIAL T RAINING I MPLEMENTATION D ETAIL
Our adversarial training is based on the basic idea of injecting adversarial examples into the training set at each step and continuously updating the adversaries according to the current model parameters (Goodfellow et al., 2015; Kurakin et al., 2017).
Our experiments inject 100 adversarial lighting examples to the CIFAR-100 data ( ≈ 0 .
17% of the training set) and keep updating these adversaries at each epoch.
We compute the adversarial lighting examples using the orange models collected from cgtrader.com and turbosquid.com .
We uses ﬁve gray-scale background colors with intensities 0.0, 0.25, 0.5, 0.75, 1.0 to mimic images in the CIFAR-100 which contains many pure color backgrounds.
Our orthographic cameras are placed at polar angle θ = π/ 3 with 10 uniformly sampled azimuthal angles ranging from φ = 0 to 2 π .
Our initial spherical harmonics lighting is the same as
[Figure]
other experiments, using the real-world lighting data provided in (Ramamoorthi & Hanrahan, 2001).
Our stepsize for computing adversaries is 0.05 along the direction of lighting gradients.
We run our adversarial lighting iterations until fooling the network or reaching the maximum 30 iterations to avoid too extreme lighting conditions, such as turning the lights off.
Our random lighting examples are constructed at each epoch by randomly perturb the lighting coefﬁcients ranging from -0.5 to 0.5.
When training the 16-layers WideResNet (Zagoruyko & Komodakis, 2016) with wide-factor 4, we use batch size 128, learning rate 0.125, dropout rate 0.3, and the standard cross entropy loss.
We implement the training using P Y T ORCH (Paszke et al., 2017), with the SGD optimizer and set the
Nesterov momentum 0.9, weight decay 5e-4.
We train the model for 150 epochs and use the one with best accuracy on the validation set.
Figure 16 shows examples of our adversarial lights at different training stages.
In the early stages, the model is not robust to different lighting conditions, thus small lighting perturbations are sufﬁcient to fool the model.
In the late stages, the network becomes more robust to different lightings.
Thus it requires dramatic changes to fool a model or even fail to fool the model within 30 iterations.
G E VALUATE R ENDERING Q UALITY
[Figure]
[Figure]
[Figure]
[Figure]
conﬁdence on rendered images, showing our rendering quality is faithful enough to be conﬁdently recognized by ImageNet models.
We evaluated our rendering quality by whether our rendered images are recognizable by models trained on real photographs.
Although large 3D shape datasets, such as ShapeNet (Chang et al., 2015), are available, they do not have have geometries or textures at the resolutions necessary to create realistic renderings.
We collected 75 high-quality textured 3D shapes from cgtrader.com and turbosquid.com to evaluate our rendering quality.
We augmented the shapes by changing the ﬁeld of view, backgrounds, and viewing directions, then keep the conﬁgurations that were correctly classiﬁed by a pre-trained ResNeton ImageNet.
Speciﬁcally, we place the centroid, calculated as the weighted average of the mesh vertices where the weights are the vertex areas, at the origin and normalize shapes to range -1 to 1; the ﬁeld of view is chosen to be 2 and 3 in the same unit with the normalized shape; background images include plain colors and real photos, which have small inﬂuence on model predictions; viewing directions are chosen to be 60 degree zenith and uniformly sampled 16 views from 0 to 2 π azimuthal angle.
In Figure 17, we show that the histogram of model conﬁdence on the correct labels over 10,000 correctly classiﬁed rendered images from our differentiable renderer.
The conﬁdence is computed using softmax function and the results show that our rendering quality is faithful enough to be recognized by models trained on natural images.