Datasets:

davanstrien HF staff commited on
Commit
53a6d4b
1 Parent(s): 4cdcbf6

tidy configs

Browse files
dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"illustration_detection": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image_id": {"dtype": "int64", "id": null, "_type": "Value"}, "image": {"decode": true, "id": null, "_type": "Image"}, "width": {"dtype": "int32", "id": null, "_type": "Value"}, "height": {"dtype": "int32", "id": null, "_type": "Value"}, "objects": [{"category_id": {"num_classes": 1, "names": ["early_printed_illustration"], "id": null, "_type": "ClassLabel"}, "image_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "int64", "id": null, "_type": "Value"}, "area": {"dtype": "int64", "id": null, "_type": "Value"}, "bbox": {"feature": {"dtype": "float32", "id": null, "_type": "Value"}, "length": 4, "id": null, "_type": "Sequence"}, "segmentation": [[{"dtype": "float32", "id": null, "_type": "Value"}]], "iscrowd": {"dtype": "bool", "id": null, "_type": "Value"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "illustration_detection", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1861271, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1861271, "size_in_bytes": 6758716105}, "image_classification": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "label": {"num_classes": 2, "names": ["not-illustrated", "illustrated"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "image_classification", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1430734, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1430734, "size_in_bytes": 6758285568}}
 
1
+ {"illustration_detection": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image_id": {"dtype": "int64", "id": null, "_type": "Value"}, "image": {"decode": true, "id": null, "_type": "Image"}, "width": {"dtype": "int32", "id": null, "_type": "Value"}, "height": {"dtype": "int32", "id": null, "_type": "Value"}, "objects": [{"category_id": {"num_classes": 1, "names": ["early_printed_illustration"], "id": null, "_type": "ClassLabel"}, "image_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "int64", "id": null, "_type": "Value"}, "area": {"dtype": "int64", "id": null, "_type": "Value"}, "bbox": {"feature": {"dtype": "float32", "id": null, "_type": "Value"}, "length": 4, "id": null, "_type": "Sequence"}, "segmentation": [[{"dtype": "float32", "id": null, "_type": "Value"}]], "iscrowd": {"dtype": "bool", "id": null, "_type": "Value"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "illustration_detection", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1861271, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1861271, "size_in_bytes": 6758716105}, "image_classification": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "label": {"num_classes": 2, "names": ["not-illustrated", "illustrated"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "image_classification", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1430734, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1430734, "size_in_bytes": 6758285568}, "illustration-detection": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image_id": {"dtype": "int64", "id": null, "_type": "Value"}, "image": {"decode": true, "id": null, "_type": "Image"}, "width": {"dtype": "int32", "id": null, "_type": "Value"}, "height": {"dtype": "int32", "id": null, "_type": "Value"}, "objects": [{"category_id": {"num_classes": 1, "names": ["early_printed_illustration"], "id": null, "_type": "ClassLabel"}, "image_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "int64", "id": null, "_type": "Value"}, "area": {"dtype": "int64", "id": null, "_type": "Value"}, "bbox": {"feature": {"dtype": "float32", "id": null, "_type": "Value"}, "length": 4, "id": null, "_type": "Sequence"}, "segmentation": [[{"dtype": "float32", "id": null, "_type": "Value"}]], "iscrowd": {"dtype": "bool", "id": null, "_type": "Value"}}]}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "illustration-detection", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1861271, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1861271, "size_in_bytes": 6758716105}, "image-classification": {"description": "TODO", "citation": "TODO", "homepage": "TODO", "license": "Public Domain Mark 1.0", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "label": {"num_classes": 2, "names": ["not-illustrated", "illustrated"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "nls_chapbook_illustrations", "config_name": "image-classification", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1430734, "num_examples": 7258, "dataset_name": "nls_chapbook_illustrations"}}, "download_checksums": {"https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip": {"num_bytes": 6754994277, "checksum": "ead1ce3f59ad561025235656848024049bae635eadb7e191048bc990d32e85f8"}, "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json": {"num_bytes": 1860557, "checksum": "edfbdaa4123c40b8a90472e5ab7664b9e22c25cdfbf1a0925f5820e5cc4d4275"}}, "download_size": 6756854834, "post_processing_size": null, "dataset_size": 1430734, "size_in_bytes": 6758285568}}
nls_chapbook_illustrations.py CHANGED
@@ -20,7 +20,6 @@ from typing import Any, Dict, List
20
 
21
  import datasets
22
 
23
-
24
  _CITATION = "TODO"
25
 
26
 
@@ -38,6 +37,8 @@ _IMAGES_URL = "https://nlsfoundry.s3.amazonaws.com/data/nls-data-chapbooks.zip"
38
  # TODO update url if this is merged upstream
39
  _ANNOTATIONS_URL = "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json"
40
 
 
 
41
 
42
  class NationalLibraryScotlandChapBooksConfig(datasets.BuilderConfig):
