KMasaki/cc12m-sam-parse-tree
收藏资源简介:
--- dataset_info: features: - name: jpg dtype: image - name: txt dtype: string - name: njson dtype: string - name: samlens.npy dtype: binary - name: samcat.npy dtype: binary splits: - name: train num_examples: 10968539 configs: - config_name: default data_files: - split: train path: "cc12m-train-*.tar" license: cc-by-4.0 task_categories: - zero-shot-image-classification - image-to-text - text-to-image tags: - clip - webdataset - sam - region-phrase-alignment size_categories: - 10M<n<100M --- # CC12M with SAM Regions and Parse-Tree Phrases Pre-processed [CC12M](https://github.com/google-research-datasets/conceptual-12m) dataset for training [PowerCLIP](https://github.com/KMasaki/PowerCLIP). Each sample contains the original image and caption plus two precomputed annotations: - **Parse-tree phrases** (`.njson`) — NP/PP/VP/S constituent phrases extracted via spaCy, with token indices aligned to OpenCLIP's `SimpleTokenizer` (CSR format). - **SAM regions** (`.samlens.npy` + `.samcat.npy`) — Segment Anything Model (SAM ViT-H) region bounding boxes converted to ViT patch-grid token indices (CSR format, patch size 16, image size 224). ## Format WebDataset tar archives (2176 shards). Each sample contains: ``` {key}.jpg # Image {key}.txt # Caption {key}.json # Metadata (original CC12M fields) {key}.njson # Parse-tree phrase indices (CSR: lengths + token IDs) {key}.samlens.npy # SAM region lengths array {key}.samcat.npy # SAM region token indices (concatenated) ``` ## Usage ```python import webdataset as wds dataset = wds.WebDataset("cc12m-train-{0000..2175}.tar") for sample in dataset: image = sample["jpg"] # raw JPEG bytes caption = sample["txt"] # caption string # SAM regions and parse-tree phrases are loaded automatically # by PowerCLIP's data pipeline ``` Or use with PowerCLIP directly: ```bash torchrun --nproc_per_node 8 -m training.main \ --train-data "cc12m-train-{0000..2175}.tar" \ ... ``` ## Source - Images & captions: [Conceptual 12M](https://github.com/google-research-datasets/conceptual-12m) (CC-BY-4.0) - SAM regions: [Segment Anything (ViT-H)](https://github.com/facebookresearch/segment-anything) - Parse-tree phrases: [spaCy](https://spacy.io/) `en_core_web_sm`
数据集信息: 特征: - 名称:jpg,数据类型:图像 - 名称:txt,数据类型:字符串 - 名称:njson,数据类型:字符串 - 名称:samlens.npy,数据类型:二进制 - 名称:samcat.npy,数据类型:二进制 数据划分: - 划分:训练集(train),样本数:10968539 配置项: - 配置名称:默认配置(default),数据文件: - 划分:训练集,路径:"cc12m-train-*.tar" 许可证:CC-BY-4.0 任务类别: - 零样本(Zero-shot)图像分类 - 图像到文本 - 文本到图像 标签: - CLIP - WebDataset - SAM - 区域短语对齐(region-phrase-alignment) 样本规模区间:10M<n<100M --- # 带SAM区域与句法分析树短语的CC12M数据集 本数据集为用于训练PowerCLIP的预处理版CC12M数据集,原始CC12M数据集可参见https://github.com/google-research-datasets/conceptual-12m,PowerCLIP项目仓库见https://github.com/KMasaki/PowerCLIP。 每个样本包含原始图像与文本标注,以及两项预计算得到的注释: - **句法分析树短语(Parse-tree phrases)**(文件后缀为.njson):通过spaCy提取的名词短语(NP)、介词短语(PP)、动词短语(VP)与句子(S)等成分短语,其Token索引与OpenCLIP的`SimpleTokenizer`对齐,格式为压缩稀疏行(CSR, Compressed Sparse Row)格式。 - **SAM区域(SAM regions)**(对应文件为.samlens.npy与.samcat.npy):由分段任意模型(Segment Anything Model, SAM)ViT-H生成的区域边界框,经转换为ViT补丁网格Token索引后得到的结果,格式为压缩稀疏行(CSR)格式,补丁大小为16,图像尺寸为224。 ## 数据格式 采用WebDataset格式的tar归档文件(共2176个分片),每个样本包含以下文件: {key}.jpg # 图像文件 {key}.txt # 文本标注字符串 {key}.json # 元数据(原始CC12M数据集字段) {key}.njson # 句法分析树短语索引(压缩稀疏行格式:长度数组+Token标识符) {key}.samlens.npy # SAM区域长度数组 {key}.samcat.npy # 拼接后的SAM区域Token索引数组 ## 使用方法 python import webdataset as wds dataset = wds.WebDataset("cc12m-train-{0000..2175}.tar") for sample in dataset: image = sample["jpg"] # 原始JPEG字节数据 caption = sample["txt"] # 文本标注字符串 # SAM区域与句法分析树短语将由PowerCLIP的数据流水线自动加载 也可直接结合PowerCLIP使用: bash torchrun --nproc_per_node 8 -m training.main --train-data "cc12m-train-{0000..2175}.tar" ... ## 数据来源 - 图像与文本标注:[Conceptual 12M](https://github.com/google-research-datasets/conceptual-12m),采用CC-BY-4.0许可证 - SAM区域:[Segment Anything项目(ViT-H版本)](https://github.com/facebookresearch/segment-anything) - 句法分析树短语:基于[spaCy](https://spacy.io/)的`en_core_web_sm`模型生成



