Solving masked jigsaw puzzles with diffusion vision transformers

Jinyang Liu, Wondmgezahu Teshome, Sandesh Ghimire, Mario Sznaier, Octavia Camps · DOI · OpenReview

Abstract

Jigsaw puzzle solving is a fundamental task in computer vision with diverse applications ranging from archaeology and biology to video editing. Traditional methods often struggle with scalability, varying numbers of fragments, and missing data. We present Jigsaw Puzzles with Diffusion Vision Transformers (JPDVT), a novel framework that treats both spatial (image) and temporal (video) puzzle solving as a conditional diffusion task. By utilizing Diffusion Vision Transformers to denoise positional encodings conditioned on visual content, JPDVT accurately reassembles shuffled fragments and can even "hallucinate" missing pieces. Our approach achieves state-of-the-art performance across multiple benchmarks, including ImageNet-1k and UCF101, demonstrating superior robustness and flexibility.

Introduction and Problem Statement

Traditional jigsaw puzzle solving involves rearranging image patches or video frames into their original, coherent order. While seemingly a simple game, this task serves as a proxy for complex restoration problems in real-world domains. Existing computer vision methods typically employ discriminative models to predict absolute positions or specific permutations. However, these models face significant hurdles:

  1. Scalability: Performance often degrades sharply as the number of pieces increases.
  2. Flexibility: Models are frequently rigid, failing when the number of input elements varies from the training distribution.
  3. Missing Data: Most models assume a complete set of pieces. When fragments are missing (masked), discriminative models often lose the global context required to place the remaining pieces correctly.
Figure 1: The JPDVT framework addresses both spatial and temporal jigsaw puzzles, even when fragments are masked.

Methodology: Jigsaw Puzzles as Diffusion

JPDVT reframes position not as a category to be classified, but as a continuous signal to be recovered through a Conditional Diffusion Denoising Probabilistic Model (CDDPM).

The Core Workflow

The system represents each puzzle piece as a pair: its visual content embedding and its positional encoding (1D for temporal sequences, 2D for spatial images).

  • Forward Diffusion: During training, Gaussian noise is iteratively added to the positional encodings of the pieces.
  • Reverse Generation: A transformer-based model is tasked with removing this noise to recover the original positions, conditioned on the visual features of the shuffled pieces.
  • Handling Masks: A unique strength of JPDVT is its ability to handle missing pieces. The model generates visual embeddings and positions for missing fragments simultaneously, maintaining global coherence.
Figure 5: Overview of the JPDVT training and testing pipelines, illustrating the interaction between the Reverse Diffusion Transformer Layers and positional embeddings.

For images, the architecture utilizes a Diffusion Transformer (DiT). For videos, a modified U-Net operates on latent variables—compressed frame representations—to handle high-resolution temporal data efficiently.

Key Insights

  • Position as a Denoising Target: By diffusing positional encodings rather than raw pixels for the reordering task, the model learns the underlying structure of the data more robustly than simple classifiers.
  • Permutation Equivariance: Transformers are naturally suited for this task because they treat inputs as sets. The model is indifferent to the initial shuffled order, focusing instead on the relationship between visual content and target positions.
  • Joint Inpainting and Ordering: The model can solve for where things go and what is missing at the same time. This allows it to maintain spatial or temporal coherence even when up to 33% of the data is missing.
  • Downstream Utility: The framework can be adapted for Temporal Super-resolution, effectively increasing video frame rates by treating missing intermediate frames as masked puzzle pieces.

Experimental Results

JPDVT was evaluated on diverse benchmarks, including ImageNet-1k for images and MovingMNIST, CLEVRER, and UCF101 for videos. The results demonstrate a significant leap over previous state-of-the-art (SOTA) methods:

  • Image Accuracy: On ImageNet-1k (3x3 puzzles), JPDVT achieved a 68.7% puzzle-level success rate, a substantial improvement over the previous SOTA (Deepzzle at 48%).
  • Large-Scale Puzzles: The model successfully handled puzzles with up to 150 pieces, maintaining high accuracy where previous methods like SJP-ED struggled.
  • Temporal Precision: In video reshuffling, the model achieved near-perfect reconstruction on MovingMNIST, significantly outperforming baselines in Normalized Kendall Distance.

Limitations and Future Work

While JPDVT offers superior accuracy, it faces a trade-off in inference speed. Because diffusion models require multiple iterative steps to denoise positions, JPDVT is slower than simple feed-forward discriminative models. For instance, solving a video puzzle may take approximately 10 seconds, compared to 1 second for some baselines.

Future research will focus on optimizing the number of diffusion steps to improve speed without sacrificing accuracy and extending the framework to "in-the-wild" restoration tasks where both the number of pieces and the extent of damage are unknown.

Summary updated

BibTeX
@misc{liu2024solving,
  author = {Jinyang Liu and Wondmgezahu Teshome and Sandesh Ghimire and Mario Sznaier and Octavia Camps},
  title = {{Solving masked jigsaw puzzles with diffusion vision transformers}},
  year = {2024},
  eprint = {2404.07292},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.07292},
}
Figure