Title: LEARNING TO INFER USER INTERFACE ATTRIBUTES FROM IMAGES

Abstract: We explore a new domain of learning to infer user interface attributes that helps developers automate the process of user interface implementation. Concretely, given an input image created by a designer, we learn to infer its implementation which when rendered, looks visually the same as the input image. To achieve this, we take a black box rendering engine and a set of attributes it supports (e.g., colors, border radius, shadow or text properties), use it to generate a suitable synthetic training dataset, and then train specialized neural models to predict each of the attribute values. To improve pixel-level accuracy, we also use imitation learning to train a neural policy that refines the predicted attribute values by learning to compute the similarity of the original and rendered images in their attribute space, rather than based on the difference of pixel values. We instantiate our approach to the task of inferring Android Button attribute values and achieve 92.5% accuracy on a dataset consisting of real-world Google Play Store applications.

1. INTRODUCTION:

With over 5 million applications in Google Play Store and Apple App Store and over a billion webpages, a significant amount of time can be saved by automating even small parts of their development. To achieve this, several tools have been recently developed that help user interface designers explore and quickly prototype different ideas, including Sketch2Code (Microsoft, 2018) and InkToCode (Corrado et al., 2018) , which generate user interface sketches from hand-drawn images, Swire (Huang et al., 2019) and Rico (Deka et al., 2017) , which allow retrieving designs similar to the one supplied by the user and Rewire (Swearngin et al., 2018) , which transforms images into vector representations consisting of rectangles, circles and lines. At the same time, to help developers implement the design, a number of approaches have been proposed that generate layout code that places the user interface components at the desired position (e.g., when resizing the application). These include both symbolic synthesis approaches such as InferUI (Bielik et al., 2018) , which encodes the problem as a satisfiability query of a first-order logic formula, as well as statistical approaches (Beltramelli, 2018; Chen et al., 2018) , which use encoder-decoder neural networks to process the input image and output the corresponding implementation.

In this work, we explore a new domain of inferring an implementation of an user interface component from an image which when rendered, looks visually the same as the input image. Going from an image to a concrete implementation is a time consuming, yet necessary task, which is often outsourced to a company for a high fee (replia, 2019; psd2android, 2019; psd2mobi, 2019) . Compared to prior work, we focus on the pixel-accurate implementation, rather than on producing sketches or the complementary task of synthesizing layouts that place the components at the desired positions.

Concretely, given a black box rendering engine that defines a set of categorical and numerical attributes of a component, we design a two step process which predicts the attribute values from an input image -(i) first, we train a neural model to predict the most likely initial attribute values, and then (ii) we use imitation learning to iteratively refine the attribute values to achieve pixel-level accuracy. Crucially, all our models are trained using synthetic datasets that are obtained by sampling the black box rendering engine, which makes it easy to train models for other attributes in the future. We instantiate our approach to the task of inferring the implementation of Android Button attributes and show that it generalizes well to a real-world dataset consisting of buttons found in existing Google Play Store applications. In particular, our approach successfully infers the correct attribute values in 94.8% and 92.5% of the cases for the synthetic and the real-world datasets, respectively.

2. RELATED WORK:

As an application, our work is related to a number of recently developed tools in the domain of user interface design and implementation with the goal of making developers more productive, as discussed in Section 1. Here we give overview of the related research from a technical perspective.

Inverting rendering engines to interpret images The most closely related work to ours phrases the task of inferring attributes from images as the more general task of learning to invert the rendering engines used to produce the images. For example, Wu et al. (2017) use reinforcement learning to train a neural pipeline that given an image of a cartoon scene or a Minecraft screenshot, identifies objects and a small number of high level features (e.g., whether the object is oriented left or right). Ganin et al. (2018) also use reinforcement learning, but with an adversarially learned reward signal, to generate a program executed by a graphics engine that draws simple CAD programs or handwritten symbols and digits. Johnson et al. (2018) and Ellis et al. (2018) design a neural architecture that generates a program that when rendered, produces that same 2D or 3D shape as in the input image. While Johnson et al. (2018) train the network using a combination of supervised pretraining and reinforcement learning with a custom reward function (using Chamfer distance to measure similarity of two objects), Ellis et al. (2018) use a two step process that first uses supervised learning to predict a set of objects in the image and then synthesizes a program (e.g., containing loops) that draws them.

