apal commited on
Commit
7823e79
1 Parent(s): 8e86d78

Image dataset loading

Browse files
Files changed (1) hide show
  1. SkyScenes.py +68 -71
SkyScenes.py CHANGED
@@ -1,35 +1,38 @@
1
  import collections
2
  import json
3
  import os
4
- import datasets
5
 
 
6
 
7
- _HOMEPAGE = "https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation/dataset/1"
8
- _LICENSE = "CC BY 4.0"
9
- _CITATION = """\
10
- @misc{ buildings-instance-segmentation_dataset,
11
- title = { Buildings Instance Segmentation Dataset },
12
- type = { Open Source Dataset },
13
- author = { Roboflow Universe Projects },
14
- howpublished = { \\url{ https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation } },
15
- url = { https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation },
16
- journal = { Roboflow Universe },
17
- publisher = { Roboflow },
18
- year = { 2023 },
19
- month = { jan },
20
- note = { visited on 2023-01-18 },
21
- }
22
- """
23
- _CATEGORIES = ['building']
24
- _ANNOTATION_FILENAME = "_annotations.coco.json"
 
 
 
25
 
26
 
27
  class SKYSCENESConfig(datasets.BuilderConfig):
28
- """Builder Config for satellite-building-segmentation"""
29
 
30
  def __init__(self, data_urls, **kwargs):
31
  """
32
- BuilderConfig for satellite-building-segmentation.
33
  Args:
34
  data_urls: `dict`, name to url to download the zip file from.
35
  **kwargs: keyword arguments forwarded to super.
@@ -46,67 +49,61 @@ class SKYSCENES(datasets.GeneratorBasedBuilder):
46
  SKYSCENESConfig(
47
  name="full",
48
  description="Full version of skyscenes dataset.",
49
- data_urls={
50
- "Images": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town01.tar.gz",
51
- "Segment": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town02.tar.gz",
52
- "Depth": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town03.tar.gz",
53
- },
54
- ),
55
- SKYSCENESConfig(
56
- name="mini",
57
- description="Mini version of skyscenes dataset.",
58
- data_urls={
59
- "Images": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town01.tar.gz",
60
- "Segment": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town02.tar.gz",
61
- "Depth": "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/H_15_P_0/ClearNight/Town03.tar.gz",
62
- },
63
- )
64
  ]
65
 
66
  def _info(self):
67
- features = datasets.Features(
68
- {
69
- "image_id": datasets.Value("int64"),
70
- "image": datasets.Image(),
71
- "width": datasets.Value("int32"),
72
- "height": datasets.Value("int32"),
73
- "objects": datasets.Sequence(
74
- {
75
- "id": datasets.Value("int64"),
76
- "area": datasets.Value("int64"),
77
- "bbox": datasets.Sequence(datasets.Value("float32"), length=4),
78
- "segmentation": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
79
- "category": datasets.ClassLabel(names=_CATEGORIES),
80
- }
81
- ),
82
- }
83
- )
84
  return datasets.DatasetInfo(
85
- features=features,
86
  homepage=_HOMEPAGE,
87
- citation=_CITATION,
88
  license=_LICENSE,
89
  )
90
 
91
  def _split_generators(self, dl_manager):
92
- data_files = dl_manager.download_and_extract(self.config.data_urls)
 
93
  return [
94
  datasets.SplitGenerator(
95
- name= datasets.Split.TRAIN,
96
- gen_kwargs={
97
- "folder_dir": data_files["Images"],
98
- },
99
- ),
100
- datasets.SplitGenerator(
101
- name=datasets.Split.VALIDATION,
102
  gen_kwargs={
103
- "folder_dir": data_files["Segment"],
 
104
  },
105
  ),
106
- datasets.SplitGenerator(
107
- name=datasets.Split.TEST,
108
- gen_kwargs={
109
- "folder_dir": data_files["Depth"],
110
- },
111
- ),
112
- ]
 
 
 
 
 
 
 
 
1
  import collections
2
  import json
3
  import os
 
4
 
5
+ import datasets
6
 
7
+ _DESCRIPTION='SkyScenes, a synthetic dataset of densely annotated aerial images captured from Unmanned Aerial Vehicle (UAV) perspectives. SkyScenes is curated from CARLA to comprehensively capture diversity across layout (urban and rural maps), weather conditions, times of day, pitch angles and altitudes with corresponding semantic, instance and depth annotations.'
8
+ _HOMEPAGE = "skyscenes.github.io"
9
+ _LICENSE = "MIT"
10
+ # _CITATION = """\
11
+ # @misc{ buildings-instance-segmentation_dataset,
12
+ # title = { Buildings Instance Segmentation Dataset },
13
+ # type = { Open Source Dataset },
14
+ # author = { Roboflow Universe Projects },
15
+ # howpublished = { \\url{ https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation } },
16
+ # url = { https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation },
17
+ # journal = { Roboflow Universe },
18
+ # publisher = { Roboflow },
19
+ # year = { 2023 },
20
+ # month = { jan },
21
+ # note = { visited on 2023-01-18 },
22
+ # }
23
+ # """
24
+ _CATEGORIES = ["unlabeled", "building", "fence", "other", "pedestrian", "pole",
25
+ "roadline", "road", "sidewalk", "vegetation", "vehicles", "wall",
26
+ "trafficsign", "sky", "ground", "bridge", "railtrack", "guardrail",
27
+ "trafficlight", "static", "dynamic", "water", "terrain"]
28
 
