File size: 4,720 Bytes
aef7e7c
 
 
 
7823e79
aef7e7c
7823e79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aef7e7c
 
 
7823e79
aef7e7c
f49d0b3
aef7e7c
7823e79
aef7e7c
 
 
 
 
 
1255f06
aef7e7c
 
 
 
 
 
 
 
 
 
0aa8f66
216c599
7823e79
 
 
216c599
7823e79
aef7e7c
 
ebaa43f
12830b1
 
 
 
 
ebaa43f
7823e79
ebaa43f
 
 
aef7e7c
 
1255f06
7823e79
aef7e7c
 
7823e79
aef7e7c
27001f3
f9da925
aef7e7c
 
388463b
7823e79
388463b
 
bb11c60
 
9c3d9b9
8cf7f85
 
 
 
 
9c3d9b9
388463b
 
 
d0319c4
7176094
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import collections
import json
import os

import datasets

_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.'
_HOMEPAGE = "skyscenes.github.io"
_LICENSE = "MIT"
# _CITATION = """\
# @misc{ buildings-instance-segmentation_dataset,
#     title = { Buildings Instance Segmentation Dataset },
#     type = { Open Source Dataset },
#     author = { Roboflow Universe Projects },
#     howpublished = { \\url{ https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation } },
#     url = { https://universe.roboflow.com/roboflow-universe-projects/buildings-instance-segmentation },
#     journal = { Roboflow Universe },
#     publisher = { Roboflow },
#     year = { 2023 },
#     month = { jan },
#     note = { visited on 2023-01-18 },
# }
# """
_CATEGORIES =    ["unlabeled", "building", "fence", "other", "pedestrian", "pole", 
                "roadline", "road", "sidewalk", "vegetation", "vehicles", "wall", 
                "trafficsign", "sky", "ground", "bridge", "railtrack", "guardrail", 
                "trafficlight", "static", "dynamic", "water", "terrain"]


class SKYSCENESConfig(datasets.BuilderConfig):
    """Builder Config for SkyScenes"""

    def __init__(self, data_urls, metadata_url, **kwargs):
        """
        BuilderConfig for SkyScenes.
        Args:
          data_urls: `dict`, name to url to download the zip file from.
          **kwargs: keyword arguments forwarded to super.
        """
        super(SKYSCENESConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
        self.data_urls = data_urls
        self.metadata_url = metadata_url


class SKYSCENES(datasets.GeneratorBasedBuilder):
    """satellite-building-segmentation instance segmentation dataset"""

    VERSION = datasets.Version("1.0.0")
    BUILDER_CONFIGS = [
        SKYSCENESConfig(
            name="full",
            description="Full version of skyscenes dataset.",
            data_urls="https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/trial_Segment/H_35_P_90/ClearNoon/Town03/Town03.tar.gz",
            metadata_url = "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/Town01.txt",)
        # SKYSCENESConfig(
        #     name="mini",
        #     description="Mini version of satellite-building-segmentation dataset.",
        #     data_urls=["https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/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",]
        # )
    ]

    def _info(self):
        features = datasets.Features(
                {
                    "image": datasets.Image(),
                }
        )
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            homepage=_HOMEPAGE,
            license=_LICENSE,
        )

    def _split_generators(self, dl_manager):
        data_files = dl_manager.download_and_extract(self.config.data_urls)
        split_metadata_paths = dl_manager.download(self.config.metadata_url)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "images": data_files,
                    "metadata_path": split_metadata_paths,
                },
            ),
        ]

    def _generate_examples(self, images, metadata_path):
        """Generate images and labels for splits."""
        # with open(metadata_path, encoding="utf-8") as f:
        #     files_to_keep = set(f.read().split("\n"))
            # print('KEEP',files_to_keep)
        # for file_path, file_obj in images:
        for filename in os.listdir(images):
            filepath = os.path.join(images, filename)
            with open(filepath, "rb") as f:
                image_bytes = f.read()
                    # print('FILE',file_path)
            # if file_path.startswith(_IMAGES_DIR):
            #     if file_path[len(_IMAGES_DIR) : -len(".jpg")] in files_to_keep:
            #         label = file_path.split("/")[2]
            yield filepath, {
                "image": {"path": filepath, "bytes": image_bytes},
            }