In comparison to these prior works, our approach differs in three key aspects. First, the main challenge in prior works is predicting the set of objects contained in the image and how to compose them. Instead, the focus of our work is in predicting a set of object properties after the objects in the image were already identified. Second, instead of using the expensive REINFORCE (Williams, 1992) algorithm (or its variation) to train our models, we use a two step process that first pretrains the network to make an initial prediction and then uses imitation learning to refine it. This is possible because, in our setting, there is a fixed set of attributes known in advance for which we can generate a suitable synthetic dataset used by both of these steps. Finally, because our goal is to learn pixel-accurate attribute values, the refinement loop takes as input both the original image, as well as the rendered image of the current attribute predictions. As a result, we do not require our models to predict pixel-accurate rendering of an attribute value but instead, to only predict whether the attribute values in two images are the same or in which direction they should be adjusted.

Attribute prediction Optical character recognition (Jaderberg et al., 2016; Lyu et al., 2018; Jaderberg et al., 2014; Gupta et al., 2016 ) is a well studied example of predicting an attribute from an image with a large number of real-world applications. Other examples include predicting text fonts (Zhao et al., 2018; Wang et al., 2015; Chen et al., 2014) , predicting eye gaze (Shrivastava et al., 2017) , face pose and lighting (Kulkarni et al., 2015) , chair pose and content (Wu et al., 2018) or 3D object shapes and pose (Kundu et al., 2018) , to name just a few. The attribute prediction network used in our work to predict the initial attribute value is similar to these existing approaches, except that it is applied to a new domain of inferring user interface attributes. As a result, while some of the challenges remain the same (e.g., how to effectively generate synthetic datasets), our main challenge is designing a pipeline, together with a network architecture capable of achieving pixel-level accuracies on a range of diverse attributes.

3. BACKGROUND: USER INTERFACE ATTRIBUTES:

Visual design of user interface components can be specified in many different ways -by defining a program that draws on a canvas, by defining a program that instantiates components at runtime and manipulates their properties, declaratively by defining attribute values in a configuration file (e.g., using CSS), or by using a bitmap image that is rendered in place of the components. In our work, we follow the best practices and consider the setting where the visual design is defined declaratively, thus allowing separating the design from the logic that controls the application behaviour.

Formally, let C denote a component with a set of attributes A. The domain of possible values of each attribute a i ∈ A is denoted as Θ i . As all the attributes are rendered on a physical device, their domains are finite sets containing measurements in pixels or a set of categorical values. For example, the domain for the text color attribute is three RGB channels N 3×[0,255] , the domain for text gravity is {top, left, center, right, bottom} and the domain for border width is N [0,20] . We distinguish two domain types: (i) comparable (e.g., colors, shadows or sizes) for which a valid distance metric d : Θ×Θ → N [0,∞) exists, and (ii) uncomparable (e.g., font types or text gravity) for which the distance between any two attribute values is equal to one. We use Θ ⊆ Θ 1 ×• • •×Θ n to denote the space of all possible attribute configurations, and use the function render : Θ → R 3×h×w to denote an image with width w, height h and three color channels obtained by rendering the attribute configuration y ∈ Θ. Furthermore, we use the notation y ∼ Θ to denote a random sample of attribute values from the space of all valid attribute configurations. Finally, we note that attributes often affect the same parts of the rendered image (e.g., the shadow is overlayed on top of the background) and they are in general not independent of each other (e.g, changing the border width affects the border radius).

4. LEARNING TO INFER USER INTERFACE ATTRIBUTES FROM IMAGES:

We now present our approach for learning to infer user interface component attributes from images.

Problem statement Given an input image I ∈ R 3×h×w , our goal is to find an attribute configuration y ∈ Θ which when rendered, produces an image most visually similar to I: arg min y∈Θ cost(I, render(y))

where cost : ) is a function that computes the visual similarity of a given user interface component in two images. It returns zero if the component looks visually the same in both images or a positive real value denoting the degree to which the attributes are dissimilar.

