aps commited on
Commit
d2a0cc5
·
1 Parent(s): f5998fb

Support classification

Browse files
Files changed (2) hide show
  1. clevr.py +50 -2
  2. dataset_infos.json +1 -1
clevr.py CHANGED
@@ -39,12 +39,60 @@ _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"),
@@ -52,7 +100,7 @@ class ClevrDataset(datasets.GeneratorBasedBuilder):
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({
@@ -102,7 +150,7 @@ class ClevrDataset(datasets.GeneratorBasedBuilder):
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": [],
 
39
 
40
  _URLS = "https://dl.fbaipublicfiles.com/clevr/CLEVR_v1.0.zip"
41
 
42
+ CLASSES = [
43
+ "0",
44
+ "gray",
45
+ "cube",
46
+ "purple",
47
+ "yes",
48
+ "small",
49
+ "brown",
50
+ "red",
51
+ "blue",
52
+ "7",
53
+ "5",
54
+ "8",
55
+ "metal",
56
+ "6",
57
+ "rubber",
58
+ "1",
59
+ "sphere",
60
+ "cylinder",
61
+ "3",
62
+ "10",
63
+ "2",
64
+ "yellow",
65
+ "cyan",
66
+ "green",
67
+ "9",
68
+ "large",
69
+ "no",
70
+ "4",
71
+ ]
72
+
73
 
74
  class ClevrDataset(datasets.GeneratorBasedBuilder):
75
 
76
  VERSION = datasets.Version("1.0.0")
77
+ DEFAULT_BUILD_CONFIG_NAME = "default"
78
+ BUILDER_CONFIGS = [
79
+ datasets.BuilderConfig(
80
+ name="default",
81
+ version=VERSION,
82
+ description="This config returns answers as plain text",
83
+ ),
84
+ datasets.BuilderConfig(
85
+ name="classification",
86
+ version=VERSION,
87
+ description="This config returns answers as class labels",
88
+ )
89
 
90
+ ]
91
  def _info(self):
92
+ if self.config.name == "classification":
93
+ answer_feature = datasets.ClassLabel(names=CLASSES)
94
+ else:
95
+ answer_feature = datasets.Value("string")
96
  features = datasets.Features(
97
  {
98
  "question_index": datasets.Value("int64"),
 
100
  "image_filename": datasets.Value("string"),
101
  "split": datasets.Value("string"),
102
  "question": datasets.Value("string"),
103
+ "answer": answer_feature,
104
  "image": datasets.Image(),
105
  "image_index": datasets.Value("int64"),
106
  "program": datasets.Sequence({
 
150
  question["image"] = str(image_folder / f"{question['image_filename']}")
151
  if split == "test":
152
  question["question_family_index"] = -1
153
+ question["answer"] = -1 if self.config.name == "classification" else ""
154
  question["program"] = [
155
  {
156
  "inputs": [],
dataset_infos.json CHANGED
@@ -1 +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}}
 
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}, "classification": {"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": {"num_classes": 28, "names": ["0", "gray", "cube", "purple", "yes", "small", "brown", "red", "blue", "7", "5", "8", "metal", "6", "rubber", "1", "sphere", "cylinder", "3", "10", "2", "yellow", "cyan", "green", "9", "large", "no", "4"], "id": null, "_type": "ClassLabel"}, "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": "classification", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 512232057, "num_examples": 699989, "dataset_name": "clevr"}, "validation": {"name": "validation", "num_bytes": 108627710, "num_examples": 149991, "dataset_name": "clevr"}, "test": {"name": "test", "num_bytes": 55713936, "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": 676573703, "size_in_bytes": 19698174427}}