29
 
30
  class SKYSCENESConfig(datasets.BuilderConfig):
31
+ """Builder Config for SkyScenes"""
32
 
33
  def __init__(self, data_urls, **kwargs):
34
  """
35
+ BuilderConfig for SkyScenes.
36
  Args:
37
  data_urls: `dict`, name to url to download the zip file from.
38
  **kwargs: keyword arguments forwarded to super.
 
49
  SKYSCENESConfig(
50
  name="full",
51
  description="Full version of skyscenes dataset.",
52
+ data_url="https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/H_15_P_0/ClearNight/Town01.tar.gz",
53
+ metadata_url = "https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/Town01.txt",
54
+ # SKYSCENESConfig(
55
+ # name="mini",
56
+ # description="Mini version of satellite-building-segmentation dataset.",
57
+ # data_urls=["https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/H_15_P_0/ClearNight/Town01.tar.gz","https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/H_15_P_0/ClearNight/Town02.tar.gz","https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/H_15_P_0/ClearNight/Town03.tar.gz","https://huggingface.co/datasets/hoffman-lab/SkyScenes/blob/main/Images/H_15_P_0/ClearNight/Town04.tar.gz",]
58
+ # )
 
 
 
 
 
 
 
 
59
  ]
60
 
61
  def _info(self):
62
+ # features = datasets.Features(
63
+ # {
64
+ # "image_id": datasets.Value("int64"),
65
+ # "image": datasets.Image(),
66
+ # "width": datasets.Value("int32"),
67
+ # "height": datasets.Value("int32"),
68
+ # "objects": datasets.Sequence(
69
+ # {
70
+ # "id": datasets.Value("int64"),
71
+ # "area": datasets.Value("int64"),
72
+ # "bbox": datasets.Sequence(datasets.Value("float32"), length=4),
73
+ # "segmentation": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
74
+ # "category": datasets.ClassLabel(names=_CATEGORIES),
75
+ # }
76
+ # ),
77
+ # }
78
+ # )
79
  return datasets.DatasetInfo(
80
+ description=_DESCRIPTION,
81
  homepage=_HOMEPAGE,
 
82
  license=_LICENSE,
83
  )
84
 
85
  def _split_generators(self, dl_manager):
86
+ data_files = dl_manager.download_and_extract(self.config.data_url)
87
+ split_metadata_paths = dl_manager.download(self.config.metadata_url)
88
  return [
89
  datasets.SplitGenerator(
90
+ name=datasets.Split.TRAIN,
 
 
 
 
 
 
91
  gen_kwargs={
92
+ "images": dl_manager.iter_archive(archive_path),
93
+ "metadata_path": split_metadata_paths["train"],
94
  },
95
  ),
96
+ ]
97
+
98
+ def _generate_examples(self, images, metadata_path):
99
+ """Generate images and labels for splits."""
100
+ with open(metadata_path, encoding="utf-8") as f:
101
+ files_to_keep = set(f.read().split("\n"))
102
+ for file_path, file_obj in images:
103
+ # if file_path.startswith(_IMAGES_DIR):
104
+ # if file_path[len(_IMAGES_DIR) : -len(".png")] in files_to_keep:
105
+ # label = file_path.split("/")[2]
106
+ yield file_path, {
107
+ "image": {"path": file_path, "bytes": file_obj.read()},
108
+ # "label": label,
109
+ }