Holasyb918/imagenet-1k-adm-crop-256
ImageNet-1k ADM Crop 256 This dataset is a preprocessed version of ILSVRC/imagenet-1k with all images center-cropped to 256Γ256 pixels using the ADM (Ablated Diffusion Model) algorithm. π― Purpose Optimized for training diffusion models and other generative models that require fixed-size square images. π Dataset Details Split Images Files Size (approx) train 1,281,167 294 ~38 GB test 50,000 28 ~3.5 GB π§ Processingβ¦ See the full description on the dataset page: https://huggingface.co/datasets/Holasyb918/imagenet-1k-adm-crop-256.
ImageNet-1k ADM Crop 256
This dataset is a preprocessed version of ILSVRC/imagenet-1k with all images center-cropped to 256Γ256 pixels using the ADM (Ablated Diffusion Model) algorithm.
π― Purpose
Optimized for training diffusion models and other generative models that require fixed-size square images.
π Dataset Details
π§ Processing Method
Center Crop Algorithm (from ADM)
The center crop implementation follows the guided-diffusion approach:
from PIL import Image
import numpy as np
def center_crop_arr(pil_image, image_size):
"""
Center cropping implementation from ADM.
https://github.com/openai/guided-diffusion/blob/8fb3ad9197f16bbc40620447b2742e13458d2831/guided_diffusion/image_datasets.py#L126
"""
# Progressively downsample if image is much larger than target
while min(*pil_image.size) >= 2 * image_size:
pil_image = pil_image.resize(
tuple(x // 2 for x in pil_image.size), resample=Image.BOX
)
# Scale so shortest side equals target size
scale = image_size / min(*pil_image.size)
pil_image = pil_image.resize(
tuple(round(x * scale) for x in pil_image.size), resample=Image.BICUBIC
)
# Center crop to exact target size
arr = np.array(pil_image)
crop_y = (arr.shape[0] - image_size) // 2
crop_x = (arr.shape[1] - image_size) // 2
return Image.fromarray(
arr[crop_y : crop_y + image_size, crop_x : crop_x + image_size]
)Why this algorithm?
- Progressive downsampling: Uses BOX filter for initial reduction, preserving image quality
- BICUBIC scaling: High-quality interpolation for final resize
- Exact center crop: Ensures consistent 256Γ256 output
π Data Structure
data/
βββ train-00000-of-00294.parquet
βββ train-00001-of-00294.parquet
βββ ...
βββ train-00293-of-00294.parquet
βββ test-00000-of-00028.parquet
βββ ...
βββ test-00027-of-00028.parquetπ Schema
π Usage
With π€ Datasets
from datasets import load_dataset
# Load full dataset
dataset = load_dataset("Holasyb918/imagenet-1k-adm-crop-256")
# Load specific split
train_dataset = load_dataset("Holasyb918/imagenet-1k-adm-crop-256", split="train")
test_dataset = load_dataset("Holasyb918/imagenet-1k-adm-crop-256", split="test")
# Access data
for example in train_dataset:
image = example["image"] # PIL Image, 256Γ256
label = example["label"] # int, 0-999With PyTorch DataLoader
from datasets import load_dataset
from torch.utils.data import DataLoader
from torchvision import transforms
# Load dataset
dataset = load_dataset("Holasyb918/imagenet-1k-adm-crop-256", split="train")
# Define transform
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]) # [-1, 1]
])
def collate_fn(batch):
images = torch.stack([transform(x["image"]) for x in batch])
labels = torch.tensor([x["label"] for x in batch])
return {"image": images, "label": labels}
# Create DataLoader
dataloader = DataLoader(dataset, batch_size=32, collate_fn=collate_fn, num_workers=4)π License
This dataset follows the same license terms as the original ImageNet dataset. Please ensure you comply with ImageNet's terms of use.
π Acknowledgments
- Original dataset: ILSVRC/imagenet-1k
- Center crop algorithm: OpenAI guided-diffusion
π Citation
If you use this dataset, please cite the original ImageNet paper:
@article{deng2009imagenet,
title={ImageNet: A large-scale hierarchical image database},
author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
},
year={2009}
}<sub>π This README was generated with the assistance of AI (Claude).</sub>
