Datasets:
Tasks:
Image-to-Text
Formats:
parquet
Languages:
Japanese
Size:
10K - 100K
Tags:
advertisement
License:
import ast | |
import datasets as ds | |
import pandas as pd | |
_DESCRIPTION = """\ | |
CAMERA (CyberAgent Multimodal Evaluation for Ad Text GeneRAtion) is the Japanese ad text generation dataset. | |
""" | |
_CITATION = """\ | |
@misc{mita2024striking, | |
title={Striking Gold in Advertising: Standardization and Exploration of Ad Text Generation}, | |
author={Masato Mita and Soichiro Murakami and Akihiko Kato and Peinan Zhang}, | |
year={2024}, | |
eprint={2309.12030}, | |
archivePrefix={arXiv}, | |
primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'} | |
} | |
""" | |
_HOMEPAGE = "https://github.com/CyberAgentAILab/camera" | |
_LICENSE = """\ | |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. | |
""" | |
_URLS = { | |
"without-lp-images": "https://storage.googleapis.com/camera-public/camera-v2.2-minimal.tar.gz", | |
"with-lp-images": "https://storage.googleapis.com/camera-public/camera-v2.2.tar.gz", | |
} | |
_DESCRIPTION = { | |
"without-lp-images": "The CAMERA dataset w/o LP images (ver.2.2.0)", | |
"with-lp-images": "The CAMERA dataset w/ LP images (ver.2.2.0)", | |
} | |
_VERSION = ds.Version("2.2.0", "") | |
class CameraConfig(ds.BuilderConfig): | |
def __init__(self, name: str, version: ds.Version = _VERSION, **kwargs): | |
super().__init__( | |
name=name, | |
description=_DESCRIPTION[name], | |
version=version, | |
**kwargs, | |
) | |
class CameraDataset(ds.GeneratorBasedBuilder): | |
BUILDER_CONFIGS = [CameraConfig(name="with-lp-images")] | |
DEFAULT_CONFIG_NAME = "with-lp-images" | |
def _info(self) -> ds.DatasetInfo: | |
features = ds.Features( | |
{ | |
"asset_id": ds.Value("int64"), | |
"kw": ds.Value("string"), | |
"lp_meta_description": ds.Value("string"), | |
"title_org": ds.Value("string"), | |
"title_ne1": ds.Value("string"), | |
"title_ne2": ds.Value("string"), | |
"title_ne3": ds.Value("string"), | |
"domain": ds.Value("string"), | |
"parsed_full_text_annotation": ds.Sequence( | |
{ | |
"text": ds.Value("string"), | |
"xmax": ds.Value("int64"), | |
"xmin": ds.Value("int64"), | |
"ymax": ds.Value("int64"), | |
"ymin": ds.Value("int64"), | |
} | |
), | |
} | |
) | |
if self.config.name == "with-lp-images": | |
features["lp_image"] = ds.Image() | |
return ds.DatasetInfo( | |
description=_DESCRIPTION, | |
citation=_CITATION, | |
homepage=_HOMEPAGE, | |
license=_LICENSE, | |
features=features, | |
) | |
def _split_generators(self, dl_manager: ds.DownloadManager): | |
base_dir = dl_manager.download_and_extract(_URLS[self.config.name]) | |
lp_image_dir: str | None = None | |
if self.config.name == "without-lp-images": | |
data_dir = f"{base_dir}/camera-v2.2-minimal" | |
elif self.config.name == "with-lp-images": | |
data_dir = f"{base_dir}/camera-v2.2" | |
lp_image_dir = f"{data_dir}/lp-screenshot" | |
else: | |
raise ValueError(f"Invalid config name: {self.config.name}") | |
return [ | |
ds.SplitGenerator( | |
name=ds.Split.TRAIN, | |
gen_kwargs={ | |
"file": f"{data_dir}/train.csv", | |
"lp_image_dir": lp_image_dir, | |
}, | |
), | |
ds.SplitGenerator( | |
name=ds.Split.VALIDATION, | |
gen_kwargs={ | |
"file": f"{data_dir}/dev.csv", | |
"lp_image_dir": lp_image_dir, | |
}, | |
), | |
ds.SplitGenerator( | |
name=ds.Split.TEST, | |
gen_kwargs={ | |
"file": f"{data_dir}/test.csv", | |
"lp_image_dir": lp_image_dir, | |
}, | |
), | |
] | |
def _generate_examples(self, file: str, lp_image_dir: str | None = None): | |
df = pd.read_csv(file) | |
for i, data_dict in enumerate(df.to_dict("records")): | |
asset_id = data_dict["asset_id"] | |
example_dict = { | |
"asset_id": asset_id, | |
"kw": data_dict["kw"], | |
"lp_meta_description": data_dict["lp_meta_description"], | |
"title_org": data_dict["title_org"], | |
"title_ne1": data_dict.get("title_ne1", ""), | |
"title_ne2": data_dict.get("title_ne2", ""), | |
"title_ne3": data_dict.get("title_ne3", ""), | |
"domain": data_dict.get("domain", ""), | |
"parsed_full_text_annotation": ast.literal_eval( | |
data_dict["parsed_full_text_annotation"] | |
), | |
} | |
if self.config.name == "with-lp-images" and lp_image_dir is not None: | |
file_name = f"screen-1200-{asset_id}.png" | |
example_dict["lp_image"] = f"{lp_image_dir}/{file_name}" | |
yield i, example_dict | |