ImageEye: Batch Image Processing using Program Synthesis

Celeste Barnaby, Qiaochu Chen, Roopsha Samanta, Isil Dillig

Abstract

Batch image editing traditionally involves global operations like resizing or color correction. However, many real-world tasks require fine-grained, content-aware modifications—such as blurring specific faces or redacting sensitive text based on spatial context. We present ImageEye, a neuro-symbolic tool designed to automate these complex tasks by synthesizing programs from a small number of user-provided examples. By lifting raw pixels into a symbolic representation of objects and attributes, ImageEye leverages a domain-specific language (DSL) and a novel pruning algorithm to navigate a vast search space efficiently. Evaluation on 50 diverse tasks shows that ImageEye achieves a 96% success rate with a median synthesis time of 1.1 seconds, significantly outperforming general-purpose synthesizers.

1. Introduction

While batch processing is a staple of modern photo editing suites, it remains largely restricted to "global" transformations. Users can easily resize a thousand images, but they cannot easily "crop every photo to the person holding a guitar" or "redact the price field in a batch of diverse receipts" without manual intervention or custom scripting. These tasks require two distinct capabilities: high-level perception to identify objects and relational reasoning to select targets based on context.

Existing computer vision (CV) models excel at detection but lack the programmatic framework for complex logic. Conversely, standard program synthesis tools lack the "eyes" to interpret visual data. ImageEye bridges this gap by lifting images into a symbolic representation and synthesizing programs that operate on these high-level abstractions.

2. The ImageEye Framework

ImageEye employs a neuro-symbolic approach to bridge the gap between raw pixels and logical selection.

2.1 Neuro-symbolic DSL

The system utilizes a Domain-Specific Language (DSL) where neural networks serve as "primitives." These primitives, powered by services like Amazon Rekognition, detect objects, faces, and text. The DSL then provides symbolic operators for:

  • Set Logic: Union, Intersect, and Complement.
  • Spatial Relationships: GetLeft, GetAbove, and GetParents.
  • Attribute Filtering: Selecting objects based on properties like isSmiling or specific text content.

2.2 Symbolic Image Representation

To make synthesis tractable, ImageEye converts raw images into a structured symbolic form. Each image becomes a collection of detected objects, each associated with a bounding box and a set of attributes. This transformation shifts the problem from the high-dimensional space of pixels to a structured search space of programmatic logic.

3. Efficient Program Synthesis

The core of ImageEye is a top-down enumerative search algorithm. Given the potential complexity of the DSL, the search space is vast. ImageEye introduces two primary innovations to maintain efficiency:

  • Equivalence Reduction: The system uses term rewriting and partial evaluation. By running incomplete programs on sample images, ImageEye can identify and discard redundant code branches that produce identical outputs, preventing the search from exploring equivalent paths.
  • Goal-Directed Abstraction: ImageEye employs "abstract semantics" to estimate the potential output of a sub-program. By calculating "Must" (under-approximation) and "May" (over-approximation) sets, the system can prune partial programs that can never satisfy the user's goal, regardless of how they are completed.

4. Evaluation

The authors evaluated ImageEye on a benchmark of 50 tasks across three domains: Wedding (facial attributes), Receipts (precise spatial text reasoning), and Objects (diverse categories). The tasks were sourced from real-world requests on forums like Reddit's r/PhotoshopRequest.

4.1 Performance and Efficiency

ImageEye demonstrated high effectiveness, successfully automating 48 out of 50 tasks. The synthesis process is remarkably fast, with a median time of 1.1 seconds. This speed allows for an interactive workflow where users can receive feedback almost instantaneously.

4.2 User Effort

A key metric for synthesis tools is the amount of user input required. ImageEye required a median of only 3.8 demonstrations (labeling specific objects in a few images) to generate a program that generalized to the entire batch. In comparison, general-purpose synthesizers like EUSolver solved only 68% of the tasks and struggled significantly as task complexity increased.

5. Discussion and Future Work

The success of ImageEye highlights that pixels are often the wrong abstraction for program synthesis. By lifting data into a symbolic space, classical synthesis techniques become viable for visual tasks.

However, the system is currently limited by the accuracy of its underlying neural primitives; if the vision model fails to detect an object, the symbolic reasoner cannot account for it. Furthermore, the current DSL is limited to 2D spatial reasoning. Future work could involve integrating 3D spatial understanding and active learning, where the system proactively asks the user to label the most informative images to further reduce demonstration effort.

Summary updated

BibTeX
@article{barnaby2023imageeye,
  author = {Celeste Barnaby and Qiaochu Chen and Roopsha Samanta and Isil Dillig},
  title = {{ImageEye: Batch Image Processing using Program Synthesis}},
  journal = {Proc. ACM Program. Lang.},
  year = {2023},
  doi = {10.1145/3591248},
}
Figure