Datasets:
Convert dataset to Parquet
#1
by
Kosuke-Yamada
- opened
README.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
---
|
2 |
-
license: cc-by-nc-sa-4.0
|
3 |
-
---
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-nc-sa-4.0
|
3 |
+
---
|
camera.py
DELETED
@@ -1,147 +0,0 @@
|
|
1 |
-
import ast
|
2 |
-
|
3 |
-
import datasets as ds
|
4 |
-
import pandas as pd
|
5 |
-
|
6 |
-
_DESCRIPTION = """\
|
7 |
-
CAMERA (CyberAgent Multimodal Evaluation for Ad Text GeneRAtion) is the Japanese ad text generation dataset.
|
8 |
-
"""
|
9 |
-
|
10 |
-
_CITATION = """\
|
11 |
-
@misc{mita2024striking,
|
12 |
-
title={Striking Gold in Advertising: Standardization and Exploration of Ad Text Generation},
|
13 |
-
author={Masato Mita and Soichiro Murakami and Akihiko Kato and Peinan Zhang},
|
14 |
-
year={2024},
|
15 |
-
eprint={2309.12030},
|
16 |
-
archivePrefix={arXiv},
|
17 |
-
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.'}
|
18 |
-
}
|
19 |
-
"""
|
20 |
-
|
21 |
-
_HOMEPAGE = "https://github.com/CyberAgentAILab/camera"
|
22 |
-
|
23 |
-
_LICENSE = """\
|
24 |
-
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
25 |
-
"""
|
26 |
-
|
27 |
-
_URLS = {
|
28 |
-
"without-lp-images": "https://storage.googleapis.com/camera-public/camera-v2.2-minimal.tar.gz",
|
29 |
-
"with-lp-images": "https://storage.googleapis.com/camera-public/camera-v2.2.tar.gz",
|
30 |
-
}
|
31 |
-
|
32 |
-
_DESCRIPTION = {
|
33 |
-
"without-lp-images": "The CAMERA dataset w/o LP images (ver.2.2.0)",
|
34 |
-
"with-lp-images": "The CAMERA dataset w/ LP images (ver.2.2.0)",
|
35 |
-
}
|
36 |
-
|
37 |
-
_VERSION = ds.Version("2.2.0", "")
|
38 |
-
|
39 |
-
|
40 |
-
class CameraConfig(ds.BuilderConfig):
|
41 |
-
def __init__(self, name: str, version: ds.Version = _VERSION, **kwargs):
|
42 |
-
super().__init__(
|
43 |
-
name=name,
|
44 |
-
description=_DESCRIPTION[name],
|
45 |
-
version=version,
|
46 |
-
**kwargs,
|
47 |
-
)
|
48 |
-
|
49 |
-
|
50 |
-
class CameraDataset(ds.GeneratorBasedBuilder):
|
51 |
-
BUILDER_CONFIGS = [CameraConfig(name="without-lp-images")]
|
52 |
-
|
53 |
-
DEFAULT_CONFIG_NAME = "without-lp-images"
|
54 |
-
|
55 |
-
def _info(self) -> ds.DatasetInfo:
|
56 |
-
features = ds.Features(
|
57 |
-
{
|
58 |
-
"asset_id": ds.Value("int64"),
|
59 |
-
"kw": ds.Value("string"),
|
60 |
-
"lp_meta_description": ds.Value("string"),
|
61 |
-
"title_org": ds.Value("string"),
|
62 |
-
"title_ne1": ds.Value("string"),
|
63 |
-
"title_ne2": ds.Value("string"),
|
64 |
-
"title_ne3": ds.Value("string"),
|
65 |
-
"domain": ds.Value("string"),
|
66 |
-
"parsed_full_text_annotation": ds.Sequence(
|
67 |
-
{
|
68 |
-
"text": ds.Value("string"),
|
69 |
-
"xmax": ds.Value("int64"),
|
70 |
-
"xmin": ds.Value("int64"),
|
71 |
-
"ymax": ds.Value("int64"),
|
72 |
-
"ymin": ds.Value("int64"),
|
73 |
-
}
|
74 |
-
),
|
75 |
-
}
|
76 |
-
)
|
77 |
-
|
78 |
-
if self.config.name == "with-lp-images":
|
79 |
-
features["lp_image"] = ds.Image()
|
80 |
-
|
81 |
-
return ds.DatasetInfo(
|
82 |
-
description=_DESCRIPTION,
|
83 |
-
citation=_CITATION,
|
84 |
-
homepage=_HOMEPAGE,
|
85 |
-
license=_LICENSE,
|
86 |
-
features=features,
|
87 |
-
)
|
88 |
-
|
89 |
-
def _split_generators(self, dl_manager: ds.DownloadManager):
|
90 |
-
base_dir = dl_manager.download_and_extract(_URLS[self.config.name])
|
91 |
-
lp_image_dir: str | None = None
|
92 |
-
|
93 |
-
if self.config.name == "without-lp-images":
|
94 |
-
data_dir = f"{base_dir}/camera-v2.2-minimal"
|
95 |
-
elif self.config.name == "with-lp-images":
|
96 |
-
data_dir = f"{base_dir}/camera-v2.2"
|
97 |
-
lp_image_dir = f"{data_dir}/lp-screenshot"
|
98 |
-
else:
|
99 |
-
raise ValueError(f"Invalid config name: {self.config.name}")
|
100 |
-
|
101 |
-
return [
|
102 |
-
ds.SplitGenerator(
|
103 |
-
name=ds.Split.TRAIN,
|
104 |
-
gen_kwargs={
|
105 |
-
"file": f"{data_dir}/train.csv",
|
106 |
-
"lp_image_dir": lp_image_dir,
|
107 |
-
},
|
108 |
-
),
|
109 |
-
ds.SplitGenerator(
|
110 |
-
name=ds.Split.VALIDATION,
|
111 |
-
gen_kwargs={
|
112 |
-
"file": f"{data_dir}/dev.csv",
|
113 |
-
"lp_image_dir": lp_image_dir,
|
114 |
-
},
|
115 |
-
),
|
116 |
-
ds.SplitGenerator(
|
117 |
-
name=ds.Split.TEST,
|
118 |
-
gen_kwargs={
|
119 |
-
"file": f"{data_dir}/test.csv",
|
120 |
-
"lp_image_dir": lp_image_dir,
|
121 |
-
},
|
122 |
-
),
|
123 |
-
]
|
124 |
-
|
125 |
-
def _generate_examples(self, file: str, lp_image_dir: str | None = None):
|
126 |
-
df = pd.read_csv(file)
|
127 |
-
for i, data_dict in enumerate(df.to_dict("records")):
|
128 |
-
asset_id = data_dict["asset_id"]
|
129 |
-
example_dict = {
|
130 |
-
"asset_id": asset_id,
|
131 |
-
"kw": data_dict["kw"],
|
132 |
-
"lp_meta_description": data_dict["lp_meta_description"],
|
133 |
-
"title_org": data_dict["title_org"],
|
134 |
-
"title_ne1": data_dict.get("title_ne1", ""),
|
135 |
-
"title_ne2": data_dict.get("title_ne2", ""),
|
136 |
-
"title_ne3": data_dict.get("title_ne3", ""),
|
137 |
-
"domain": data_dict.get("domain", ""),
|
138 |
-
"parsed_full_text_annotation": ast.literal_eval(
|
139 |
-
data_dict["parsed_full_text_annotation"]
|
140 |
-
),
|
141 |
-
}
|
142 |
-
|
143 |
-
if self.config.name == "with-lp-images" and lp_image_dir is not None:
|
144 |
-
file_name = f"screen-1200-{asset_id}.png"
|
145 |
-
example_dict["lp_image"] = f"{lp_image_dir}/{file_name}"
|
146 |
-
|
147 |
-
yield i, example_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
without-lp-images/test-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c3fd0569a4bd65396f7bee6684a8ad797f1cc7d96487e2920ed7eb12b23d4016
|
3 |
+
size 6225055
|
without-lp-images/train-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fe6dfcd5187affda84e5f311430481a2759be729132a2e3d8955cc2d58692238
|
3 |
+
size 115596015
|
without-lp-images/validation-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e08fbf4f13df83edea2e7fb6439b9ac829dbe080f200d7f132156c23f6d07f9c
|
3 |
+
size 28667944
|