Working clevr
Browse files- README.md +15 -0
- clevr.py +114 -0
- dataset_infos.json +1 -0
README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Checks with https://visualqa.org/download.html:
|
| 2 |
+
- Num train questions: 443,757
|
| 3 |
+
- Num val questions: 214,354
|
| 4 |
+
- Num test questions: 447,793
|
| 5 |
+
|
| 6 |
+
- Num train answers: 4,437,570
|
| 7 |
+
- Num val answers: 2,143,540
|
| 8 |
+
|
| 9 |
+
- Num train images: 82,783
|
| 10 |
+
- Num val images: 40,504
|
| 11 |
+
- Num test images: 81,434
|
| 12 |
+
|
| 13 |
+
testdev is not mentionned:
|
| 14 |
+
- Num questions: 107,394
|
| 15 |
+
- Num images: 36,807
|
clevr.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 The HuggingFace Datasets Authors.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""VQA v2 loading script."""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
import json
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_CITATION = """\
|
| 23 |
+
@inproceedings{johnson2017clevr,
|
| 24 |
+
title={Clevr: A diagnostic dataset for compositional language and elementary visual reasoning},
|
| 25 |
+
author={Johnson, Justin and Hariharan, Bharath and Van Der Maaten, Laurens and Fei-Fei, Li and Lawrence Zitnick, C and Girshick, Ross},
|
| 26 |
+
booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},
|
| 27 |
+
pages={2901--2910},
|
| 28 |
+
year={2017}
|
| 29 |
+
}
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
_DESCRIPTION = """\
|
| 33 |
+
CLEVR is a diagnostic dataset that tests a range of visual reasoning abilities. It contains minimal biases and has detailed annotations describing the kind of reasoning each question requires. We use this dataset to analyze a variety of modern visual reasoning systems, providing novel insights into their abilities and limitations.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
_HOMEPAGE = "https://cs.stanford.edu/people/jcjohns/clevr/"
|
| 37 |
+
|
| 38 |
+
_LICENSE = "CC BY 4.0" # TODO need to credit both ms coco and vqa authors!
|
| 39 |
+
|
| 40 |
+
_URLS = "https://dl.fbaipublicfiles.com/clevr/CLEVR_v1.0.zip"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class ClevrDataset(datasets.GeneratorBasedBuilder):
|
| 44 |
+
|
| 45 |
+
VERSION = datasets.Version("1.0.0")
|
| 46 |
+
|
| 47 |
+
def _info(self):
|
| 48 |
+
features = datasets.Features(
|
| 49 |
+
{
|
| 50 |
+
"question_index": datasets.Value("int64"),
|
| 51 |
+
"question_family_index": datasets.Value("int64"),
|
| 52 |
+
"image_filename": datasets.Value("string"),
|
| 53 |
+
"split": datasets.Value("string"),
|
| 54 |
+
"question": datasets.Value("string"),
|
| 55 |
+
"answer": datasets.Value("string"),
|
| 56 |
+
"image": datasets.Image(),
|
| 57 |
+
"image_index": datasets.Value("int64"),
|
| 58 |
+
"program": datasets.Sequence({
|
| 59 |
+
"inputs": datasets.Sequence(datasets.Value("int64")),
|
| 60 |
+
"function": datasets.Value("string"),
|
| 61 |
+
"value_inputs": datasets.Sequence(datasets.Value("string")),
|
| 62 |
+
}),
|
| 63 |
+
}
|
| 64 |
+
)
|
| 65 |
+
return datasets.DatasetInfo(
|
| 66 |
+
description=_DESCRIPTION,
|
| 67 |
+
features=features,
|
| 68 |
+
homepage=_HOMEPAGE,
|
| 69 |
+
license=_LICENSE,
|
| 70 |
+
citation=_CITATION,
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
def _split_generators(self, dl_manager):
|
| 74 |
+
data_dir = dl_manager.download_and_extract(_URLS)
|
| 75 |
+
gen_kwargs = {
|
| 76 |
+
split_name: {
|
| 77 |
+
"split": split_name,
|
| 78 |
+
"questions_path": Path(data_dir) / "CLEVR_v1.0" / "questions" / f"CLEVR_{split_name}_questions.json",
|
| 79 |
+
"image_folder": Path(data_dir) / "CLEVR_v1.0" / "images" / f"{split_name}",
|
| 80 |
+
}
|
| 81 |
+
for split_name in ["train", "val", "test"]
|
| 82 |
+
}
|
| 83 |
+
return [
|
| 84 |
+
datasets.SplitGenerator(
|
| 85 |
+
name=datasets.Split.TRAIN,
|
| 86 |
+
gen_kwargs=gen_kwargs["train"],
|
| 87 |
+
),
|
| 88 |
+
datasets.SplitGenerator(
|
| 89 |
+
name=datasets.Split.VALIDATION,
|
| 90 |
+
gen_kwargs=gen_kwargs["val"],
|
| 91 |
+
),
|
| 92 |
+
datasets.SplitGenerator(
|
| 93 |
+
name=datasets.Split.TEST,
|
| 94 |
+
gen_kwargs=gen_kwargs["test"],
|
| 95 |
+
),
|
| 96 |
+
]
|
| 97 |
+
|
| 98 |
+
def _generate_examples(self, split, questions_path, image_folder):
|
| 99 |
+
questions = json.load(open(questions_path, "r"))
|
| 100 |
+
|
| 101 |
+
for idx, question in enumerate(questions["questions"]):
|
| 102 |
+
question["image"] = str(image_folder / f"{question['image_filename']}")
|
| 103 |
+
if split == "test":
|
| 104 |
+
question["question_family_index"] = -1
|
| 105 |
+
question["answer"] = ""
|
| 106 |
+
question["program"] = [
|
| 107 |
+
{
|
| 108 |
+
"inputs": [],
|
| 109 |
+
"function": "scene",
|
| 110 |
+
"value_inputs": [],
|
| 111 |
+
}
|
| 112 |
+
]
|
| 113 |
+
yield idx, question
|
| 114 |
+
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"default": {"description": "CLEVR is a diagnostic dataset that tests a range of visual reasoning abilities. It contains minimal biases and has detailed annotations describing the kind of reasoning each question requires. We use this dataset to analyze a variety of modern visual reasoning systems, providing novel insights into their abilities and limitations.\n", "citation": "@inproceedings{johnson2017clevr,\n title={Clevr: A diagnostic dataset for compositional language and elementary visual reasoning},\n author={Johnson, Justin and Hariharan, Bharath and Van Der Maaten, Laurens and Fei-Fei, Li and Lawrence Zitnick, C and Girshick, Ross},\n booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},\n pages={2901--2910},\n year={2017}\n}\n", "homepage": "https://cs.stanford.edu/people/jcjohns/clevr/", "license": "CC BY 4.0", "features": {"question_index": {"dtype": "int64", "id": null, "_type": "Value"}, "question_family_index": {"dtype": "int64", "id": null, "_type": "Value"}, "image_filename": {"dtype": "string", "id": null, "_type": "Value"}, "split": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}, "image": {"decode": true, "id": null, "_type": "Image"}, "image_index": {"dtype": "int64", "id": null, "_type": "Value"}, "program": {"feature": {"inputs": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "function": {"dtype": "string", "id": null, "_type": "Value"}, "value_inputs": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "clevr", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 511632731, "num_examples": 699989, "dataset_name": "clevr"}, "validation": {"name": "validation", "num_bytes": 108498206, "num_examples": 149991, "dataset_name": "clevr"}, "test": {"name": "test", "num_bytes": 55113984, "num_examples": 149988, "dataset_name": "clevr"}}, "download_checksums": {"https://dl.fbaipublicfiles.com/clevr/CLEVR_v1.0.zip": {"num_bytes": 19021600724, "checksum": "5cd61cf1096ed20944df93c9adb31e74d189b8459a94f54ba00090e5c59936d1"}}, "download_size": 19021600724, "post_processing_size": null, "dataset_size": 675244921, "size_in_bytes": 19696845645}}
|