Datasets:
id
stringlengths 13
21
| split
stringclasses 2
values | category
stringclasses 5
values | main_label
stringclasses 96
values | ref_image
imagewidth (px) 368
3.84k
| ref_mask
imagewidth (px) 368
3.84k
| tar_image
imagewidth (px) 368
3.84k
| tar_mask
imagewidth (px) 368
3.84k
|
---|---|---|---|---|---|---|---|
train/object/3458 | train | object | Book | ||||
train/object/9857 | train | object | Tomato | ||||
train/accessory/14906 | train | accessory | Trousers | ||||
train/accessory/21236 | train | accessory | top | ||||
train/accessory/10311 | train | accessory | Bag | ||||
train/object/5778 | train | object | pillow | ||||
train/object/18269 | train | object | table | ||||
train/object/2418 | train | object | Banana | ||||
train/object/677 | train | object | Pizza | ||||
train/person/6563 | train | person | person | ||||
train/accessory/23111 | train | accessory | top | ||||
train/accessory/12592 | train | accessory | Trousers | ||||
train/object/9925 | train | object | Tomato | ||||
train/object/8039 | train | object | Pumpkin | ||||
train/accessory/3748 | train | accessory | Dress | ||||
train/accessory/8724 | train | accessory | Hat | ||||
train/object/529 | train | object | Pizza | ||||
train/accessory/9624 | train | accessory | Necklace | ||||
train/accessory/23726 | train | accessory | top | ||||
train/object/18892 | train | object | lamp | ||||
train/person/5930 | train | person | person | ||||
train/object/5741 | train | object | pillow | ||||
train/accessory/4033 | train | accessory | Dress | ||||
train/accessory/13807 | train | accessory | Trousers | ||||
train/object/4938 | train | object | Percussion | ||||
train/object/18360 | train | object | Momordica charantia | ||||
train/object/2804 | train | object | Book | ||||
train/object/6201 | train | object | Apple | ||||
train/object/11075 | train | object | mug | ||||
train/accessory/17298 | train | accessory | top | ||||
train/object/21207 | train | object | rifle | ||||
train/object/22011 | train | object | chair | ||||
train/object/1507 | train | object | Hair dryer | ||||
train/object/2458 | train | object | Banana | ||||
train/object/14969 | train | object | Bagged snacks | ||||
train/object/19427 | train | object | lamp | ||||
train/accessory/22095 | train | accessory | top | ||||
train/accessory/15737 | train | accessory | top | ||||
train/accessory/5412 | train | accessory | Trousers | ||||
train/accessory/14547 | train | accessory | Necklace | ||||
train/object/18583 | train | object | Momordica charantia | ||||
train/person/3705 | train | person | person | ||||
train/accessory/8720 | train | accessory | Scarf | ||||
train/object/6628 | train | object | Pear | ||||
train/accessory/18299 | train | accessory | top | ||||
train/accessory/5889 | train | accessory | Dress | ||||
train/accessory/12545 | train | accessory | Trousers | ||||
train/object/23620 | train | object | Potato | ||||
train/accessory/6552 | train | accessory | Dress | ||||
train/object/24266 | train | object | bottle | ||||
train/accessory/8395 | train | accessory | Trousers | ||||
train/object/5428 | train | object | pillow | ||||
train/accessory/24141 | train | accessory | top | ||||
train/accessory/17667 | train | accessory | top | ||||
train/object/18914 | train | object | lamp | ||||
train/object/23642 | train | object | Potato | ||||
train/accessory/14553 | train | accessory | Trousers | ||||
train/accessory/2688 | train | accessory | Dress | ||||
train/object/8512 | train | object | Lipstick | ||||
train/object/5122 | train | object | Projector | ||||
train/object/23557 | train | object | Potato | ||||
train/accessory/13831 | train | accessory | Trousers | ||||
train/object/896 | train | object | Glasses | ||||
train/object/19176 | train | object | lamp | ||||
train/object/14717 | train | object | Bagged snacks | ||||
train/object/7175 | train | object | Eggplant | ||||
train/accessory/3396 | train | accessory | Dress | ||||
train/person/1232 | train | person | person | ||||
train/accessory/18842 | train | accessory | top | ||||
train/accessory/6609 | train | accessory | Dress | ||||
train/accessory/26567 | train | accessory | top | ||||
train/accessory/5061 | train | accessory | Dress | ||||
train/person/3702 | train | person | person | ||||
train/accessory/2018 | train | accessory | Trousers | ||||
train/object/10493 | train | object | Soccer | ||||
train/person/446 | train | person | person | ||||
train/accessory/14318 | train | accessory | Trousers | ||||
train/person/3769 | train | person | person | ||||
train/person/1048 | train | person | person | ||||
train/accessory/15503 | train | accessory | Trousers | ||||
train/object/15419 | train | object | toy figure | ||||
train/object/20305 | train | object | ashcan | ||||
train/accessory/25516 | train | accessory | top | ||||
train/object/13724 | train | object | Sunflower | ||||
train/accessory/8710 | train | accessory | Scarf | ||||
train/accessory/4591 | train | accessory | Dress | ||||
train/person/586 | train | person | person | ||||
train/object/3747 | train | object | Book | ||||
train/accessory/20052 | train | accessory | top | ||||
train/object/7492 | train | object | Eggplant | ||||
train/object/21091 | train | object | toy dog | ||||
train/person/3535 | train | person | person | ||||
train/accessory/12086 | train | accessory | Trousers | ||||
train/accessory/27166 | train | accessory | top | ||||
train/accessory/20999 | train | accessory | top | ||||
train/accessory/23042 | train | accessory | top | ||||
train/accessory/9732 | train | accessory | Bag | ||||
train/object/16603 | train | object | hammer | ||||
train/accessory/11910 | train | accessory | Trousers | ||||
train/accessory/8184 | train | accessory | Dress |
AnyInsertion
Wensong Song
·
Hong Jiang
·
Zongxing Yang
·
Ruijie Quan
·
Yi Yang
Zhejiang University | Harvard University | Nanyang Technological University
News
- [2025.4.25] Released AnyInsertion v1 mask-prompt dataset on Hugging Face.
Summary
This is the dataset proposed in our paper Insert Anything: Image Insertion via In-Context Editing in DiT
AnyInsertion dataset consists of training and testing subsets. The training set includes 159,908 samples across two prompt types: 58,188 mask-prompt image pairs and 101,720 text-prompt image pairs;the test set includes 158 data pairs: 120 mask-prompt pairs and 38 text-prompt pairs.
AnyInsertion dataset covers diverse categories including human subjects, daily necessities, garments, furniture, and various objects.
Directory
data/
├── train/
│ ├── accessory/
│ │ ├── ref_image/ # Reference image containing the element to be inserted
│ │ ├── ref_mask/ # The mask corresponding to the inserted element
│ │ ├── tar_image/ # Ground truth
│ │ ├── tar_mask/ # The mask corresponding to the edited area of target image
│ │
│ ├── object/
│ │ ├── ref_image/
│ │ ├── ref_mask/
│ │ ├── tar_image/
│ │ ├── tar_mask/
│ │
│ └── person/
│ ├── ref_image/
│ ├── ref_mask/
│ ├── tar_image/
│ ├── tar_mask/
│
└── test/
├── garment/
│ ├── ref_image/
│ ├── ref_mask/
│ ├── tar_image/
│ ├── tar_mask/
│
├── object/
│ ├── ref_image/
│ ├── ref_mask/
│ ├── tar_image/
│ ├── tar_mask/
│
└── person/
├── ref_image/
├── ref_mask/
├── tar_image/
├── tar_mask/
Example