43
  """BuilderConfig for National Library of Scotland Chapbooks dataset."""
@@ -55,19 +56,18 @@ class NationalLibraryScotlandChapBooks(datasets.GeneratorBasedBuilder):
55
  """National Library of Scotland Chapbooks dataset."""
56
 
57
  BUILDER_CONFIGS = [
58
- NationalLibraryScotlandChapBooksConfig("illustration_detection"),
59
- NationalLibraryScotlandChapBooksConfig("image_classification"),
60
  ]
61
 
62
  def _info(self):
63
- if self.config.name == "illustration_detection":
64
  features = datasets.Features(
65
  {
66
  "image_id": datasets.Value("int64"),
67
  "image": datasets.Image(),
68
  "width": datasets.Value("int32"),
69
  "height": datasets.Value("int32"),
70
- # "url": datasets.Value("string"),
71
  }
72
  )
73
  object_dict = {
@@ -82,7 +82,7 @@ class NationalLibraryScotlandChapBooks(datasets.GeneratorBasedBuilder):
82
  "iscrowd": datasets.Value("bool"),
83
  }
84
  features["objects"] = [object_dict]
85
- if self.config.name == "image_classification":
86
  features = datasets.Features(
87
  {
88
  "image": datasets.Image(),
@@ -131,7 +131,6 @@ class NationalLibraryScotlandChapBooks(datasets.GeneratorBasedBuilder):
131
  "image": os.path.join(image_dir, image),
132
  "width": image_info["width"],
133
  "height": image_info["height"],
134
- # "url": image_info.get("url"),
135
  }
136
 
137
  with open(annotations_file, encoding="utf8") as f:
@@ -142,7 +141,7 @@ class NationalLibraryScotlandChapBooks(datasets.GeneratorBasedBuilder):
142
  image_id_to_annotations = self._get_image_id_to_annotations_mapping(
143
  annotations
144
  )
145
- if self.config.name == "illustration_detection":
146
  for idx, image_info in enumerate(images):
147
  example = _image_info_to_example(
148
  image_info,
@@ -157,9 +156,8 @@ class NationalLibraryScotlandChapBooks(datasets.GeneratorBasedBuilder):
157
  objects.append(annot)
158
  example["objects"] = objects
159
  yield idx, example
160
- if self.config.name == "image_classification":
161
  for idx, image_info in enumerate(images):
162
- example = _image_info_to_example(image_info, image_dir)
163
  annotations = image_id_to_annotations[image_info["id"]]
164
  if len(annotations) < 1:
165
  label = 0
 
20
 
21
  import datasets
22
 
 
23
  _CITATION = "TODO"
24
 
25
 
 
37
  # TODO update url if this is merged upstream
38
  _ANNOTATIONS_URL = "https://gitlab.com/davanstrien/nls-chapbooks-illustrations/-/raw/master/data/annotations/step5-manual-verification-image-0-47329_train_coco.json"
39
 
40
+ logger = datasets.utils.logging.get_logger(__name__)
41
+
42
 
43
  class NationalLibraryScotlandChapBooksConfig(datasets.BuilderConfig):
44
  """BuilderConfig for National Library of Scotland Chapbooks dataset."""
 
56
  """National Library of Scotland Chapbooks dataset."""
57
 
58
  BUILDER_CONFIGS = [
59
+ NationalLibraryScotlandChapBooksConfig("illustration-detection"),
60
+ NationalLibraryScotlandChapBooksConfig("image-classification"),
61
  ]
62
 
63
  def _info(self):
64
+ if self.config.name == "illustration-detection":
65
  features = datasets.Features(
66
  {
67
  "image_id": datasets.Value("int64"),
68
  "image": datasets.Image(),
69
  "width": datasets.Value("int32"),
70
  "height": datasets.Value("int32"),
 
71
  }
72
  )
73
  object_dict = {
 
82
  "iscrowd": datasets.Value("bool"),
83
  }
84
  features["objects"] = [object_dict]
85
+ if self.config.name == "image-classification":
86
  features = datasets.Features(
87
  {
88
  "image": datasets.Image(),
 
131
  "image": os.path.join(image_dir, image),
132
  "width": image_info["width"],
133
  "height": image_info["height"],
 
134
  }
135
 
136
  with open(annotations_file, encoding="utf8") as f:
 
141
  image_id_to_annotations = self._get_image_id_to_annotations_mapping(
142
  annotations
143
  )
144
+ if self.config.name == "illustration-detection":
145
  for idx, image_info in enumerate(images):
146
  example = _image_info_to_example(
147
  image_info,
 
156
  objects.append(annot)
157
  example["objects"] = objects
158
  yield idx, example
159
+ if self.config.name == "image-classification":
160
  for idx, image_info in enumerate(images):
 
161
  annotations = image_id_to_annotations[image_info["id"]]
162
  if len(annotations) < 1:
163
  label = 0