--- dataset_info: features: - name: id dtype: string - name: image dtype: image - name: width dtype: int32 - name: height dtype: int32 - name: boxes list: list: float32 length: 4 - name: labels list: class_label: names: '0': __background__ '1': airplane '2': animal '3': arm '4': bag '5': banana '6': basket '7': beach '8': bear '9': bed '10': bench '11': bike '12': bird '13': board '14': boat '15': book '16': boot '17': bottle '18': bowl '19': box '20': boy '21': branch '22': building '23': bus '24': cabinet '25': cap '26': car '27': cat '28': chair '29': child '30': clock '31': coat '32': counter '33': cow '34': cup '35': curtain '36': desk '37': dog '38': door '39': drawer '40': ear '41': elephant '42': engine '43': eye '44': face '45': fence '46': finger '47': flag '48': flower '49': food '50': fork '51': fruit '52': giraffe '53': girl '54': glass '55': glove '56': guy '57': hair '58': hand '59': handle '60': hat '61': head '62': helmet '63': hill '64': horse '65': house '66': jacket '67': jean '68': kid '69': kite '70': lady '71': lamp '72': laptop '73': leaf '74': leg '75': letter '76': light '77': logo '78': man '79': men '80': motorcycle '81': mountain '82': mouth '83': neck '84': nose '85': number '86': orange '87': pant '88': paper '89': paw '90': people '91': person '92': phone '93': pillow '94': pizza '95': plane '96': plant '97': plate '98': player '99': pole '100': post '101': pot '102': racket '103': railing '104': rock '105': roof '106': room '107': screen '108': seat '109': sheep '110': shelf '111': shirt '112': shoe '113': short '114': sidewalk '115': sign '116': sink '117': skateboard '118': ski '119': skier '120': sneaker '121': snow '122': sock '123': stand '124': street '125': surfboard '126': table '127': tail '128': tie '129': tile '130': tire '131': toilet '132': towel '133': tower '134': track '135': train '136': tree '137': truck '138': trunk '139': umbrella '140': vase '141': vegetable '142': vehicle '143': wave '144': wheel '145': window '146': windshield '147': wing '148': wire '149': woman '150': zebra - name: attributes list: list: class_label: names: '0': __background__ '1': white '2': black '3': blue '4': green '5': red '6': brown '7': yellow '8': small '9': large '10': wooden '11': silver '12': orange '13': grey '14': tall '15': long '16': dark '17': pink '18': standing '19': round '20': tan '21': glass '22': here '23': wood '24': open '25': purple '26': short '27': plastic '28': parked '29': sitting '30': walking '31': striped '32': brick '33': young '34': gold '35': old '36': hanging '37': empty '38': 'on' '39': bright '40': concrete '41': cloudy '42': colorful '43': one '44': beige '45': bare '46': wet '47': light '48': square '49': closed '50': stone '51': shiny '52': thin '53': dirty '54': flying '55': smiling '56': painted '57': thick '58': part '59': sliced '60': playing '61': tennis '62': calm '63': leather '64': distant '65': rectangular '66': looking '67': grassy '68': dry '69': cement '70': leafy '71': wearing '72': tiled '73': man's '74': baseball '75': cooked '76': pictured '77': curved '78': decorative '79': dead '80': eating '81': paper '82': paved '83': fluffy '84': lit '85': back '86': framed '87': plaid '88': dirt '89': watching '90': colored '91': stuffed '92': clean '93': in the picture '94': steel '95': stacked '96': covered '97': full '98': three '99': street '100': flat '101': baby '102': black and white '103': beautiful '104': ceramic '105': present '106': grazing '107': sandy '108': golden '109': blurry '110': side '111': chocolate '112': wide '113': growing '114': chrome '115': cut '116': bent '117': train '118': holding '119': water '120': up '121': arched '122': metallic '123': spotted '124': folded '125': electrical '126': pointy '127': running '128': leafless '129': electric '130': in background '131': rusty '132': furry '133': traffic '134': ripe '135': behind '136': laying '137': rocky '138': tiny '139': down '140': fresh '141': floral '142': stainless steel '143': high '144': surfing '145': close '146': 'off' '147': leaning '148': moving '149': multicolored '150': woman's '151': pair '152': huge '153': some '154': background '155': chain link '156': checkered '157': top '158': tree '159': broken '160': maroon '161': iron '162': worn '163': patterned '164': ski '165': overcast '166': waiting '167': rubber '168': riding '169': skinny '170': grass '171': porcelain '172': adult '173': wire '174': cloudless '175': curly '176': cardboard '177': jumping '178': tile '179': pointed '180': blond '181': cream '182': four '183': male '184': smooth '185': hazy '186': computer '187': older '188': pine '189': raised '190': many '191': bald '192': snow covered '193': skateboarding '194': narrow '195': reflective '196': rear '197': khaki '198': extended '199': roman '200': american - name: relations struct: - name: subject_index list: int64 - name: object_index list: int64 - name: predicate list: class_label: names: '0': __background__ '1': above '2': across '3': against '4': along '5': and '6': at '7': attached to '8': behind '9': belonging to '10': between '11': carrying '12': covered in '13': covering '14': eating '15': flying in '16': for '17': from '18': growing on '19': hanging from '20': has '21': holding '22': in '23': in front of '24': laying on '25': looking at '26': lying on '27': made of '28': mounted on '29': near '30': of '31': 'on' '32': on back of '33': over '34': painted on '35': parked on '36': part of '37': playing '38': riding '39': says '40': sitting on '41': standing on '42': to '43': under '44': using '45': walking in '46': walking on '47': watching '48': wearing '49': wears '50': with splits: - name: train num_bytes: 8889584511 num_examples: 62407 - name: validation num_bytes: 1260526902 num_examples: 8915 - name: test num_bytes: 2706740524 num_examples: 17832 download_size: 12730567170 dataset_size: 12856851937 configs: - config_name: default data_files: - split: train path: data/train-* - split: validation path: data/validation-* - split: test path: data/test-* --- # Visual Genome Scene Graph Dataset 该仓库提供经过结构化处理的 Visual Genome 场景图数据集,可直接通过 Hugging Face `datasets` 加载。数据采用常用的 VG150 类别体系,包含 150 个前景对象类别、50 个前景关系类别和 200 个前景属性类别;每组类别还包含索引为 0 的 `__background__`。 ## 数据划分 | Split | 样本数 | | --- | ---: | | train | 62,407 | | validation | 8,915 | | test | 17,832 | | **合计** | **89,154** | 仓库下载大小约为 12.7 GB。图片直接嵌入 Parquet,因此 `image` 字段由 Hugging Face 解码为 PIL 图片对象。 ## 字段说明 每行表示一张图片及其场景图: - `id`:样本 ID。 - `image`:Hugging Face `Image` 字段,读取样本时返回 PIL 图片。 - `width`、`height`:图片宽高。 - `boxes`:对象边界框,格式为 `[x_min, y_min, x_max, y_max]`。 - `labels`:与 `boxes` 一一对应的对象类别 ID。 - `attributes`:与对象一一对应的属性类别 ID 列表。 - `relations.subject_index`:关系主语在对象数组中的索引。 - `relations.object_index`:关系宾语在对象数组中的索引。 - `relations.predicate`:关系类别 ID。 对象、属性和关系均使用 `ClassLabel`,可以通过 Dataset 的 `features` 取得类别名称。 ## 加载数据 ```python from datasets import load_dataset dataset = load_dataset("wliafe/vg") print(dataset) sample = dataset["train"][0] print(sample["id"]) print(sample["image"].size) print(len(sample["boxes"])) print(len(sample["relations"]["predicate"])) ``` 如需避免立即解码图片,可以先把 `image` 字段转换为 `decode=False`: ```python from datasets import Image, load_dataset dataset = load_dataset("wliafe/vg") dataset = dataset.cast_column("image", Image(decode=False)) sample = dataset["train"][0] print(sample["image"]) ``` ## 读取类别名称 ```python from datasets import load_dataset dataset = load_dataset("wliafe/vg") features = dataset["train"].features object_names = features["labels"].feature.names attribute_names = features["attributes"].feature.feature.names predicate_names = features["relations"]["predicate"].feature.names sample = dataset["train"][0] for subject_index, object_index, predicate_id in zip( sample["relations"]["subject_index"], sample["relations"]["object_index"], sample["relations"]["predicate"], ): subject_label = object_names[sample["labels"][subject_index]] object_label = object_names[sample["labels"][object_index]] predicate = predicate_names[predicate_id] print(f"{subject_label} --{predicate}--> {object_label}") ``` ## 标注约定 - 边界框会裁剪到图片范围内。 - 裁剪后面积为零的对象不会保留。 - 引用已删除对象的关系不会保留。 - 关系端点保存为当前对象数组的索引,而不是 Visual Genome 的原始对象 ID。 - `boxes`、`labels` 和 `attributes` 使用相同的对象顺序。 ## 引用 如果该数据集对你的研究有帮助,请引用 Visual Genome: ```bibtex @article{krishna2017visual, title={Visual Genome: Connecting Language and Vision Using Crowdsourced Dense Image Annotations}, author={Krishna, Ranjay and Zhu, Yuke and Groth, Oliver and Johnson, Justin and Hata, Kenji and Kravitz, Joshua and Chen, Stephanie and Kalantidis, Yannis and Li, Li-Jia and Shamma, David A. and Bernstein, Michael S. and Fei-Fei, Li}, journal={International Journal of Computer Vision}, volume={123}, pages={32--73}, year={2017} } ``` 数据的使用许可和适用范围请以 Visual Genome 官方发布条款为准。