Yanpeng Yuan commited on
Commit
7debf8d
1 Parent(s): 0a3322f
Files changed (2) hide show
  1. README.md +143 -0
  2. zhlds.py +171 -0
README.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators: []
3
+ language:
4
+ - en
5
+ language_creators: []
6
+ license:
7
+ - other
8
+ multilinguality: []
9
+ pretty_name: This is a test version for ELEVATER benchmark.
10
+ size_categories:
11
+ - 10M<n<100M
12
+ source_datasets:
13
+ - original
14
+ tags: []
15
+ task_categories:
16
+ - image-classification
17
+ - object-detection
18
+ task_ids:
19
+ - multi-class-image-classification
20
+ ---
21
+
22
+ # Dataset Card for [Dataset Name]
23
+
24
+ ## Table of Contents
25
+ - [Table of Contents](#table-of-contents)
26
+ - [Dataset Description](#dataset-description)
27
+ - [Dataset Summary](#dataset-summary)
28
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
29
+ - [Languages](#languages)
30
+ - [Dataset Structure](#dataset-structure)
31
+ - [Data Instances](#data-instances)
32
+ - [Data Fields](#data-fields)
33
+ - [Data Splits](#data-splits)
34
+ - [Dataset Creation](#dataset-creation)
35
+ - [Curation Rationale](#curation-rationale)
36
+ - [Source Data](#source-data)
37
+ - [Annotations](#annotations)
38
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
39
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
40
+ - [Social Impact of Dataset](#social-impact-of-dataset)
41
+ - [Discussion of Biases](#discussion-of-biases)
42
+ - [Other Known Limitations](#other-known-limitations)
43
+ - [Additional Information](#additional-information)
44
+ - [Dataset Curators](#dataset-curators)
45
+ - [Licensing Information](#licensing-information)
46
+ - [Citation Information](#citation-information)
47
+ - [Contributions](#contributions)
48
+
49
+ ## Dataset Description
50
+
51
+ - **Homepage:**
52
+ - **Repository:**
53
+ - **Paper:**
54
+ - **Leaderboard:**
55
+ - **Point of Contact:**
56
+
57
+ ### Dataset Summary
58
+
59
+ [More Information Needed]
60
+
61
+ ### Supported Tasks and Leaderboards
62
+
63
+ [More Information Needed]
64
+
65
+ ### Languages
66
+
67
+ [More Information Needed]
68
+
69
+ ## Dataset Structure
70
+
71
+ ### Data Instances
72
+
73
+ [More Information Needed]
74
+
75
+ ### Data Fields
76
+
77
+ [More Information Needed]
78
+
79
+ ### Data Splits
80
+
81
+ [More Information Needed]
82
+
83
+ ## Dataset Creation
84
+
85
+ ### Curation Rationale
86
+
87
+ [More Information Needed]
88
+
89
+ ### Source Data
90
+
91
+ #### Initial Data Collection and Normalization
92
+
93
+ [More Information Needed]
94
+
95
+ #### Who are the source language producers?
96
+
97
+ [More Information Needed]
98
+
99
+ ### Annotations
100
+
101
+ #### Annotation process
102
+
103
+ [More Information Needed]
104
+
105
+ #### Who are the annotators?
106
+
107
+ [More Information Needed]
108
+
109
+ ### Personal and Sensitive Information
110
+
111
+ [More Information Needed]
112
+
113
+ ## Considerations for Using the Data
114
+
115
+ ### Social Impact of Dataset
116
+
117
+ [More Information Needed]
118
+
119
+ ### Discussion of Biases
120
+
121
+ [More Information Needed]
122
+
123
+ ### Other Known Limitations
124
+
125
+ [More Information Needed]
126
+
127
+ ## Additional Information
128
+
129
+ ### Dataset Curators
130
+
131
+ [More Information Needed]
132
+
133
+ ### Licensing Information
134
+
135
+ [More Information Needed]
136
+
137
+ ### Citation Information
138
+
139
+ [More Information Needed]
140
+
141
+ ### Contributions
142
+
143
+ Thanks to [@github-username](https://github.com/<github-username>) for adding this dataset.
zhlds.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the 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
+ """The ELEVATER benchmark"""
18
+
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+ from zipfile import ZipFile
25
+ from io import BytesIO
26
+ from PIL import Image
27
+
28
+ _ELEVATER_CITATION = """\
29
+ @article{li2022elevater,
30
+ title={ELEVATER: A Benchmark and Toolkit for Evaluating Language-Augmented Visual Models},
31
+ author={Li, Chunyuan and Liu, Haotian and Li, Liunian Harold and Zhang, Pengchuan and Aneja, Jyoti and Yang, Jianwei and Jin, Ping and Lee, Yong Jae and Hu, Houdong and Liu, Zicheng and Gao, Jianfeng},
32
+ journal={Neural Information Processing Systems},
33
+ year={2022}
34
+ }
35
+
36
+ Note that each ELEVATER dataset has its own citation. Please see the source to
37
+ get the correct citation for each contained dataset.
38
+ """
39
+
40
+ _CIFAR_10_DESCRIPTION="""\
41
+ The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images."""
42
+
43
+ _CIFAR_10_CITATION="""\
44
+ @article{krizhevsky2009learning,
45
+ title={Learning multiple layers of features from tiny images},
46
+ author={Krizhevsky, Alex and Hinton, Geoffrey and others},
47
+ year={2009},
48
+ publisher={Toronto, ON, Canada}
49
+ }"""
50
+
51
+ class ELEVATERConfig(datasets.BuilderConfig):
52
+
53
+ """BuilderConfig for ELEVATER."""
54
+ print(f"zhlds/zhlds.py, line 50")
55
+ def __init__(self, name, description, contact, version, type_, root_folder, labelmap, num_classes, train, test, citation, url, **kwargs):
56
+ """BuilderConfig for ELEVATER.
57
+ Args:
58
+ features: `list[string]`, list of the features that will appear in the
59
+ feature dict. Should not include "label".
60
+ data_url: `string`, url to download the zip file from.
61
+ citation: `string`, citation for the data set.
62
+ url: `string`, url for information about the data set.
63
+ label_classes: `list[string]`, the list of classes for the label if the
64
+ label is present as a string. Non-string labels will be cast to either
65
+ 'False' or 'True'.
66
+ **kwargs: keyword arguments forwarded to super.
67
+ """
68
+ super(ELEVATERConfig, self).__init__(**kwargs)
69
+ self.name = name
70
+ self.description = description
71
+ self.contact = contact
72
+ self.version = version
73
+ self.type = type_
74
+ self.root_folder = root_folder
75
+ self.labelmap = labelmap
76
+ self.num_classes = num_classes
77
+ self.train = train
78
+ self.test = test
79
+ self.citation = citation
80
+ self.url = url
81
+
82
+
83
+ class ELEVATER(datasets.GeneratorBasedBuilder):
84
+
85
+ BUILDER_CONFIGS = [
86
+ ELEVATERConfig(
87
+ name="cifar-10",
88
+ description="The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images.",
89
+ contact="pinjin",
90
+ version="1.0.0",
91
+ type_="classification_multiclass",
92
+ root_folder="classification/cifar_10_20211007",
93
+ labelmap="labels.txt",
94
+ num_classes=10,
95
+ train={
96
+ "index_path": "train.txt",
97
+ "files_for_local_usage": ["train.zip"],
98
+ "num_images": 50000
99
+ },
100
+ test={
101
+ "index_path": "test.txt",
102
+ "files_for_local_usage": ["val.zip"],
103
+ "num_images": 10000
104
+ },
105
+ citation=_CIFAR_10_CITATION,
106
+ url="https://cvinthewildeus.blob.core.windows.net/datasets/",
107
+ ),
108
+ ]
109
+
110
+ def _info(self):
111
+ features = datasets.Features(
112
+ {
113
+ "image_file_path": datasets.Value("string"),
114
+ "image": datasets.Image(),
115
+ "labels": datasets.Value("int32")
116
+ }
117
+ )
118
+ return datasets.DatasetInfo(
119
+ description=self.config.description,
120
+ features=features,
121
+ citation=self.config.citation + '\n' + _ELEVATER_CITATION,
122
+ )
123
+
124
+ def _split_generators(self, dl_manager):
125
+ _URL = self.config.url + self.config.root_folder
126
+ urls_to_download = {
127
+ "labelmap": os.path.join(_URL, self.config.labelmap),
128
+ "train": {
129
+ "images": os.path.join(_URL, self.config.train['files_for_local_usage'][0]),
130
+ "index": os.path.join(_URL, self.config.train['index_path']),
131
+ },
132
+ "test": {
133
+ "images": os.path.join(_URL, self.config.test['files_for_local_usage'][0]),
134
+ "index": os.path.join(_URL, self.config.test['index_path']),
135
+ }
136
+ }
137
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
138
+
139
+ return [
140
+ datasets.SplitGenerator(
141
+ name=datasets.Split.TRAIN,
142
+ gen_kwargs={
143
+ "images": downloaded_files["train"]["images"],
144
+ "index": downloaded_files["train"]["index"],
145
+ "split": datasets.Split.TRAIN,
146
+ },
147
+ ),
148
+ datasets.SplitGenerator(
149
+ name=datasets.Split.TEST,
150
+ gen_kwargs={
151
+ "images": downloaded_files["test"]["images"],
152
+ "index": downloaded_files["test"]["index"],
153
+ "split": datasets.Split.TEST,
154
+ },
155
+ )
156
+ ]
157
+
158
+ def _generate_examples(self, images, index, split):
159
+ image_path_label_list = []
160
+ with open(index, "r") as f:
161
+ lines = f.readlines()
162
+ for i, line in enumerate(lines):
163
+ line_split = line[:-1].split(" ")
164
+ label = int(line_split[1])
165
+ image_path = line_split[0].split('@')[1]
166
+ path = images + '/' + image_path
167
+ yield i, {
168
+ "image_file_path": path,
169
+ "image": path,
170
+ "labels": label,
171
+ }