Usage
This guide explains how to load and use the AnyInsertion dataset, specifically the subset focusing on mask-prompt image pairs, which has been prepared in Apache Arrow format for efficient loading with the Hugging Face datasets
library.
Installation
First, ensure you have the datasets
library installed. If not, you can install it via pip:
pip install datasets pillow
Loading the Dataset
You can load the dataset directly from the Hugging Face Hub using its identifier:
from datasets import load_dataset
# Replace with the correct Hugging Face Hub repository ID
repo_id = "WensongSong/AnyInsertion"
# Load the entire dataset (usually returns a DatasetDict with 'train' and 'test' splits)
dataset = load_dataset(repo_id)
print(dataset)
# Expected output similar to:
# DatasetDict({
# train: Dataset({
# features: ['id', 'split', 'category', 'main_label', 'ref_image', 'ref_mask', 'tar_image', 'tar_mask'],
# num_rows: XXXX
# })
# test: Dataset({
# features: ['id', 'split', 'category', 'main_label', 'ref_image', 'ref_mask', 'tar_image', 'tar_mask'],
# num_rows: YYYY
# })
# })
Loading Specific Splits
If you only need a specific split (e.g., 'test'), you can specify it during loading:
# Load only the 'test' split
test_dataset = load_dataset(repo_id, split='test')
print("Loaded Test Split:")
print(test_dataset)
# Load only the 'train' split
train_dataset = load_dataset(repo_id, split='train')
print("\nLoaded Train Split:")
print(train_dataset)
Dataset Structure
The loaded dataset (or individual splits) has the following structure and features (columns):
id (string): A unique identifier for each data sample, typically formatted as "split/category/image_id" (e.g., "train/accessory/0").
split (string): Indicates whether the sample belongs to the 'train' or 'test' set.
category (string): The category of the main object or subject in the sample. Possible values include: 'accessory', 'object', 'person' (for train), 'garment', 'object_test', 'person' (for test).
main_label (string): The label associated with the reference image/mask pair, derived from the original label.json files.
ref_image (Image): The reference image containing the object or element to be conceptually inserted. Loaded as a PIL (Pillow) Image object.
ref_mask (Image): The binary mask highlighting the specific element within the ref_image. Loaded as a PIL Image object.
tar_image (Image): The target image, representing the ground truth result after the conceptual insertion or editing. Loaded as a PIL Image object.
tar_mask (Image): The binary mask indicating the edited or inserted region within the tar_image. Loaded as a PIL Image object.
Accessing Data
You can access data like a standard Python dictionary or list:
# Get the training split from the loaded DatasetDict
train_ds = dataset['train']
# Get the first sample from the training set
first_sample = train_ds[0]
# Access specific features (columns) of the sample
ref_image = first_sample['ref_image']
label = first_sample['main_label']
category = first_sample['category']
print(f"\nFirst train sample category: {category}, label: {label}")
print(f"Reference image size: {ref_image.size}") # ref_image is a PIL Image
# Display the image (requires matplotlib or other image libraries)
# import matplotlib.pyplot as plt
# plt.imshow(ref_image)
# plt.title(f"Category: {category}, Label: {label}")
# plt.show()
# Iterate through the dataset (e.g., the first 5 test samples)
print("\nIterating through the first 5 test samples:")
test_ds = dataset['test']
for i in range(5):
sample = test_ds[i]
print(f" Sample {i}: ID={sample['id']}, Category={sample['category']}, Label={sample['main_label']}")
Filtering Data
The datasets library provides powerful filtering capabilities.
# Filter the training set to get only 'accessory' samples
accessory_train_ds = train_ds.filter(lambda example: example['category'] == 'accessory')
print(f"\nNumber of 'accessory' samples in train split: {len(accessory_train_ds)}")
# Filter the test set for 'person' samples
person_test_ds = test_ds.filter(lambda example: example['category'] == 'person')
print(f"Number of 'person' samples in test split: {len(person_test_ds)}")
Filtering by Split (if loaded as DatasetDict)
Although loading specific splits is preferred, you can also filter by the split column if you loaded the entire DatasetDict and somehow combined them (not typical, but possible):
# Assuming 'combined_ds' is a dataset containing both train and test rows
# test_split_filtered = combined_ds.filter(lambda example: example['split'] == 'test')
Working with Images
The features defined as Image (ref_image, ref_mask, tar_image, tar_mask) will automatically load the image data as PIL (Pillow) Image objects when accessed. You can then use standard Pillow methods or convert them to other formats (like NumPy arrays or PyTorch tensors) for further processing.
# Example: Convert reference image to NumPy array
import numpy as np
first_sample = train_ds[0]
ref_image_pil = first_sample['ref_image']
ref_image_np = np.array(ref_image_pil)
print(f"\nReference image shape as NumPy array: {ref_image_np.shape}")
Citation
@article{song2025insert,
title={Insert Anything: Image Insertion via In-Context Editing in DiT},
author={Song, Wensong and Jiang, Hong and Yang, Zongxing and Quan, Ruijie and Yang, Yi},
journal={arXiv preprint arXiv:2504.15009},
year={2025}
}
- Downloads last month
- 265