|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Conceptual 12M dataset.""" |
|
|
|
import datasets |
|
import gzip |
|
import json |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{changpinyo2021cc12m, |
|
title = {{Conceptual 12M}: Pushing Web-Scale Image-Text Pre-Training To Recognize Long-Tail Visual Concepts}, |
|
author = {Changpinyo, Soravit and Sharma, Piyush and Ding, Nan and Soricut, Radu}, |
|
booktitle = {CVPR}, |
|
year = {2021}, |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Conceptual 12M is a large-scale dataset of 12 million |
|
image-text pairs specifically meant to be used for visionand-language pre-training. |
|
Its data collection pipeline is a relaxed version of the one used in Conceptual Captions 3M. |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/google-research-datasets/conceptual-12m" |
|
|
|
_LICENSE = """\ |
|
The dataset may be freely used for any purpose, although acknowledgement of |
|
Google LLC ("Google") as the data source would be appreciated. The dataset is |
|
provided "AS IS" without any warranty, express or implied. Google disclaims all |
|
liability for any damages, direct or indirect, resulting from the use of the |
|
dataset. |
|
""" |
|
|
|
_URL = "https://huggingface.co/datasets/munggok/CC_12M_Indonesia/resolve/main/data/cc12m_indo.jsonl.gz" |
|
|
|
|
|
class Conceptual12M(datasets.GeneratorBasedBuilder): |
|
"""Conceptual 12M Indonesia dataset.""" |
|
|
|
def _info(self): |
|
features = datasets.Features({"image_url": datasets.Value("string"), "caption": datasets.Value("string")}) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
file = dl_manager.download(_URL) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"file": file, |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, file): |
|
id_ = 0 |
|
with gzip.open(open(file, "rb"), "rt", encoding="utf-8") as fi: |
|
for line in fi: |
|
if line: |
|
example = json.loads(line) |
|
yield id_, {"image_url": example['url'], "caption": example['caption']} |
|
id_ += 1 |
|
|