You need to agree to share your Hugging Face information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

Anime-2024Dru768-8M

Danbooru 2024 的动漫图像集,统一到 768² 面积预算后封成 tar 分片,适合 SD / SDXL / Flux 类模型的底模训练与打标流水线。

A danbooru2024 subset, resized to a 768² area budget and packed into tar shards for diffusion-model training and auto-tagging pipelines.

概览 / At a glance

项目 值
图像数 8,005,010
tar 分片 844 个(shard-000000.tar … shard-000843.tar)
总体积 1,439.78 GB(tar)/ 1,434.05 GB(纯图像字节)
索引 manifest.jsonl(1,134 MB)
平均每张 187.8 KB
格式 JPEG,RGB

分片按 1750 MB 封口(最后几片较小)。成员名 <image_id>.jpg,image_id 与 danbooru post id 一致。

文件布局 / Layout

shard-000000.tar
shard-000001.tar
...
shard-000843.tar
manifest.jsonl
README.md

每个 tar 的成员:

<image_id>.jpg        JPEG,尺寸见 manifest 的 out_w / out_h

manifest.jsonl

一行一条,UTF-8,与 tar 成员一一对应(行数 = 成员数 = 唯一 id 数 = 8,005,010)。

字段 含义
image_id danbooru post id(字符串)
src_shard 来源源分片名,如 0025.tar
orig_w / orig_h 源图尺寸
out_w / out_h 本数据集里的尺寸
fit 缩放策略,见下
bytes_768 JPEG 字节数(与 tar 内成员大小一致)

fit 语义

取值 占比 含义
freeratio 56.82% 面积超预算,按 sqrt(预算/面积) 等比缩小,向下取整到 32 的倍数
bucket 25.42% 缩到固定的桶尺寸(边长 32 的倍数)
asis 17.76% 面积在预算内,保持原尺寸不缩放

处理细节 / Processing

  • 面积预算:768 × 768 = 589,824 像素
  • 缩放:PIL LANCZOS
  • 编码:JPEG,quality=95,subsampling=0(4:4:4 无下采样),progressive=True
  • 不裁切、不补边,宽高比保持

关于 32 对齐(重要)

83.15% 的图边长是 32 的倍数,16.85% 不是。

不对齐的全部来自 fit=asis(原图本身不是 32 倍数)。如果你的 VAE 要求严格 32 倍数(例如 SDXL 的某些配置),这 16.85% 需要自行后处理(裁切或补边),或者直接用 fit != "asis" 过滤:

keep = [r for r in rows if r["fit"] != "asis"]

用法 / Usage

按 manifest 索引读取(推荐,可分片流式):

import io, json, tarfile
from PIL import Image

MANIFEST = "manifest.jsonl"
ROOT = "."          # shard-*.tar 所在目录

def iter_images(limit=None):
    with open(MANIFEST, encoding="utf-8") as f:
        for i, line in enumerate(f):
            if limit and i >= limit:
                return
            r = json.loads(line)
            # tar 序号按 src_shard 反查不方便,实际用 webdataset 更省事
            yield r

# webdataset 方式(推荐)
# pip install webdataset
# ds = wds.WebDataset("shard-{000000..000843}.tar").decode("pil")

不依赖库的最小示例(逐个分片顺序读):

import json, os, tarfile
from PIL import Image

index = {}
for line in open("manifest.jsonl", encoding="utf-8"):
    r = json.loads(line)
    index[r["image_id"]] = r

for name in sorted(f for f in os.listdir(".") if f.endswith(".tar")):
    with tarfile.open(name) as tf:
        for m in tf:
            if not m.isfile():
                continue
            iid = os.path.splitext(os.path.basename(m.name))[0]
            meta = index[iid]
            img = Image.open(tf.extractfile(m)).convert("RGB")
            assert img.size == (meta["out_w"], meta["out_h"])

完整性 / Integrity

  • manifest.jsonl 行数 = 所有 tar 成员总数 = 唯一 image_id 数 = 8,005,010
  • 无重复 image_id,无 manifest 指向缺失图像的条目
  • 每个 tar 成员都是可解码的 JPEG,尺寸与 manifest 一致

如需校验,最快的办法是只比数量与唯一 id 集合,不要去比 tar 字节哈希(1.4 TB 全量读一次要数小时)。

来源与使用条款 / Provenance & terms

  • 原始图像来自 danbooru,经 deepghs/danbooru2024-webp-4Mpixel(gated,需申请访问)取用,再按上述规则统一缩放。
  • 图像版权归原作者所有,本仓库不授予任何图像的再许可。请遵守 danbooru 的服务条款与原数据集的使用条件。
  • 仅建议用于研究与非商业实验;商用前请自行评估每个作品的授权。
  • 内容包含成人向动漫图像(未做内容过滤)。
Downloads last month
2,396