Datasets:
Tasks:
Image-to-Text
Formats:
parquet
Sub-tasks:
image-captioning
Languages:
English
Size:
1M - 10M
License:
Add Google Conceptual Captions Dataset (#1459)
Browse files* Add Google Conceptual Captions Dataset
* fix
* fix
* fix
* Update README.md
* Improve script
* Generate info
* Fix dummy data
* Update card
* Minor import fix
* Minor fix in SBU Captions
* Remove extra newline
* Delete Image_Labels_Subset_Train_GCC-Labels-training.tsv%3F_ga%3D2.234395421.-20118413.1607637118
Co-authored-by: abhishek thakur <abhishekkrthakur@users.noreply.github.com>
Co-authored-by: mariosasko <mariosasko777@gmail.com>
Commit from https://github.com/huggingface/datasets/commit/8f4c95630a17cb53ac908c3b50a1c1c7ef65494e
- README.md +253 -0
- conceptual_captions.py +159 -0
- dataset_infos.json +1 -0
- dummy/labeled/1.0.0/dummy_data.zip +3 -0
- dummy/unlabeled/1.0.0/dummy_data.zip +3 -0
README.md
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- found
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- other
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 1M<n<10M
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- image-to-text
|
18 |
+
task_ids:
|
19 |
+
- image-captioning
|
20 |
+
paperswithcode_id: conceptual-captions
|
21 |
+
pretty_name: Conceptual Captions
|
22 |
+
---
|
23 |
+
|
24 |
+
# Dataset Card for Conceptual Captions
|
25 |
+
|
26 |
+
## Table of Contents
|
27 |
+
- [Dataset Description](#dataset-description)
|
28 |
+
- [Dataset Summary](#dataset-summary)
|
29 |
+
- [Dataset Preprocessing](#dataset-preprocessing)
|
30 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
31 |
+
- [Languages](#languages)
|
32 |
+
- [Dataset Structure](#dataset-structure)
|
33 |
+
- [Data Instances](#data-instances)
|
34 |
+
- [Data Fields](#data-instances)
|
35 |
+
- [Data Splits](#data-instances)
|
36 |
+
- [Dataset Creation](#dataset-creation)
|
37 |
+
- [Curation Rationale](#curation-rationale)
|
38 |
+
- [Source Data](#source-data)
|
39 |
+
- [Annotations](#annotations)
|
40 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
41 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
42 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
43 |
+
- [Discussion of Biases](#discussion-of-biases)
|
44 |
+
- [Other Known Limitations](#other-known-limitations)
|
45 |
+
- [Additional Information](#additional-information)
|
46 |
+
- [Dataset Curators](#dataset-curators)
|
47 |
+
- [Licensing Information](#licensing-information)
|
48 |
+
- [Citation Information](#citation-information)
|
49 |
+
|
50 |
+
## Dataset Description
|
51 |
+
|
52 |
+
- **Homepage:** [Conceptual Captions homepage](https://ai.google.com/research/ConceptualCaptions/)
|
53 |
+
- **Repository:** [Conceptual Captions repository](https://github.com/google-research-datasets/conceptual-captions)
|
54 |
+
- **Paper:** [Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning](https://www.aclweb.org/anthology/P18-1238/)
|
55 |
+
- **Leaderboard:** [Conceptual Captions leaderboard](https://ai.google.com/research/ConceptualCaptions/competition?active_tab=leaderboard)https://ai.google.com/research/ConceptualCaptions/leaderboard?active_tab=leaderboard
|
56 |
+
- **Point of Contact:** [Conceptual Captions e-mail](mailto:conceptual-captions@google.com)
|
57 |
+
|
58 |
+
### Dataset Summary
|
59 |
+
|
60 |
+
Conceptual Captions is a dataset consisting of ~3.3M images annotated with captions. In contrast with the curated style of other image caption annotations, Conceptual Caption images and their raw descriptions are harvested from the web, and therefore represent a wider variety of styles. More precisely, the raw descriptions are harvested from the Alt-text HTML attribute associated with web images. To arrive at the current version of the captions, we have developed an automatic pipeline that extracts, filters, and transforms candidate image/caption pairs, with the goal of achieving a balance of cleanliness, informativeness, fluency, and learnability of the resulting captions.
|
61 |
+
|
62 |
+
### Dataset Preprocessing
|
63 |
+
|
64 |
+
This dataset doesn't download the images locally by default. Instead, it exposes URLs to the images. To fetch the images, use the following code:
|
65 |
+
|
66 |
+
```python
|
67 |
+
from concurrent.futures import ThreadPoolExecutor
|
68 |
+
from functools import partial
|
69 |
+
import io
|
70 |
+
import urllib
|
71 |
+
|
72 |
+
import PIL.Image
|
73 |
+
|
74 |
+
from datasets import load_dataset
|
75 |
+
from datasets.utils.file_utils import get_datasets_user_agent
|
76 |
+
|
77 |
+
|
78 |
+
def fetch_single_image(image_url, timeout=None, retries=0):
|
79 |
+
for _ in range(retries + 1):
|
80 |
+
try:
|
81 |
+
request = urllib.request.Request(
|
82 |
+
image_url,
|
83 |
+
data=None,
|
84 |
+
headers={"user-agent": get_datasets_user_agent()},
|
85 |
+
)
|
86 |
+
with urllib.request.urlopen(request, timeout=timeout) as req:
|
87 |
+
image = PIL.Image.open(io.BytesIO(req.read()))
|
88 |
+
break
|
89 |
+
except Exception:
|
90 |
+
image = None
|
91 |
+
return image
|
92 |
+
|
93 |
+
|
94 |
+
def fetch_images(batch, num_threads, timeout=None, retries=0):
|
95 |
+
fetch_single_image_with_args = partial(fetch_single_image, timeout=timeout, retries=retries)
|
96 |
+
with ThreadPoolExecutor(max_workers=num_threads) as executor:
|
97 |
+
batch["image"] = list(executor.map(fetch_single_image_with_args, batch["image_url"]))
|
98 |
+
return batch
|
99 |
+
|
100 |
+
|
101 |
+
num_threads = 20
|
102 |
+
dset = load_dataset("conceptual_captions")
|
103 |
+
dset = dset.map(fetch_images, batched=True, batch_size=100, fn_kwargs={"num_threads": num_threads})
|
104 |
+
```
|
105 |
+
|
106 |
+
### Supported Tasks and Leaderboards
|
107 |
+
|
108 |
+
- `image-captioning`: This dataset can be used to train model for the Image Captioning task. The leaderboard for this task is available [here](https://ai.google.com/research/ConceptualCaptions/competition?active_tab=leaderboard). Official submission output captions are scored against the reference captions from the hidden test set using [this](https://github.com/tylin/coco-caption) implementation of the CIDEr (primary), ROUGE-L and SPICE metrics.
|
109 |
+
|
110 |
+
### Languages
|
111 |
+
|
112 |
+
All captions are in English.
|
113 |
+
|
114 |
+
## Dataset Structure
|
115 |
+
|
116 |
+
### Data Instances
|
117 |
+
|
118 |
+
#### `unlabeled`
|
119 |
+
|
120 |
+
Each instance in this configuration represents a single image with a caption:
|
121 |
+
|
122 |
+
```
|
123 |
+
{
|
124 |
+
'image_url': 'http://lh6.ggpht.com/-IvRtNLNcG8o/TpFyrudaT6I/AAAAAAAAM6o/_11MuAAKalQ/IMG_3422.JPG?imgmax=800',
|
125 |
+
'caption': 'a very typical bus station'
|
126 |
+
}
|
127 |
+
```
|
128 |
+
|
129 |
+
#### `labeled`
|
130 |
+
|
131 |
+
Each instance in this configuration represents a single image with a caption with addtional machine-generated image labels and confidence scores:
|
132 |
+
|
133 |
+
```
|
134 |
+
{
|
135 |
+
'image_url': 'https://thumb1.shutterstock.com/display_pic_with_logo/261388/223876810/stock-vector-christmas-tree-on-a-black-background-vector-223876810.jpg',
|
136 |
+
'caption': 'christmas tree on a black background .',
|
137 |
+
'labels': ['christmas tree', 'christmas decoration', 'font', 'text', 'graphic design', 'illustration','interior design', 'tree', 'christmas eve', 'ornament', 'fir', 'plant', 'pine', 'pine family', 'graphics'],
|
138 |
+
'MIDs': ['/m/025nd', '/m/05fc9mj', '/m/03gq5hm', '/m/07s6nbt', '/m/03c31', '/m/01kr8f', '/m/0h8nzzj', '/m/07j7r', '/m/014r1s', '/m/05ykl4', '/m/016x4z', '/m/05s2s', '/m/09t57', '/m/01tfm0', '/m/021sdg'],
|
139 |
+
'confidence_scores': [0.9818305373191833, 0.952756941318512, 0.9227379560470581, 0.8524878621101379, 0.7597672343254089, 0.7493422031402588, 0.7332468628883362, 0.6869218349456787, 0.6552258133888245, 0.6357356309890747, 0.5992692708969116, 0.585474967956543, 0.5222904086112976, 0.5113164782524109, 0.5036579966545105]
|
140 |
+
}
|
141 |
+
```
|
142 |
+
|
143 |
+
### Data Fields
|
144 |
+
|
145 |
+
#### `unlabeled`
|
146 |
+
|
147 |
+
- `image_url`: Static URL for downloading the image associated with the post.
|
148 |
+
- `caption`: Textual description of the image.
|
149 |
+
|
150 |
+
#### `labeled`
|
151 |
+
|
152 |
+
- `image_url`: Static URL for downloading the image associated with the post.
|
153 |
+
- `caption`: Textual description of the image.
|
154 |
+
- `labels`: A sequence of machine-generated labels obtained using the [Google Cloud Vision API](https://cloud.google.com/vision).
|
155 |
+
- `MIDs`: A sequence of machine-generated identifiers (MID) corresponding to the label's Google Knowledge Graph entry.
|
156 |
+
- `confidence_scores`: A sequence of confidence scores denoting how likely the corresponing labels are present on the image.
|
157 |
+
|
158 |
+
### Data Splits
|
159 |
+
|
160 |
+
#### `unlabeled`
|
161 |
+
|
162 |
+
The basic version of the dataset split into Training and Validation splits. The Training split consists of 3,318,333 image-URL/caption pairs and the Validation split consists of 15,840 image-URL/caption pairs.
|
163 |
+
|
164 |
+
#### `labeled`
|
165 |
+
|
166 |
+
The labeled version of the dataset with a single. The entire data is contained in Training split, which is a subset of 2,007,090 image-URL/caption pairs from the Training set of the `unlabeled` config.
|
167 |
+
|
168 |
+
## Dataset Creation
|
169 |
+
|
170 |
+
### Curation Rationale
|
171 |
+
|
172 |
+
From the paper:
|
173 |
+
> In this paper, we make contributions to both the data and modeling categories. First, we present a new dataset of caption annotations Conceptual Captions (Fig. 1), which has an order of magnitude more images than the COCO dataset. Conceptual Captions consists of about 3.3M himage, descriptioni pairs. In contrast with the curated style of the COCO images, Conceptual Captions images and their raw descriptions are harvested from the web, and therefore represent a wider variety of styles.
|
174 |
+
|
175 |
+
### Source Data
|
176 |
+
|
177 |
+
#### Initial Data Collection and Normalization
|
178 |
+
|
179 |
+
From the homepage:
|
180 |
+
>For Conceptual Captions, we developed a fully automatic pipeline that extracts, filters, and transforms >candidate image/caption pairs, with the goal of achieving a balance of cleanliness, informativeness, fluency, >and learnability of the resulting captions. Because no human annotators are involved, the Conceptual Captions >dataset generation process is highly scalable.
|
181 |
+
>
|
182 |
+
>To generate this dataset, we started with a Flume pipeline that processes billions of Internet webpages, >extracting, filtering, and processing candidate image and caption pairs, and keeping those that pass through >several filters.
|
183 |
+
>
|
184 |
+
>We first screen for certain properties like size, aspect ratio, adult content scores. These filters discard >more than 65% of the candidates. Next, we use Alt-Texts for text-based filtering, removing captions with >non-descriptive text (such as SEO tags or hashtags); we also discard texts with high sentiment polarity or >adult content scores, resulting in just 3% of the incoming candidates passing through.
|
185 |
+
>
|
186 |
+
>In the next step, we filter out candidates for which none of the text tokens can be mapped to the visual >content of the image. We use image classifiers (e.g., Google Cloud Vision APIs) to assign class labels to >images and match these labels against the candidate text (allowing morphological transformations), discarding >around 60% of the candidates that reach this stage.
|
187 |
+
>
|
188 |
+
>The candidates passing the above filters tend to be good Alt-text image descriptions. However, a large >majority of these use proper names (for people, venues, locations, etc.), brands, dates, quotes, etc. This >creates two distinct problems. First, some of these cannot be inferred based on the image pixels alone. This >is problematic because unless the image has the necessary visual information it is not useful for training. >Second, even if the proper names could be inferred from the image it is extremely difficult for a model to >learn to perform both fine-grained classification and natural-language descriptions simultaneously. We posit >that if automatic determination of names, locations, brands, etc. is needed, it should be done as a separate >task that may leverage image meta-information (e.g. GPS info), or complementary techniques such as OCR.
|
189 |
+
>
|
190 |
+
>We address the above problems with the insight that proper names should be replaced by words that represent >the same general notion, i.e., by their concept. For example, we remove locations (“Crowd at a concert in Los >Angeles“ becomes “Crowd at a concert”), names (e.g., “Former Miss World Priyanka Chopra on the red carpet” >becomes “actor on the red carpet”), proper noun modifiers (e.g., “Italian cuisine” becomes just “cuisine”) >and noun phrases (e.g., “actor and actor” becomes “actors”). Around 20% of the samples are discarded during >this transformation because it can leave sentences too short, or otherwise inconsistent.
|
191 |
+
>
|
192 |
+
>Finally, we perform another round of filtering to identify concepts with low-count. We cluster all resolved >entities (e.g., “actor”, “dog”, “neighborhood”, etc.) and keep only the candidate types which have a count of >over 100 mentions. This retains around 16K entity concepts such as: “person”, “actor”, “artist”, “player” and >“illustration”. The less frequent ones that we dropped include “baguette”, “bridle”, “deadline”, “ministry” >and “funnel”.
|
193 |
+
|
194 |
+
#### Who are the source language producers?
|
195 |
+
|
196 |
+
Not specified.
|
197 |
+
|
198 |
+
### Annotations
|
199 |
+
|
200 |
+
#### Annotation process
|
201 |
+
|
202 |
+
Annotations are extracted jointly with the images using the automatic pipeline.
|
203 |
+
|
204 |
+
#### Who are the annotators?
|
205 |
+
|
206 |
+
Not specified.
|
207 |
+
|
208 |
+
### Personal and Sensitive Information
|
209 |
+
|
210 |
+
[More Information Needed]
|
211 |
+
|
212 |
+
## Considerations for Using the Data
|
213 |
+
|
214 |
+
### Social Impact of Dataset
|
215 |
+
|
216 |
+
[More Information Needed]
|
217 |
+
|
218 |
+
### Discussion of Biases
|
219 |
+
|
220 |
+
[More Information Needed]
|
221 |
+
|
222 |
+
### Other Known Limitations
|
223 |
+
|
224 |
+
[More Information Needed]
|
225 |
+
|
226 |
+
## Additional Information
|
227 |
+
|
228 |
+
### Dataset Curators
|
229 |
+
|
230 |
+
Piyush Sharma, Nan Ding, Sebastian Goodman and Radu Soricut.
|
231 |
+
|
232 |
+
### Licensing Information
|
233 |
+
|
234 |
+
The dataset may be freely used for any purpose, although acknowledgement of
|
235 |
+
Google LLC ("Google") as the data source would be appreciated. The dataset is
|
236 |
+
provided "AS IS" without any warranty, express or implied. Google disclaims all
|
237 |
+
liability for any damages, direct or indirect, resulting from the use of the
|
238 |
+
dataset.
|
239 |
+
|
240 |
+
### Citation Information
|
241 |
+
|
242 |
+
```bibtex
|
243 |
+
@inproceedings{sharma2018conceptual,
|
244 |
+
title = {Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning},
|
245 |
+
author = {Sharma, Piyush and Ding, Nan and Goodman, Sebastian and Soricut, Radu},
|
246 |
+
booktitle = {Proceedings of ACL},
|
247 |
+
year = {2018},
|
248 |
+
}
|
249 |
+
```
|
250 |
+
|
251 |
+
### Contributions
|
252 |
+
|
253 |
+
Thanks to [@abhishekkrthakur](https://github.com/abhishekkrthakur) and [@mariosasko](https://github.com/mariosasko) for adding this dataset.
|
conceptual_captions.py
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""Conceptual Captions dataset."""
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import textwrap
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
Google's Conceptual Captions dataset has more than 3 million images, paired with natural-language captions.
|
27 |
+
In contrast with the curated style of the MS-COCO images, Conceptual Captions images and their raw descriptions are harvested from the web,
|
28 |
+
and therefore represent a wider variety of styles. The raw descriptions are harvested from the Alt-text HTML attribute associated with web images.
|
29 |
+
The authors developed an automatic pipeline that extracts, filters, and transforms candidate image/caption pairs, with the goal of achieving a balance of cleanliness,
|
30 |
+
informativeness, fluency, and learnability of the resulting captions.
|
31 |
+
"""
|
32 |
+
|
33 |
+
_HOMEPAGE = "http://data.statmt.org/cc-100/"
|
34 |
+
|
35 |
+
_LICENSE = """\
|
36 |
+
The dataset may be freely used for any purpose, although acknowledgement of
|
37 |
+
Google LLC ("Google") as the data source would be appreciated. The dataset is
|
38 |
+
provided "AS IS" without any warranty, express or implied. Google disclaims all
|
39 |
+
liability for any damages, direct or indirect, resulting from the use of the
|
40 |
+
dataset.
|
41 |
+
"""
|
42 |
+
|
43 |
+
_CITATION = """\
|
44 |
+
@inproceedings{sharma2018conceptual,
|
45 |
+
title = {Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning},
|
46 |
+
author = {Sharma, Piyush and Ding, Nan and Goodman, Sebastian and Soricut, Radu},
|
47 |
+
booktitle = {Proceedings of ACL},
|
48 |
+
year = {2018},
|
49 |
+
}
|
50 |
+
"""
|
51 |
+
|
52 |
+
_URLS = {
|
53 |
+
"unlabeled": {
|
54 |
+
"train": "https://storage.googleapis.com/gcc-data/Train/GCC-training.tsv?_ga=2.191230122.-1896153081.1529438250",
|
55 |
+
"validation": "https://storage.googleapis.com/gcc-data/Validation/GCC-1.1.0-Validation.tsv?_ga=2.141047602.-1896153081.1529438250",
|
56 |
+
},
|
57 |
+
"labeled": {
|
58 |
+
"train": "https://storage.googleapis.com/conceptual-captions-v1-1-labels/Image_Labels_Subset_Train_GCC-Labels-training.tsv?_ga=2.234395421.-20118413.1607637118",
|
59 |
+
},
|
60 |
+
}
|
61 |
+
|
62 |
+
_DESCRIPTIONS = {
|
63 |
+
"unlabeled": textwrap.dedent(
|
64 |
+
"""\
|
65 |
+
The basic version of the dataset split into Training, Validation, and Test splits.
|
66 |
+
The Training split consists of 3,318,333 image-URL/caption pairs, with a total number of 51,201 total token types in the captions (i.e., total vocabulary).
|
67 |
+
The average number of tokens per captions is 10.3 (standard deviation of 4.5), while the median is 9.0 tokens per caption.
|
68 |
+
The Validation split consists of 15,840 image-URL/caption pairs, with similar statistics.
|
69 |
+
"""
|
70 |
+
),
|
71 |
+
"labeled": textwrap.dedent(
|
72 |
+
"""\
|
73 |
+
A subset of 2,007,090 image-URL/caption pairs from the training set with machine-generated image labels.
|
74 |
+
The image labels are obtained using the Google Cloud Vision API.
|
75 |
+
Each image label has a machine-generated identifier (MID) corresponding to the label's Google Knowledge Graph entry and a confidence score for its presence in the image.
|
76 |
+
|
77 |
+
Note: 2,007,528 is the number of image-URL/caption pairs specified by the authors, but some rows are missing labels, so they are not included.
|
78 |
+
"""
|
79 |
+
),
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
class ConceptualCaptions(datasets.GeneratorBasedBuilder):
|
84 |
+
"""Builder for Conceptual Captions dataset."""
|
85 |
+
|
86 |
+
VERSION = datasets.Version("1.0.0")
|
87 |
+
|
88 |
+
BUILDER_CONFIGS = [
|
89 |
+
datasets.BuilderConfig("unlabeled", version=VERSION, description=_DESCRIPTIONS["unlabeled"]),
|
90 |
+
datasets.BuilderConfig("labeled", version=VERSION, description=_DESCRIPTIONS["labeled"]),
|
91 |
+
]
|
92 |
+
|
93 |
+
DEFAULT_CONFIG_NAME = "unlabeled"
|
94 |
+
|
95 |
+
def _info(self):
|
96 |
+
features = datasets.Features(
|
97 |
+
{
|
98 |
+
"image_url": datasets.Value("string"),
|
99 |
+
"caption": datasets.Value("string"),
|
100 |
+
},
|
101 |
+
)
|
102 |
+
if self.config.name == "labeled":
|
103 |
+
features.update(
|
104 |
+
{
|
105 |
+
"labels": datasets.Sequence(datasets.Value("string")),
|
106 |
+
"MIDs": datasets.Sequence(datasets.Value("string")),
|
107 |
+
"confidence_scores": datasets.Sequence(datasets.Value("float64")),
|
108 |
+
}
|
109 |
+
)
|
110 |
+
return datasets.DatasetInfo(
|
111 |
+
description=_DESCRIPTION,
|
112 |
+
features=features,
|
113 |
+
supervised_keys=None,
|
114 |
+
homepage=_HOMEPAGE,
|
115 |
+
license=_LICENSE,
|
116 |
+
citation=_CITATION,
|
117 |
+
)
|
118 |
+
|
119 |
+
def _split_generators(self, dl_manager):
|
120 |
+
downloaded_data = dl_manager.download(_URLS[self.config.name])
|
121 |
+
splits = [
|
122 |
+
datasets.SplitGenerator(
|
123 |
+
name=datasets.Split.TRAIN,
|
124 |
+
gen_kwargs={"annotations_file": downloaded_data["train"]},
|
125 |
+
),
|
126 |
+
]
|
127 |
+
if self.config.name == "unlabeled":
|
128 |
+
splits += [
|
129 |
+
datasets.SplitGenerator(
|
130 |
+
name=datasets.Split.VALIDATION,
|
131 |
+
gen_kwargs={"annotations_file": downloaded_data["validation"]},
|
132 |
+
),
|
133 |
+
]
|
134 |
+
return splits
|
135 |
+
|
136 |
+
def _generate_examples(self, annotations_file):
|
137 |
+
if self.config.name == "unlabeled":
|
138 |
+
with open(annotations_file, encoding="utf-8") as f:
|
139 |
+
for i, row in enumerate(csv.reader(f, delimiter="\t")):
|
140 |
+
# Sanity check
|
141 |
+
assert len(row) == 2
|
142 |
+
caption, image_url = row
|
143 |
+
yield i, {
|
144 |
+
"image_url": image_url,
|
145 |
+
"caption": caption,
|
146 |
+
},
|
147 |
+
else:
|
148 |
+
with open(annotations_file, encoding="utf-8") as f:
|
149 |
+
for i, row in enumerate(csv.reader(f, delimiter="\t")):
|
150 |
+
caption, image_url, labels, MIDs, confidence_scores = row
|
151 |
+
if not labels:
|
152 |
+
continue
|
153 |
+
yield i, {
|
154 |
+
"image_url": image_url,
|
155 |
+
"caption": caption,
|
156 |
+
"labels": labels.split(","),
|
157 |
+
"MIDs": MIDs.split(","),
|
158 |
+
"confidence_scores": [float(x) for x in confidence_scores.split(",")],
|
159 |
+
},
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "Image captioning dataset\nThe resulting dataset (version 1.1) has been split into Training, Validation, and Test splits. The Training split consists of 3,318,333 image-URL/caption pairs, with a total number of 51,201 total token types in the captions (i.e., total vocabulary). The average number of tokens per captions is 10.3 (standard deviation of 4.5), while the median is 9.0 tokens per caption. The Validation split consists of 15,840 image-URL/caption pairs, with similar statistics.\n", "citation": "@inproceedings{sharma-etal-2018-conceptual,\n title = \"Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning\",\n author = \"Sharma, Piyush and\n Ding, Nan and\n Goodman, Sebastian and\n Soricut, Radu\",\n booktitle = \"Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)\",\n month = jul,\n year = \"2018\",\n address = \"Melbourne, Australia\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/P18-1238\",\n doi = \"10.18653/v1/P18-1238\",\n pages = \"2556--2565\",\n abstract = \"We present a new dataset of image caption annotations, Conceptual Captions, which contains an order of magnitude more images than the MS-COCO dataset (Lin et al., 2014) and represents a wider variety of both images and image caption styles. We achieve this by extracting and filtering image caption annotations from billions of webpages. We also present quantitative evaluations of a number of image captioning models and show that a model architecture based on Inception-ResNetv2 (Szegedy et al., 2016) for image-feature extraction and Transformer (Vaswani et al., 2017) for sequence modeling achieves the best performance when trained on the Conceptual Captions dataset.\",\n}\n", "homepage": "http://data.statmt.org/cc-100/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "caption": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "conceptual_captions", "config_name": "default", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 623230370, "num_examples": 3318333, "dataset_name": "conceptual_captions"}, "validation": {"name": "validation", "num_bytes": 2846024, "num_examples": 15840, "dataset_name": "conceptual_captions"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 626076394, "size_in_bytes": 626076394}, "unlabeled": {"description": "Google's Conceptual Captions dataset has more than 3 million images, paired with natural-language captions.\nIn contrast with the curated style of the MS-COCO images, Conceptual Captions images and their raw descriptions are harvested from the web,\nand therefore represent a wider variety of styles. The raw descriptions are harvested from the Alt-text HTML attribute associated with web images.\nThe authors developed an automatic pipeline that extracts, filters, and transforms candidate image/caption pairs, with the goal of achieving a balance of cleanliness,\ninformativeness, fluency, and learnability of the resulting captions.\n", "citation": "@inproceedings{sharma2018conceptual,\n title = {Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning},\n author = {Sharma, Piyush and Ding, Nan and Goodman, Sebastian and Soricut, Radu},\n booktitle = {Proceedings of ACL},\n year = {2018},\n}\n", "homepage": "http://data.statmt.org/cc-100/", "license": "The dataset may be freely used for any purpose, although acknowledgement of\nGoogle LLC (\"Google\") as the data source would be appreciated. The dataset is\nprovided \"AS IS\" without any warranty, express or implied. Google disclaims all\nliability for any damages, direct or indirect, resulting from the use of the\ndataset.\n", "features": {"image_url": {"dtype": "string", "id": null, "_type": "Value"}, "caption": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "conceptual_captions", "config_name": "unlabeled", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 584520156, "num_examples": 3318333, "dataset_name": "conceptual_captions"}, "validation": {"name": "validation", "num_bytes": 2698726, "num_examples": 15840, "dataset_name": "conceptual_captions"}}, "download_checksums": {"https://storage.googleapis.com/gcc-data/Train/GCC-training.tsv?_ga=2.191230122.-1896153081.1529438250": {"num_bytes": 564607502, "checksum": "eab84e5ebc713a41a6b1f6ae6fa3d6617821a13b03fe24e16004cc4aac189635"}, "https://storage.googleapis.com/gcc-data/Validation/GCC-1.1.0-Validation.tsv?_ga=2.141047602.-1896153081.1529438250": {"num_bytes": 2603670, "checksum": "528a0c939ec2ad8d1740bd3f459a51e9fe67643050e29f68fabb6da3f8ac985d"}}, "download_size": 567211172, "post_processing_size": null, "dataset_size": 587218882, "size_in_bytes": 1154430054}, "labeled": {"description": "Google's Conceptual Captions dataset has more than 3 million images, paired with natural-language captions.\nIn contrast with the curated style of the MS-COCO images, Conceptual Captions images and their raw descriptions are harvested from the web,\nand therefore represent a wider variety of styles. The raw descriptions are harvested from the Alt-text HTML attribute associated with web images.\nThe authors developed an automatic pipeline that extracts, filters, and transforms candidate image/caption pairs, with the goal of achieving a balance of cleanliness,\ninformativeness, fluency, and learnability of the resulting captions.\n", "citation": "@inproceedings{sharma2018conceptual,\n title = {Conceptual Captions: A Cleaned, Hypernymed, Image Alt-text Dataset For Automatic Image Captioning},\n author = {Sharma, Piyush and Ding, Nan and Goodman, Sebastian and Soricut, Radu},\n booktitle = {Proceedings of ACL},\n year = {2018},\n}\n", "homepage": "http://data.statmt.org/cc-100/", "license": "The dataset may be freely used for any purpose, although acknowledgement of\nGoogle LLC (\"Google\") as the data source would be appreciated. The dataset is\nprovided \"AS IS\" without any warranty, express or implied. Google disclaims all\nliability for any damages, direct or indirect, resulting from the use of the\ndataset.\n", "features": {"image_url": {"dtype": "string", "id": null, "_type": "Value"}, "caption": {"dtype": "string", "id": null, "_type": "Value"}, "labels": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "MIDs": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "confidence_scores": {"feature": {"dtype": "float64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "conceptual_captions", "config_name": "labeled", "version": "0.0.0", "splits": {"train": {"name": "train", "num_bytes": 1199330856, "num_examples": 2007090, "dataset_name": "conceptual_captions"}}, "download_checksums": {"https://storage.googleapis.com/conceptual-captions-v1-1-labels/Image_Labels_Subset_Train_GCC-Labels-training.tsv?_ga=2.234395421.-20118413.1607637118": {"num_bytes": 1282463277, "checksum": "d63f475306f376e4df2d365003f321468032278cd241d4c9eefc3c3e232baa38"}}, "download_size": 1282463277, "post_processing_size": null, "dataset_size": 1199330856, "size_in_bytes": 2481794133}}
|
dummy/labeled/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9eded5d20cbce8727de578749cb76daa40e2bd8e4cbb95794526fcc310685c61
|
3 |
+
size 3891
|
dummy/unlabeled/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3d2daf61b889c802e0dc876bc55e9a09fa56a857dd29c119919bdb9c0af7b719
|
3 |
+
size 1661
|