{'fraction_non_alphanumeric': 0.029345536427689403, 'fraction_numerical': 0.009333914433064574, 'mean_word_length': 4.9291559000861325, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Sketch2Model: View-Aware 3D Modeling from Single Free-Hand Sketches

We investigate the problem of generating 3D meshes from single free-hand sketches, aiming at fast 3D modeling for novice users. It can be regarded as a single-view reconstruction problem, but with unique challenges, brought by the variation and conciseness of sketches. Ambiguities in poorly-drawn sketches could make it hard to determine how the sketched object is posed. In this paper, we address the importance of viewpoint specification for overcoming such ambiguities, and propose a novel view-aware generation approach. By explicitly conditioning the generation process on a given viewpoint, our method can generate plausible shapes automatically with predicted viewpoints, or with specified viewpoints to help users better express their intentions. Extensive evaluations on various datasets demonstrate the effectiveness of our view-aware design in solving sketch ambiguities and improving reconstruction quality.


Introduction
Sketch-based 3D modeling has been studied for decades, intended to free people from the tedious and timeconsuming modeling process. With the widespread usage of portable touch screens and emergence of VR/AR technologies, the need of 3D content creation for novice users is increasing [37]. However, existing sketch-based 3D modeling techniques either require precise line-drawings from multiple views or simply retrieve from existing models, both failing to provide easy-to-use interface and customizability at the same time. We aim at fast and intuitive 3D modeling for people without professional drawing skills, and investigate the problem of mesh generation from a single freehand sketch. It is in general a single-view reconstruction problem, but has its unique challenges due to the characteristics of free-hand sketches. Unlike real images, free-hand sketches can be poorly-drawn with drastic simplifications and geometric distortions, and lack important visual cues like textures or shading. This makes it difficult, sometimes *   even impossible, for algorithms to understand sketches correctly. One tricky scenario results from the "camera-shape ambiguity" [21], as shown in Fig. 1. Subjectivity of sketch creation could lead to different explanation of the same sketch, like which side being the front of the car (left). Furthermore, a recent study shows that existing single-view reconstruction approaches mainly rely on the recognition of input images, rather than actually performing geometry reconstruction. Therefore, they can be hard to generalize to unseen data and perform worse on hand-drawn sketches, which are created with barely any constraint, showing more diverse in appearance.
Recall how human cognitive system works for the task of 3D reconstruction. Human relies on visual memory and visual rules to recover 3D geometry from imagery [28]. Visual memory contains priors gained from daily life, like what an object of a certain class might look like, while visual rules act like a regularizer, requiring that an object should match what it looks like from a certain viewpoint. When seeing a sketch, we search our visual memory and try to find a solution that also obeys visual rules. However, this search process may not go well when (1) we could not figure out how the sketched object is posed, thus finding difficulty applying visual rules; (2) multiple solutions exist due to the ambiguity of the sketch. Both problems result from the lack of details in sketches, and we address that viewpoint specification can be essential to the above problems. If we are told which viewpoint the object is sketched from, search space can be easily reduced, which lowers search difficulty and may eliminate ambiguities. Based on the above observations, we think that explicitly specified viewpoints can directly guide the reconstruction algorithm to find the correct shape described by the user. Moreover, viewpoints offer extra information for the understanding of hand-drawn sketches, which can improve generalization ability for out-of-distribution data. To utilize view information, we propose a view-aware sketch-based 3D reconstruction method, which explicitly conditions the generation process on a given viewpoint. We extend the traditional encoder-decoder architecture used in some recent works [20,22]. In the encoder, image features are decomposed to a latent view code and a latent shape code. The latent view code is used to predict viewpoint for the input sketch, and the latent shape code is combined with a latent view code to generate the output shape. Just like other disentangling problems, the network would take a short path and fail to decompose certain properties if no other constraints are made. To ensure that only view information is contained in the latent view space, a view auto-encoder is learned to transform viewpoints to latent view space and vice versa. To force the decoder network to depend on the given view code, we propose a simple but effective random view reinforced training strategy, where random views along with ground truth views are fed to the decoder, forcing the network to learn how to match the input sketch from different viewpoints. We use synthetic sketch data for training, due to the lack of paired sketch-3D dataset, and apply domain adaptation technique to bridge the gap between synthetic sketches and real sketches. In the inference stage, our method can generate 3D mesh based on a single freehand sketch automatically using the predicted viewpoint, or semi-automatically using a user-specified viewpoint.
Extensive experiments are conducted to demonstrate the effectiveness of our design. We first perform case studies to show characteristics of our view-aware architecture, and how specified views can be used to eliminate ambiguities. To evaluate how our method performs on freehand sketches and inspire further research, we collect a ShapeNet-Sketch dataset based on the ShapeNet dataset, which contains 1,300 sketch-shape pairs. Results on various datasets show that our method can generate higher-quality shapes and better convey user's intentions comparing to alternative baselines, which demonstrates the advantages of introducing viewpoint specification. Ablation studies are performed to show the necessity of serveral parts of our method.
To summarize, our contributions are as follows: • We are the first to investigate the problem of generating 3D mesh from a single free-hand sketch, which provides a fast and easy-to-use 3D content creation solution for novice users.
• We address the importance of viewpoint specifica-tion in the sketch-based reconstruction task, and design a view-aware generation architecture to condition the generation process explicitly on viewpoints. Quantitative and qualitative evaluations on various datasets demonstrate our method can generate promising shapes that well convey user's intentions and generalize better on free-hand sketches.

Single-View 3D Reconstruction
Recovering 3D geometry from a single image is an illposed problem. Early approaches utilize perceptual cues, such as shading [14] and texture [39], to get a clue about surface orientations. With the emergence of online 3D model collections and large-scale 3D model datasets [1], data-driven approaches are developed to infer categoryspecific shapes directly from image features [3,4,8,10,16,24,29,38], in the form of voxel [4,10], point cloud [8], triangle mesh [16,29,38], and implicit function [3,24]. Recently, differentiable rendering techniques [20,22,27,33,40] are proposed to relax the need for ground truth 3D models in training, which enables supervision with solely 2D images. Our method is based on the single-view reconstruction process of [22]. We extend the original approach by disentangling image features into a latent shape space and a latent view space, and achieve view-aware generation by applying special designed training strategy. Note that no 3D information is needed in our training process.

Sketch-Based 3D Modeling
3D modeling based on sketches, has been studied for a long time. Olsen et al. [28] categorized traditional sketchbased modeling techniques into evocative [2,9,34] and constructive [17,19,25,26] ones. Evocative approaches create models from template primitives or retrieve objects from model collections, while constructive ones directly map the input strokes to a 3D model, providing free-form modeling abilities. Either of the two paradigms has its shortcomings: evocative methods are confined to generate certain shapes or primitives, and the lack of prior knowledge in constructive methods often requires large efforts to get the desired shape. Deng et al. [6] proposed to extract free-form shapes from single images in an interactive way, inspired by the lofting technique in CAD systems. By utilizing deep learning techniques, several works [5,11,12,15,23,31,32,35,36] have achieved to gain priors from existing 3D models, while being able to leverage user inputs. However, very few of them focuses on reconstruction from free-hand sketches [35,36], instead of precise line drawings. Wang et al. [36] proposed a retrieval-based apporach to generate 3D voxels from freehand sketches. The work most similar to ours is that of Wang et al. [35], where point cloud is generated according Figure 2. Network architecture of (a) baseline methods [20,22] and (b) our method. Purple and blue blocks denote inputs and trainable parameters respectively. R is the differentiable rendering module. Our method extends the encoder-decoder model by decomposing image features into shape space S and view space V. We train a view encoder Ev and a view decoder Dv to ensure only view-related information is contained in view space, and force the decoder D to use view information by training with an additional random view Vr. Shape quality is preserved by a shape discriminator Ds.
to a single free-hand sketch, and rotated to a canonical view by predicted viewpoint to match the ground truth. Different from their work, we regard viewpoint as an additional input to the generation process, and rely on them to interpret sketches. The authors proposed sketch standardization steps to synthesize sketches from edge maps, while we try to bridge the domain gap in feature space.

Method
To generate 3D mesh from a single free-hand sketch, we first propose a baseline approach, that works the same way as single-view reconstruction for real images. Then we extend the baseline architecture by decomposing image features into a latent view space and a latent shape space, and condition the generation process on the choice of viewpoint.

View-Aware Generation
Given an input sketch I, we wish to generate a 3D mesh M , under the constraint that the sketch represents the object seen from a specific viewpoint V .
As a basis of our method, the single-view mesh reconstruction framework proposed in [20,22] is built upon a simple encoder-decoder architecture, shown in Fig.2(a). The encoder E is a convolutional neural network, which extracts image features from input image I and outputs a compact feature vector z = E(I). The decoder D calculates from z the vertex offsets of a template mesh, and deforms it to get the output mesh M = D(z). By approximating gradients of the rasterization process in the differentiable rendering module R, the network can be end-to-end trained by comparing rendered silhouettes and ground truth ones, without the need for ground truth 3D shapes.
To explicitly condition the generation process on viewpoints, we design a novel view-aware architecture, shown in Fig.2(b). In our encoder, the image feature vector z is further mapped to a latent view space V and a latent shape space S. The decoder takes a latent view code z v and a shape code z s , and get a deformed mesh M . Denote the image space and mesh space to be I and M, our encoder and decoder can be expressed as: We also introduce a view auto-encoder, denoted as E v and D v , to encode an arbitrary viewpoint to the latent view space and vice versa: such that only view-related information are held in the latent view space. We predict the viewpoint for the input sketch from the latent view code z v given by the encoder: Intuitive as it seems, it is not straightforward to ensure that shapes are generated by taking the latent view code z v into consideration. A common degradation could happen, that M is directly generated from z s , totally ignoring z v , if trained without any other constraint. We propose a random view reinforced training strategy to solve this problem. In addition to the ground truth viewpoint V , we feed a random viewpoint V r to the decoder network and generate a mesh M r . By forcing consistency between the projected silhouette of M r under V r and the input silhouette, the network will learn to match the input sketch under any given viewpoint. However, interpreting input sketches with an arbitrary viewpoint is not feasible. This will cause the network to generate distorted shapes, which only satisfy the silhouette constraint, but are not meaningful objects. To avoid distortions as much as possible, we introduce a shape discriminator D s , which is trained jointly with the encoder and decoder in an adversarial manner. The random view reinforced training and the shape discriminator work as a balance between view-awareness and shape quality. The network may not produce shapes strictly matching the input silhouette under V r , but still be aware of the impacts of viewpoints to the generation results.

Training and Inference
Domain adaptation. Due to the lack of paired sketchshape data, we use synthetic sketches of ShapeNet objects as training data, which are precise line-drawings of objects, and have different appearances from free-hand sketches. Performance drop occurs when the model trained on synthetic sketches is tested on hand-drawn ones. To bridge the gap between them, previous works mostly try to mimic hand-drawn sketches when generating synthetic data by hand-crafted rules or image translation techniques. We first propose to bridge this gap in feature space instead of image space, inspired by existing domain adaptation approaches. Our intention is to make image features of synthetic and hand-drawn sketches indistinguishable. To do this, we learn a domain discriminator to separate features coming from the two domains, and train it with the encoder adversarially.
Optimization objectives. Our loss functions consist of five parts: silhouette loss L s between projected and ground truth silhouettes, geometry regularizations L r for generated shapes, view prediction loss L v between predicted and ground truth viewpoints, classification loss L sd and L dd for shape discriminator and domain discriminator.
For input and rasterized silhouettes, we adopt IoU loss as in [20,22]. Let S 1 and S 2 be two binary silhouettes, IoU loss L iou is defined as: Denote P (·, ·) as the differentiable rasterization function, which takes a mesh M and a viewpoint V , and output the rasterized silhouette of M under V . Our silhouette loss is expressed as: where V and S is the ground truth viewpoint and silhouette respectively. Note that we use the latent code for ground truth viewpoint E v (V ) in training, instead of the predicted z v , because we observe negative impacts for training by utilizing inaccurate predictions. Most existing works compute IoU loss on low resolution silhouettes like 64×64, which ignores fine structures. Considering computational efficiency, we adopt a multi-scale progressive training strategy, leveraging silhouettes of different resolutions. Let L i s be the silhouette loss on the i-th level of the silhouette pyramid, N be the number of levels, we adopt a progressive silhouette loss L sp : In early stage of training, only low resolution silhouettes are used for loss calculation. Higher resolution ones are used for shape refinement as the training progresses.
To improve visual quality of generated meshes, we apply flatten loss and and laplacian loss as regularizations for mesh structures, as in [20,22,38]. We denote the shape regularization loss as L r .
For the representation of viewpoint, we assume fixed distance to camera and represent viewpoints as Euler angles. We adopt L2 loss for predicted and ground truth views: To train the view encoder, we adopt a view reconstruction loss L vr between original and reconstructed views: To ease the training process, we apply a gradient reversal layer before shape discriminator and domain discriminator. The gradient reversal layer reverses the sign of the gradient that passes it, which achieves adversarial training in a single pass. For the shape discriminator, we expect it to output 1 for M and 0 for M r , and for the domain discriminator, 1 for synthetic sketches and 0 for hand-drawn sketches, which lead to the following losses: where S s and S h denote synthetic sketches and hand-drawn sketches respectively. Our overall loss function is the weighted sum of the above objectives:  . Ablation studies for random view reinforced training strategy (RVR) and shape discriminator (SD). Without applying random view reinforced training, the network would fail to generate meaningful objects under given viewpoints (first row). Without shape discriminator, the output shape may not resemble real objects (second row). We successfully achieve view-aware generation by adopting both techniques (third row).
During inference, shapes can be generated from an input free-hand sketch automatically or semi-automatically, depending on the choice of latent view code z v . Users can use the predicted viewpointV to get the output mesĥ M = D(z s , E v (V )), or provide a specified viewpointṼ to getM = D(z s , E v (Ṽ )).

Experiments
We first perform case studies to show the effectiveness of our view-aware design and how specified viewpoints can be used to solve the ambiguity problem. Quantitative and qualitative evaluations on both synthetic and handdrawn sketches show that our method generates shapes better matching the given sketch comparing to alternative baselines.

Datasets
ShapeNet-Synthetic. We use synthetic sketches to train our model. We create the synthetic dataset using rendered images provided by Kar et al. [18]. It contains object renderings of 13 categories from ShapeNet [1]. Images from 20 different views of each object are rendered in 224x224 resolution. We extract the edge map of each rendered image using canny edge detector, which does not require 3D ground truth comparing to extracting contours from 3D shapes. We directly use the edge maps as synthetic sketches, and use this dataset for training and evaluation, under the same train/test split as in [22].

ShapeNet-Sketch.
To quantitatively evaluate our method on free-hand sketches and benefit further research, we collect a paired dataset of 3D shape and hand-drawn sketches, which we call ShapeNet-Sketch. We randomly choose 100 rendered images for each of the 13 ShapeNet categories from Kar's dataset [18], and ask people of different drawing skills to sketch the object based on the rendered image   Table 2. Quantitative ablation studies for random view reinforced training (RVR), shape discriminator (SD) and multi-scale progressive training (MS). Numbers outside and inside parenthesis are mean voxel IoU scores on ShapeNet-Synthetic test set for ground truth and predicted viewpoints respectively. By adopting all three strategies, we can achieve the highest IoU scores in most cases with or without groud truth views.
on a touch pad. Our ShapeNet-Sketch dataset contains in total 1,300 free-hand sketches and their corresponding ground truth 3D models. We use this dataset for evaluations only.
Existing sketch datasets. We use some existing sketch datasets designed for other sketch-related tasks to qualitatively evaluate our method, and demonstrate the advantages of our method in dealing with poorly-drawn sketches. In detail, we use sketches of 7 categories that overlap with the ShapeNet classes, from Sketchy database [30] and Tu-Berlin dataset [7].

Implementation Details
We use ResNet-18 [13] as our image feature extractor and SoftRas [22] for differentiable rendering of generated meshes. Detailed network architecture is described in the supplementary material. We assume a canonical view for objects in each class and use elevation and azimuth angles to represent viewpoints. The canonical view is 0 in elevation and 0 in azimuth, and the distance to camera is fixed. We use Adam optimizer with learning rate 1e − 4, and train a separate model for each class. Hyper-parameters are set to λ r = λ sd = λ dd = 0.1, λ v = λ vr = 10.

Effectiveness of View-Aware Design
As is illustrated in Sec.3.1, our generation result relies on both input sketch image and a viewpoint. With different viewpoints, the network is expected to generate different shapes to match the input sketch. Examples in Fig.3 show how the generated shape changes with the change of elevation and azimuth angle. For each example, the second row shows how well the generated model matches the input sketch from the given view. In the vehicle example (top right), the choice of azimuth angle, which represents which side the vehicle is looking from, influences the output model to be a van (left, -90 in azimuth) or a truck (right, 90 in azimuth). For the badly-drawn table (bottom left), the height of the table and the thickness of the table top are determined by the elevation angle. Fig.4 shows the importance of the proposed random view reinforced training strategy and shape discriminator to the generation results. If only normal views are used in training, the network fails to learn the dependency on input viewpoint, and could get confused on given views. Without shape discriminator, the output mesh may get distorted and not resemble a real object. Under the influence of both, we can get view-aware property with promising shape quality.   Table 3. Mean voxel IoU on ShapeNet-Sketch dataset. We apply domain adaptation (DA) on 7 of the classes, which have considerable amount of sketches in the Sketchy database [30] and Tu-Berlin dataset [7]. Our method with domain adaptation achieves the highest IoU score, and shows significant improvement on airplane, car and sofa.

Comparisons and Evaluations
We compare our method with the traditional encoderdecoder architecture in Fig. 2(a) and a retrieval-based approach. For the former, we adopt SoftRas [22] as the differentiable rendering module, and denote it as "SoftRas" for simplicity. We also train a separate model for each category for fair comparison. Retrieval is a widely-adopted apporach to get 3D shape from a single sketch input. Instead of using traditional image features, we use features from a pre-trained sketch classification network, which is demonstrated to be more powerful than hand-crafted features in many sketch-related works [30,41]. For each input sketch, we find its nearest neighbor in training edge maps and take the corresponding 3D shape as the retrieval result. For quantitative comparisons, we use voxel IoU score, as in [20,22].

Comparisons on ShapeNet-Synthetic Dataset
Comparison results on ShapeNet-Synthetic test set is shown in Table.1. We evaluate our method using both the predicted viewpoint (pred) and the ground truth viewpoint (gt), which serves as the lower and upper bound for our view-aware design. Our method outperforms the two baselines on most of the categories, especially when the ground truth view is given. This implies that view information plays an essential role in reconstruction, and generation quality should be improved by specifying correct views. We perform ablation studies on several designs of our approach in Table.2. RVR, SD, MS denotes for random view reinforced training, shape discriminator and multi-scale progressive training respectively. Without using any of the three techniques, the method performs well on predicted viewpoints, but fails on given ground truth views, since it is not trained to fit arbitrary viewpoints. Adopting random view reinforced training without shape discriminator will lead to poor results on predicted views, because the shapes may get distorted given inaccurate view predictions. By applying multi-scale progressive training, the performance can be further improved.

Comparisons on ShapeNet-Sketch Dataset
We show voxel IoU score on our collected ShapeNet-Sketch dataset in Table.3, and further demonstrate the effectiveness of our domain discriminator. We observe significant performance improvement after applying domain adaptation in some of the classes (airplane, car, sofa), indicating that large domain gaps exist. For comparison, we also tried to create fake sketches by utilizing CycleGAN and use them as training data, but no significant improvement is observed. Some reconstruction results using predicted views on ShapeNet-Sketch dataset is shown in Fig.5. Fig.7 Table 4. Comparison of 2D silhouette IoU score on ShapeNet-Sketch dataset. The generated shapes are projected to the ground truth view and we calculate the IoU score between the projected silhouette and the ground truth silhouette. Our method achieves significantly higher results than baseline methods. It demonstrates that our method can generate shapes better match the input sketches.

Input
Retrieval SoftRas Ours (pred) Input Retrieval SoftRas Ours (pred) Figure 6. Qualitative comparisons with two baseline methods on sketches from the Sketchy database [30] and Tu-Berlin dataset [7]. The reconstructed mesh is projected on our predict viewpoint, to compare with the given sketch. Our method generates meshes that align better with the given sketch, and performs well on rare shapes (bottom right) and poorly-drawn sketches (bottom left). of the airplane (left). We also compare projected silhouettes of generated meshes with ground truth silhouettes, and show the results in Table.4. It shows our model is more powerful at matching input sketches, which provides evidence for the effectiveness of our view-aware design.

Evaluations on Free-Hand Sketches
Finally, we qualitatively evaluate our method on handdrawn sketches from the Sketchy database [30] and Tu-Berlin dataset [7]. Some representative results are shown in Fig.6. It can be seen that our method can better align the boundary of the generated mesh with the input sketch, benefit from the view-aware design. Our method balance well between sketch alignment and shape realism when handling out-of-distribution shapes, like the airplane on the top left and the table on the bottom left. Results here are all generated automatically using predicted viewpoints, and users should be able to control the output shape by specifying new viewpoints, like is illustrated in Sec.4.3. This makes our method more flexible and practical than existing viewagnostic methods.

Conclusion
We investigate the problem of generating 3D mesh from a single free-hand sketch, aiming for fast content generation for novice users. A view-aware architecture is proposed, to condition the generation process explicitly on viewpoints, which improves generation quality and brings controllability to the output shape. Our method can generate promising shapes on several free-hand sketch datasets, well balancing user intentions and shape qualities, especially for poorlydrawn sketches. We hope the view-aware paradigm can inspire further researches in single view 3D reconstruction and sketch-related areas.