GAP
收藏资源简介:
GAP(Generated Archaeological-fragments Puzzles)是一个专为不规则碎片拼图求解设计的基准数据集,其灵感来源于考古学中的真实碎片复原任务。该数据集旨在推动计算机视觉和机器学习算法在处理非矩形、具有复杂边界形状的拼图碎片方面的研究。数据内容与构成:GAP通过对自然图像进行方形裁剪、网格划分,并应用基于变分自编码器(VAE)生成的侵蚀掩码,模拟出考古学上合理的碎片边界,从而生成包含不规则形状碎片的拼图。每个碎片以RGBA格式存储,其中RGB通道为像素颜色,Alpha通道编码了碎片的形状掩码(255表示碎片像素,0表示背景)。数据集提供两种变体:GAP-3(3x3网格,共9个碎片)和GAP-5(5x5网格,共25个碎片)。数据规模:每个变体包含20,000个拼图,总计40,000个。具体划分如下:训练集14,000个,验证集3,000个,测试集3,000个。每个碎片的图像分辨率为128×128像素,完整拼图图像尺寸分别为384×384(GAP-3)和640×640(GAP-5)。数据格式与标签:数据以HDF5文件格式存储,包含三个核心文件:`puzzles.h5`(碎片图像数据,形状为(N, P, 128, 128, 4),uint8类型)、`labels_indices.h5`(索引标签,形状为(N, P),表示每个碎片的目标扁平化位置索引)和`labels_coordinates.h5`(坐标标签,形状为(N, P, 2),表示每个碎片的目标网格行列坐标)。其中N为拼图数量,P为碎片数量。适用任务与应用场景:GAP主要用于评估和开发拼图求解算法,特别是针对不规则碎片形状的挑战。它适用于计算机视觉、模式识别和机器学习领域,可作为基准测试来比较不同方法在碎片重组任务上的性能。数据集还附带了用于生成不规则碎片掩码的VAE模型(碎片生成器),允许用户创建新的类似碎片或应用于自定义图像。
GAP (Generated Archaeological-fragments Puzzles) is a benchmark dataset designed for irregular fragment puzzle solving, inspired by real-world fragment restoration tasks in archaeology. The dataset aims to advance research in computer vision and machine learning algorithms for handling non-rectangular puzzle fragments with complex boundary shapes. Data Content and Composition: GAP generates puzzles containing irregularly shaped fragments by cropping natural images into squares, dividing them into grids, and applying erosion masks generated via a Variational Autoencoder (VAE) to simulate archaeologically plausible fragment boundaries. Each fragment is stored in RGBA format, where the RGB channels represent pixel colors, and the Alpha channel encodes the fragments shape mask (255 for fragment pixels, 0 for background). The dataset offers two variants: GAP-3 (3x3 grid, 9 fragments) and GAP-5 (5x5 grid, 25 fragments). Data Scale: Each variant contains 20,000 puzzles, totaling 40,000. The specific splits are: 14,000 for training, 3,000 for validation, and 3,000 for testing. Each fragment image has a resolution of 128×128 pixels, with full puzzle image sizes of 384×384 (GAP-3) and 640×640 (GAP-5). Data Format and Labels: The data is stored in HDF5 file format, comprising three core files: `puzzles.h5` (fragment image data, shape (N, P, 128, 128, 4), uint8 type), `labels_indices.h5` (index labels, shape (N, P), indicating the target flattened position index for each fragment), and `labels_coordinates.h5` (coordinate labels, shape (N, P, 2), indicating the target grid row and column coordinates for each fragment). Here, N is the number of puzzles, and P is the number of fragments. Applicable Tasks and Scenarios: GAP is primarily used for evaluating and developing puzzle-solving algorithms, especially for challenges involving irregular fragment shapes. It is suitable for computer vision, pattern recognition, and machine learning fields, serving as a benchmark to compare the performance of different methods in fragment reassembly tasks. The dataset also includes a VAE model (fragment generator) for generating irregular fragment masks, allowing users to create new similar fragments or apply them to custom images.
数据集概述
GAP(Generated Archaeological-fragments Puzzles) 是一个用于不规则拼图求解的基准数据集,其碎片形状受真实考古碎片启发。数据集中的拼图由自然图像经侵蚀掩膜碎片化生成,产生带有透明度通道的非矩形碎片。
- 许可协议: CC-BY-NC-4.0
- 任务类别: 图像到图像、其他
- 语言: 英语
- 数据集大小: 10K < n < 100K
数据集变体与规模
| 变体 | 网格 | 碎片数量 | 碎片尺寸 | 完整图像尺寸 | 训练集 | 验证集 | 测试集 |
|---|---|---|---|---|---|---|---|
| GAP-3 | 3×3 | 9 | 128×128 | 384×384 | 14,000 | 3,000 | 3,000 |
| GAP-5 | 5×5 | 25 | 128×128 | 640×640 | 14,000 | 3,000 | 3,000 |
总计:每个变体20,000个拼图,两个变体共40,000个。
数据生成流程
每个拼图的构建步骤:
- 将自然图像裁剪为正方形。
- 按网格划分为方形小块。
- 使用基于真实考古碎片的VAE模型为每个小块采样不规则侵蚀掩膜。
- 通过透明度合成应用掩膜,生成具有考古学合理边界的RGBA碎片。
数据格式
数据以HDF5文件存储,采用gzip压缩。每个变体目录结构如下:
puzzles.h5: 存储拼图碎片,形状为(N, P, 128, 128, 4),数据类型uint8,RGBA格式。labels_indices.h5: 存储排列索引标签,形状为(N, P),数据类型int,每个碎片的目标位置索引。labels_coordinates.h5: 存储坐标标签,形状为(N, P, 2),数据类型int,每个碎片的(row, col)坐标。metadata.json: 元数据文件。
通道说明:
- R/G/B (通道0-2): 像素颜色,范围[0, 255]。
- A (通道3): 透明度掩膜,255表示碎片区域,0表示背景。
标签格式:
- 索引标签: 展平排列,给出每个碎片在网格中的目标位置(索引0到P-1)。
- 坐标标签: 二维表示,给出每个碎片的行和列,等效展平索引为
row * grid_size + col。
使用示例
使用PyTorch加载
python from gap_dataloader import GAPDataset, create_dataloaders
dataset = GAPDataset("GAP-3/train") pieces, label = dataset[0]
pieces: Tensor (9, 4, 128, 128), float32 in [0, 1]
label: Tensor (9,), int64 - permutation indices
仅使用NumPy加载
python import h5py import numpy as np
with h5py.File("GAP-3/test/puzzles.h5", "r") as f: puzzles = f["puzzles"][:] # (3000, 9, 128, 128, 4) uint8 with h5py.File("GAP-3/test/labels_indices.h5", "r") as f: labels = f["labels"][:] # (3000, 9) int
评估指标
| 指标 | 缩写 | 级别 | 描述 |
|---|---|---|---|
| 完美准确率 | PA | 拼图级 | 每个碎片都正确放置的拼图比例 |
| 绝对准确率 | AA | 碎片级 | 放置在正确位置的单个碎片比例 |
| 空间关系准确率 | SRA | 碎片对级 | 相邻碎片对的空间关系被保持的比例 |
评估代码示例:
python from evaluate_gap import compute_all_metrics
metrics = compute_all_metrics(predictions, targets, grid_size=3)
基准结果
以下为论文中在GAP测试集上的主要结果:
| 方法 | GAP-3 PA (%) | GAP-3 AA (%) | GAP-3 SRA (%) | GAP-5 PA (%) | GAP-5 AA (%) | GAP-5 SRA (%) |
|---|---|---|---|---|---|---|
| 最优方法 (PuzzleFlow) | 28.5 | 62.9 | 55.7 | 0.3 | 29.1 | 19.8 |
GAP对现有拼图求解方法提出了显著挑战,尤其是在不规则侵蚀碎片场景下。
碎片生成器
数据集包含一个训练好的VAE模型(位于fragment_generator/目录),可用于:
- 生成新的128×128考古风格碎片掩膜。
- 对任意图像应用掩膜以生成更多不规则拼图。
- 基于其他碎片掩膜源重新训练生成器。
引用
若在研究中使用了GAP基准,请引用以下论文:
@article{shahar2026missing, title={The Missing GAP: From Solving Square Jigsaw Puzzles to Handling Real World Archaeological Fragments}, author={Shahar, Ofir Itzhak and Elkin, Gur and Ben-Shahar, Ohad}, journal={arXiv preprint arXiv:2605.12077}, year={2026} }