I × I → R [0,∞

The first challenge that arises from the problem statement above is how to define the cost function. Pixel based metrics, such as mean squared error of pixel differences, are not suitable and instead of producing images with similar attribute values, produce images that have on average similar colors. Training a discriminator also does not work, as all the generated images are produced by rendering a set of attributes and are true images by definition. Finally, the cost can be computed not over the rendered image but by comparing the predicted attributes y with the ground-truth labels. Unfortunately, even if we would spend the effort and annotated a large number of images with their ground-truth attributes, using a manually annotated dataset restricts the space of models that can be used to infer y to only those that do supervised learning. In what follows we address this challenge by showing how to define the cost function over attributes (used for supervise learning) as well as over images (used for reinforcement learning), both by using a synthetically generated dataset.

Our approach To address the task of inferring user interface attributes from images, we propose a two step process that -(i) first selects the most likely initial attribute values arg max y∈Θ p(y | I) by learning a probability distribution of attribute values conditioned on the input image, and then (ii) iteratively refines the attribute values by learning a policy π(∆y (i) | I, render(y (i) )) that represents the probability distribution of how each attribute should be changed, conditioned on both the original image, as well as the rendered image of the attribute configuration y (i) at iteration i. We use the policy π to define the cost between two images as cost(I, I ) := 1-π(∆y = 0 | I, I ). That is, the cost is defined as the probability that the two images are not equal in the attribute space.

We illustrate both steps in Figure 1 with an example that predicts attributes of a Button component.

In Figure 1 (a), the input image is passed to a set of convolutional neural networks, each of which is trained to predict a single attribute value. In our example, the most likely value predicted for the border width is 2dp while the most likely color of the border is #4a4a4a. Then, instead of returning the most likely attribute configuration y, we take advantage of the fact that it can be rendered and compared to the original input image. This give us additional information that is used to refine the predictions as shown in Figure 1 (b) . Here, we use a pair of siamese networks (pretrained on the prediction task) to learn the probability distribution over changes required to make the component attributes in both images the same. In our example, the network predicts that the border color and the text gravity attributes have already the correct values but the border width should be decreased by 2dp and the shadow should be increased by 4dp. Then, due to the large number of different attributes that affect each other, instead of applying all the changes at once, we select and apply a single attribute change. In our example, the ∆y corresponds to adjusting the value of border width by -2dp. Since the change is supposed to correct a mispredicted attribute value, we accept it only if it indeed makes the model more confident that the prediction is correct. Synthetic datasets We instantiate our approach by training it purely using synthetic datasets, while ensuring that it generalizes well to real-world images. This allows us to avoid the expensive task of collecting and annotating real-world datasets and more importantly, makes our approach easily applicable to new domains and attributes. In particular, given a space of possible attribute configurations Θ and a rendering function render, we generate two different datasets D and D ∆ used to train the attribute prediction network and the policy π, respectively. The dataset D = {(render(y (i) ), y (i) ∼ Θ)} N i=1 is constructed by sampling a valid attribute configuration y (i) ∼ Θ and rendering it to produce the input image. To generate D ∆ , we sample two attribute configurations y (i) , y (j) ∼ Θ that are used to render two input images and train the network to predict the difference of their attributes, that is, D ∆ = {( render(y (i) ∼ Θ), render(y (j) ∼ Θ) , ∆(y (i) -y (j) ))} M i,j=1 . For both datasets, to avoid overfitting when training models for attributes with large domain of possible values, we sample only a subset of attributes, while setting the remaining attributes to values from the previous example y (i-1) . As a result, every two consecutive samples are similar to each other, since a subset of their attributes is the same. Further, because the real-world images do not contain components in isolation but together with other components that fill the rest of the screen, we introduce three additional attributes x pos ∈ N, y pos ∈ N and background. We use x pos and y pos to denote the horizontal and vertical position of the component in the image, respectively. This allows the network to learn robust predictions regardless of the component position in the image. We use background to select the background on which the component is rendered. We experimented with three different choices of backgrounds -only while color, random solid color and overlaying the component on top of an existing application, all of which are evaluated in Section 5.

4.1. ATTRIBUTE PREDICTION:

The attribute prediction network architecture is a multilayer convolutional neural network (CNN) followed by a set of fully connected layers. The multilayer convolutional part consists of 6 repetitive sequences of convolutional layers with ReLU activations, followed by batch normalization and a max-pooling layer of size 2 and stride 2. For the convolutional layers we use 3×3 filters of size 32, 32, 64, 64, 128 and 128, respectively. The result of the convolutional part is then flattened and connected to a fully connected layer of size 256 with ReLU activation followed by a final softmax layer (or a single neuron for regression). We note that this is not a fixed architecture and instead, it is adapted to a given attribute by performing an architecture search, as shown in Section 5.

Supporting multiple input sizes:

To support user interface components of different sizes, we select the input image dimension such that it is large enough to contain them. This is necessary as our goal is to infer pixel-accurate attribute values and scaling down or resizing the image to a fixed dimension is not an option, as it leads to severe performance degradation. However, this is problematic, as most of the input images are smaller or cropped in order to remove other components. As a result, before feeding the image to the network we need to increase the dimension of the input without resizing or scaling. To achieve this, we pad the missing pixels with the values of edge pixels, which improves the generalization to real-world images as shown in Section 5.1 and illustrated in Appendix C.

Optimizations To improve the accuracy and reduce the variance of the attribute prediction network, we perform the following two optimizations. First, we compute the most likely attribute value by combining multiple predictions and selecting the most likely among them. This is achieved by generating several perturbations of the input image, each of which shifts the image randomly, horizontally by x ∼ U(-t, t) and vertically by y ∼ U(-t, t), where t ∈ N. This is similar to ensemble models but instead of training multiple models we generate and evaluate multiple inputs.

Second, to improve the accuracy of the color attributes, we perform color clipping by picking the closest color to one of those present in the input image. To reduce the set of all possible colors, we use saliency maps (Simonyan et al., 2013) to select a subset of the pixels most relevant for the prediction. In our experiments we keep only the pixels with the normalized saliency value above 0.8. Then, we clip the predicted color to the closest color from the top five most common colors among the pixels selected by the saliency map. We provide illustration of the color clipping in Appendix D.

4.2. ATTRIBUTE REFINEMENT LOOP:

We now describe how to learn a function π(∆y | I, render(y)) that represents probability distribution of how each attribute should be changed, conditioned on both the original image as well as the rendered image of the current attribute configuration y. We can think of π as a policy, where the actions correspond to changing an attribute value and the state is a tuple of the original and the currently rendered image. We can then apply imitation learning to train the policy π on a synthetic dataset D ∆ = {( render(y (i) ∼ Θ), render(y (j) ∼ Θ) , ∆(y (i) -y (j) ))} M i,j=1 . Because the range of possible values ∆(y (i) -y (j) ) can be large and sparse, we limit the range by clipping it to an interval [-c, c] (where c is a hyperparameter set to c = 5 for all the attributes in our evaluation). To fix a change larger than c, we perform sequence of small changes. For comparable attributes, the delta between two attribute values is defined as their distance ∆(y

(i) k -y (j) k ) := d(y (i) k -y (j) k ).

For uncomparable attributes, the delta is binary and determines whether the value is correct or not.

The model architecture used to represent π consists of two convolutional neural networks with shared weights θ, also called siamese neural networks, each of which computes a latent representation of the input image h x = f θ (I) and h r = f θ (render(y)). The function f θ has the same architecture as the attribute prediction network, except that we replace the fully connected layer with one that has a bigger size and remove the last softmax layer. Then, we combine the latent features h x and h r into a single vector h = [h x ; h r ; h x + h r ; h x -h r ; h x h r ], where denotes element-wise multiplication. Finally, the vector h is passed to a fully connected layer of size 256 with ReLU activations, followed by a final softmax layer. Once the models are trained, we perform the refinement loop as follows:

Select attribute to change. As in general attributes interfere with each other, in each refinement iteration we adjust only a single attribute, which is chosen by sampling from the following distribution:

P [A = a i ] = 1 -π(∆y i = 0 | I, render(y)) |A| k=1 1 -π(∆y k = 0 | I, render(y))

where π(∆y k = 0 | I, render(y)) denotes the probability that the k-th attribute should not be changed, that is, the predicted change is zero. Since we train a separate model for each attribute, the probability that the given attribute should be changed is 1 -π(∆y k = 0 | I, render(y)).

Select attribute's new value. For comparable attributes, we adjust their value by sampling from the probability distribution computed by the policy π, which contains changes in range [-c, c].

For uncomparable attributes another approach has to be chosen, since the delta prediction network computes only whether the attribute is correct and not how to change it. Instead, we select the new value by sampling from the probability distribution computed by the corresponding attribute prediction network.

Accept or reject the change. In a typical setting, we would accept the proposed changes as long as the model predicts that an attribute should be changed. However, in our domain we can render the proposed changes and check whether the result is consistent with the model. Concretely, we accept the change y if it reduces the cost, that is, cost(I, render(y )) < cost(I, render(y)). Note that this optimization is possible only if the change was supposed to fix the attribute value, that is, the change was in the range (-c, c) or the attribute is uncomparable.

5. EVALUATION:

To evaluate the effectiveness of our approach, we apply it to the task of generating Android Button implementations. Concretely, we predict the following 12 attributes -border color, border width, border radius, height, width, padding, shadow, main color, text color, text font type, text gravity and text size. We do not predict the text content for which specialized models already exist (Jaderberg et al., 2016; Lyu et al., 2018; Jaderberg et al., 2014; Gupta et al., 2016) . We provide domains and the visualization of all these attributes in Appendix A. In what follows we first describe our datasets and evaluation metrics, then we present a detailed evaluation of our approach consisting of the attribute prediction network (Section 4.1) and the refinement loop (Section 4.2).

Datasets To train the attribute prediction network we use a synthetic dataset D containing ≈20,000 images and their corresponding attributes as described in Section 4. To train the refinement loop we use a second synthetic dataset D ∆ , also containing ≈20,000 image pairs. During training we perform two iterations of DAgger (Ross et al., 2011) , each of which generates ≈20,000 samples obtained by running the policy on the initial training dataset. To evaluate our models we use two datasets -(i) synthetic D syn generated in the same way as for training, and (ii) real-world D gplay we obtained by manually implementing 110 buttons in existing Google Play Store applications. The illustration of samples and our inferred implementations for both datasets are provided in Appendix F.

Evaluation metrics To remove clutter, we introduce an uniform unit to measure attribute similarity called perceivable difference. We say that two attributes have the same (=) perceivable difference if their values are the same or almost indistinguishable. For example, the text size is perceivably the same, if the distance of the predicted y and the ground-truth y * value is d(y, y * ) ≤ 1, while the border width is perceivably the same only if it is predicted perfectly, i.e., d(y, y * ) = 0. The formal definition of perceivable difference with visualizations of all attributes is provided in Appendix E.

A detailed summary of the variations of our attribute prediction models and their effect on performance is shown in Table 1 . To enable easy comparison, we selected a good performing instantiation of our models, denoted as core, against which all variations in the rows (A)-(E) can be directly compared. Based on our experiments, we then select the best configuration that achieves accuracy 93.6% and 91.4% on the synthetic and the real-world datasets, respectively. All models were trained for 500 epochs, with early-stopping of 15 epochs, using a batch size of 128 and initial learning rate of 0.01. In what follows we provide a short discussion of each of the variations from Table 1 .

Image background (A) We trained our models on synthetic datasets with three different component backgrounds of increasing complexity -white color, random solid color and user interface screenshot. Unsurprisingly, the models trained with white background fail to generalize to real-world datasets and achieve only 56.7% accuracy. Perhaps surprisingly, although the models trained with the screenshot background improve significantly, they also fail to generalize and achieve only 75.6% accuracy. Upon closer inspection, this is because overlaying components over existing images often introduces small visual artefacts around the component. On the other hand, random color backgrounds generalize well to real-world dataset as they have enough variety and no visual artefacts. Affine transformations (B) Since the components can appear in any part of the input image, we use three methods to generate the training datasets -tr 1 places the component randomly at any position with a margin of at least 20 pixels of the image border, tr 2 places the component in the middle of the image with a horizontal offset x ∼ U(-13, 13) and vertical offset y ∼ U (-19, 19) , and center always places the component exactly in the center. We can see that using either tr 1 or tr 2 leads to significantly more robust model and increases the real-world accuracy by ≈ 8%.

Input image size & padding (C) As our goal is to perform pixel-accurate predictions, we do not scale down or resize the input images. However, since large images include additional noise (e.g., parts of the application unrelated to the predicted component), we measure how robust our model is to such noise by training models for three different input sizes -135×310, 150×330 and 180×350. While the accuracy on the synthetic dataset is not affected, the real-world accuracy shows a slight decrease for larger sizes that contain more noise. However, note that the decrease is so small because of our padding technique, which extends the component to a larger size by padding the missing pixels with edge pixel values. When using no padding, the accuracy of the real-world dataset drops to 72% and when padding with a white color the accuracy drops even further to 71% (not shown in Table 1 ).

Color clipping (D):

We experimented with different color clipping techniques -saliency top5 that considers the top 5 colors in the saliency map of a given attribute, image top5 that considers the top 5 colors in the image, and image all that considers all the colors in the image. The color clipping using saliency maps performs the best and leads to more than 3% and 16% improvements over other types of clipping or using no clipping, respectively. While the other types of color clipping also perform reasonably well, they typically fail for images that include many colors, where the saliency map helps focusing only on the colors relevant to the prediction. We note that the color clipping works best for components with solid colors and the improvement for gradient colors is limited.

Network architecture (E) We adapt the architecture presented in Section 4.1 for each attribute, by performing a small scale architecture search. Concretely, we choose between using classification (C) or regression (R), the kernel sizes, the number of output channels, whether we use pooling layer and whether we use additional fully connected layer before the softmax layer. Although the results in Table 1 are not directly comparable, as they provide only the aggregate accuracy over all attributes (additionally for regression experiments we consider only numerical attributes), they do show that such architectural choices have a significant impact on the network's performance. 

5.2. ATTRIBUTE REFINEMENT:

To evaluate our attribute refinement loop, we perform two experiments that refine the attribute values: (i) starting from random initial values, and (ii) starting from values computed by the attribute prediction network. For both experiments, we show that the refinement loop improves the accuracy of the predicted attribute values, as well as significantly outperforms other similarity metrics used as a baseline. We trained all our models for 500 epochs, with early-stopping of 15 epochs, using a batch size of 64, learning rate of 0.01 and gradient clipping of 3, which is necessary to make the training stable. Further, we initialize the siamese networks with the pretrained weights of the best attribute prediction network, which leads to both improved accuracy of 4%, as well as faster convergence when compared to training from scratch. Finally, we introduce a hyperparameter that controls which attributes are refined. This is useful as it allows the refinement loop to improve the overall accuracy even if only a subset of the attributes values can be refined successfully.

Attribute refinement improves accuracy:

The top row in Table 2 (right) shows the accuracy of our refinement loop when applied starting from values predicted by the best attribute prediction network. Based on our hyperparameters, we refined the following six attributes -text size, text gravity, text font, shadow, width and height. The refined attributes are additionally set to random initial values for the experiment in Table 2 (left). The overall improvement for both synthetic and real-world dataset is ≈ 1.1% when starting from the values predicted by the attribute prediction network. When starting from random values the refinement loop can still recover predictions of almost the same quality, although with ≈ 12× more refinement iterations. The reason why the improvement is not higher is mainly because ≈ 5% of the errors are performed when predicting the text color and the text padding, for which both the attribute prediction networks and the refinement loop work poorly. This suggest that a better network architecture is needed to improve the accuracy of these attributes.

Effectiveness of our learned similarity metric:

To evaluate the quality of our learned cost function, which computes image similarity in the attribute space, we use the following similarity metrics as a baseline -pairwise pixel difference, structural similarity (Wang et al., 2004) , and Wasserstein distance. As the baseline metrics depend heavily on the fact that the input components are aligned in the two images (e.g., when computing pairwise pixel difference), for a fair comparison we add a manual preprocessing step that centers the components in the input image. The results from Table 2 show that all of these metrics are significantly worse compared to our learned cost function. Even though they provide some improvement when starting from random attributes, the improvement is limited and all of them result in accuracy decrease when used starting from good attributes.

6. CONCLUSION:

We present an approach for learning to infer user interface attributes from images. We instantiate it to the task of learning the implementation of the Android Button component and achieve 92.5% accuracy on a dataset consisting of Google Play Store applications. We show that this can be achieved by training purely using suitable datasets generated synthetically. This result indicates that our method is a promising step towards automating the process of user interface implementation. Per-attribute accuracy We provide per-attribute accuracy of the refinement loop in Table 4 . As described in Section 5.2, we refined the following six attributes -text size, text gravity, text font, shadow, width and height. When considering only these six attributes, the refinement loop improves the accuracy by 2.3%, from 93.5% to 95.8%.

The remaining errors are mainly due to text color, padding and text font attributes. The padding achieves accuracy 81% and is difficult to learn as it often interferes with the text alignment and the same position of the text can be achieved with different attribute values. The text font attribute accuracy is 85% which is slightly improved by using the refinement loop but could be improved further.

The worst attribute overall is the text color that achieves 69% accuracy. Upon closer inspection, the predictions of the text color are challenging due to the fact that the text is typically narrow and when rendered, it does not have a solid background. Instead, the color is an interpolation of the text color and background color as computed by the anti-aliasing in the rendering engine.

Attribute dependencies All the results presented in Table 4 , as well as in our evaluation, are computed starting from the initial set of attribute values that typically contains mistakes. Since different attributes can (and do) dependent on each other, mispredicting one attribute can negatively affect the predictions of other attributes. As a concrete example, refining text font while assuming that all the other attribute values are correct leads to an improvement of 12% which is significantly higher than ≈ 2% from Table 4 .

To partially address this issue, the refinement loop uses a heuristic which ensures that all attributes have different values when used as input to the refinement loop. Concretely, if two attributes would have the same value, one of the values is temporarily changed to a random valid value and returned to the original value at the end of each refinement iteration.

C IMAGE PADDING:

To improve robustness of our models on real-world images we experimented with three techniques of image padding shown in Figure 2 . In (a) the image is padded with the edge values, in (b) the image is padded with a constant solid color and in (c) the image is simply extended to the required input size. 

:



Figures and Tables:

Figure 1: (a) Illustration of the attribute prediction network which takes an input an image with a component (a Button) and predicts all the component attribute values. (b) Refinement loop which renders the attribute values obtained from (a) and iteratively refines them to match the input image.

Variations of the attribute prediction network and their effect on the model accuracy.

Table content: <table><tr><td/><td colspan="3">Network Architecture</td><td colspan="3">Dataset &amp; Input Preprocessing</td><td colspan="2">Accuracy</td></tr><tr><td/><td>arch</td><td>lr rd</td><td>color clip</td><td>inputsize</td><td>tr</td><td>background</td><td>D syn =</td><td>D gplay =</td></tr><tr><td colspan="2">core C0,R0</td><td>-</td><td colspan="2">saliencytop5 150×330</td><td>tr2</td><td>rand</td><td>92.7%</td><td>90.1%</td></tr><tr><td>(A)</td><td/><td/><td/><td/><td/><td>white screenshot</td><td>88.9% 88.6%</td><td>56.7% 75.6%</td></tr><tr><td>(B)</td><td/><td/><td/><td/><td>center tr1</td><td/><td>89.4% 92.3%</td><td>82.4% 90.3%</td></tr><tr><td>(C)</td><td/><td/><td/><td>135×310 180×350</td><td/><td/><td>92.5% 92.5%</td><td>91.2% 88.7%</td></tr><tr><td/><td/><td/><td>imagetop5</td><td/><td/><td/><td>89.2%</td><td>85.9%</td></tr><tr><td>(D)</td><td/><td/><td>image all</td><td/><td/><td/><td>87.1%</td><td>83.0%</td></tr><tr><td/><td/><td/><td>none</td><td/><td/><td/><td>74.1%</td><td>72.0%</td></tr><tr><td/><td>C3</td><td/><td/><td/><td/><td/><td>83.2%</td><td>83.4%</td></tr><tr><td/><td>C6</td><td/><td/><td/><td/><td/><td>88.6%</td><td>88.2%</td></tr><tr><td>(E)</td><td>R1</td><td/><td/><td/><td/><td/><td>62.6%</td><td>64.3%</td></tr><tr><td/><td>R2</td><td/><td/><td/><td/><td/><td>67.7%</td><td>65.3%</td></tr><tr><td/><td>• • •</td><td/><td/><td/><td/><td/><td>• • •</td><td>• • •</td></tr><tr><td colspan="2">best C6, R2</td><td>0.1</td><td colspan="2">saliencytop5 135×310</td><td>tr2</td><td>rand</td><td colspan="2">93.6% 91.4%</td></tr><tr><td colspan="3">arch model architecture</td><td colspan="2">tr input transformation</td><td colspan="4">lr rd reduced learning rate on plateau</td></tr></table>

Accuracy of the attribute refinement loop instantiated with different similarity metrics. The accuracy shown in brackets denotes the improvement compared to the initial attribute values.

Table content: <table><tr><td/><td colspan="2">Random Attribute Initialization</td><td colspan="2">Best Prediction Initialization</td></tr><tr><td>Metric</td><td>D syn =</td><td>D gplay =</td><td>D syn =</td><td>D gplay =</td></tr><tr><td>Our Work</td><td/><td/><td/><td/></tr><tr><td colspan="5">Learned Dst. 94.4% (+57.3%) 91.3% (+53.3%) 94.8% (+1.2%) 92.5% (+1.1%)</td></tr><tr><td>Baselines</td><td/><td/><td/><td/></tr><tr><td colspan="5">Pixel Sim. 59.6% (+22.5%) 65.0% (+27.0%) 93.6% ( 0.0%) 91.1% (-0.3%)</td></tr><tr><td colspan="5">Structural Sim. 81.1% (+44.0%) 71.9% (+33.9%) 93.4% (-0.2%) 89.3% (-2.1%)</td></tr><tr><td colspan="5">Wasserstein Dst. 63.4% (+26.3%) 61.8% (+23.8%) 91.8% (-1.8%) 89.6% (-1.8%)</td></tr></table>

Per attribute accuracy before and after applying the refinement loop when starting from the best predictions of the attribute prediction network for the real-world D gplay

Table content: <table><tr><td/><td/><td>=</td><td>dataset.</td></tr><tr><td/><td colspan="2">Accuracy on D gplay =</td></tr><tr><td colspan="4">Attribute Before Refinement After Refinement</td></tr><tr><td>Refined Attributes</td><td/><td/></tr><tr><td>Text Size</td><td>96.2%</td><td>99.1%</td></tr><tr><td>Text Gravity</td><td>94.4%</td><td>96.3%</td></tr><tr><td>Text Font Family</td><td>84.0%</td><td>85.8%</td></tr><tr><td>Shadow</td><td>93.7%</td><td>97.3%</td></tr><tr><td>Width</td><td>99.1%</td><td>99.1%</td></tr><tr><td>Height</td><td>93.6%</td><td>97.3%</td></tr><tr><td>Non-Refined Attributes</td><td/><td/></tr><tr><td>Main Color</td><td>99.1%</td><td>99.1%</td></tr><tr><td>Text Color</td><td>69.2%</td><td>69.2%</td></tr><tr><td>Border Color</td><td>92.6%</td><td>92.6%</td></tr><tr><td/><td>81.1%</td><td>81.1%</td></tr><tr><td>Border Width</td><td>94.5%</td><td>94.5%</td></tr><tr><td>Border Radius</td><td>99.1%</td><td>99.1%</td></tr><tr><td>All Attributes</td><td>91.4%</td><td>92.5%</td></tr></table>

Visualization of the attribute predictions for the synthetic buttons in the D syn dataset.

Table content: <table><tr><td>Input</td><td>Preprocessed</td><td>Predicted</td><td>Refined</td></tr><tr><td/><td colspan="2">Good predictions</td><td/></tr></table>

Peer review (iclr2020):
The paper proposes an approach to infer the attribute values of an input image representing a user interface. The model first infers the most likely initial attribute values, and iteratively refine them to improve the similarity between the input image and the interface generated from the newly inferred attributes. The model is trained on synthetic datasets generated by a black box rendering engine, and generalizes well to real-world datasets. To address the issues of pixel based metrics and mean squared error, the authors instead uses the probability that two images are equal in the attribute space to define the cost between these two images. Although I*m not familiar with the problem addressed by the paper, I found the paper very clear and well written. Overall, the method is sensible and elegant, and could easily be applied to other domains. My only disappointment is maybe the fact that only the Android Button was considered, and it is not clear how the model would perform with other and more sophisticated Android components. A few questions for the authors: - How many steps do you perform in the refinement loop? This is an important information, but I couldn*t find it in the paper. Typically, I was surprised to see in the first row of Table 2 that the model with a random attribute initialization can reach such a high performance. But I imagine that you need many more iterations to converge if you start from random attributes than from the best prediction initialization? - Also, what is the stopping criterion? Do you decide to stop when none of the proposed attribute changes improve the pixel-level accuracy?