Skip to main content
QUICK REVIEW

[Paper Review] Learning to Infer Graphics Programs from Hand-Drawn Images

Kevin Ellis, Daniel Ritchie|arXiv (Cornell University)|Jul 30, 2017
Software Engineering ResearchComputer Science49 citations
TL;DR

This paper presents a deep learning and program synthesis framework that converts hand-drawn sketches into structured LATEX graphics programs by first inferring a symbolic specification of drawing commands via a convolutional neural network with attention, then synthesizing high-level programs with loops, conditionals, and symmetries. The key contribution is a learned amortized inference approach that accelerates program synthesis, enabling error correction, similarity measurement via program structure, and extrapolation of repetitive patterns.

ABSTRACT

We introduce a model that learns to convert simple hand drawings into graphics programs written in a subset of \LaTeX. The model combines techniques from deep learning and program synthesis. We learn a convolutional neural network that proposes plausible drawing primitives that explain an image. These drawing primitives are like a trace of the set of primitive commands issued by a graphics program. We learn a model that uses program synthesis techniques to recover a graphics program from that trace. These programs have constructs like variable bindings, iterative loops, or simple kinds of conditionals. With a graphics program in hand, we can correct errors made by the deep network, measure similarity between drawings by use of similar high-level geometric structures, and extrapolate drawings. Taken together these results are a step towards agents that induce useful, human-readable programs from perceptual input.

Motivation & Objective

  • To develop a system that infers high-level graphics programs from simple 2D hand-drawn sketches.
  • To address the challenge of bridging perceptual input (images) to symbolic, executable programs with constructs like loops and conditionals.
  • To enable high-level image editing and reasoning by recovering structured programs from sketches.
  • To reduce the computational cost of program synthesis through amortized inference using deep learning.

Proposed method

  • A convolutional neural network with a differentiable spatial transformer attends to image regions and generates drawing commands one at a time, conditioned on previously generated commands.
  • The network uses a multilayer perceptron to predict a distribution over primitive commands (e.g., line, rectangle, circle) on a discrete 16×16 grid.
  • Stochastic search via Sequential Monte Carlo is used to infer a symbolic specification (spec) of drawing commands from the input image.
  • A constraint-based program synthesis engine reconstructs high-level programs from the inferred spec, incorporating loops, conditionals, and symmetries.
  • Amortized inference is achieved by training a neural network to approximate the stochastic search, reducing the need for expensive online inference.
  • The system combines neural perception with symbolic reasoning to produce executable, human-readable graphics programs.

Experimental results

Research questions

  • RQ1Can a deep neural network effectively infer a symbolic specification of drawing commands from noisy, hand-drawn images?
  • RQ2How can program synthesis techniques be accelerated and made practical for real-world sketch-to-code conversion?
  • RQ3To what extent can learned programs capture high-level visual concepts like symmetry and repetition from simple sketches?
  • RQ4Can the inferred programs enable coherent image editing, such as extrapolation of repetitive patterns?
  • RQ5How does program-level similarity compare to image-level similarity in capturing semantic structure?

Key findings

  • The model successfully infers symbolic specifications from hand-drawn images with high accuracy, enabling downstream program synthesis.
  • The use of amortized inference via a learned neural network significantly reduces the computational cost of program synthesis compared to standard stochastic search.
  • The system can correct errors made by the deep network by leveraging the consistency of program-level semantics.
  • Program-level similarity metrics effectively capture high-level geometric structures like symmetry and repetition, outperforming image-level similarity in capturing semantic structure.
  • The system can extrapolate drawings by modifying loop bounds in the synthesized program, producing coherent, larger-scale versions of the original sketch.
  • Experiments show that the model generalizes to novel sketches and produces executable LATEX graphics programs that match the intended visual structure.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.