From Program to Sketch: Modeling Non-Deterministic Observations in Code Generation

Table of Links
Appendix
C Sketch Simulation
As mentioned in the main text, we implement the CSG2D-Sketch environment, which is the same as CSG2D with a hand-drawn sketch observation model. We do this to primarily show how this sort of a generative model can possibly be applied to a real-world task, and that observations do not need to
\
\
be deterministic. Our sketch algorithm can be found in our codebase, and is based off the approach described in Wood et al. [39].
\
Our compiler uses Iceberg [16] and Google’s 2D Skia library to perform boolean operations on primitive paths. The resulting path consists of line and cubic bézier commands. We post-process these commands to generate sketches. For each command, we first add Gaussian noise to all points stated in those commands. For each line, we randomly pick a point near the 50% and 75% of the line, add Gaussian noise, and fit a Catmull-Rom spline [5]. For all curves, we sample random points at uniform intervals and fit Catmull-Rom splines. We have a special condition for circles, where we ensure that the start and end points are randomized to create the effect of the pen lifting off. Additionally we randomize the stroke thickness.
\
Figure 10 shows the same program rendered multiple times using our randomized sketch simulator.
\
:::info
Authors:
(1) Shreyas Kapur, University of California, Berkeley (srkp@cs.berkeley.edu);
(2) Erik Jenner, University of California, Berkeley (jenner@cs.berkeley.edu);
(3) Stuart Russell, University of California, Berkeley (russell@cs.berkeley.edu).
:::
:::info
This paper is available on arxiv under CC BY-SA 4.0 DEED license.
:::
\