SatwikKambham
commited on
Commit
•
d4ec9f0
1
Parent(s):
f87dc03
Add loading script and dataset
Browse files- UCMerced_LandUse.zip +3 -0
- uc_merced_land_use.py +166 -0
UCMerced_LandUse.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06c539ef28703a58fb07bd2837991ac7c48b813b00bb12ac197efd813a18daeb
|
3 |
+
size 332468434
|
uc_merced_land_use.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
+
"""UC Merced Land Use Dataset"""
|
15 |
+
|
16 |
+
|
17 |
+
import os
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_CITATION = """\
|
23 |
+
@inproceedings{yang2010bagofvisualwords,
|
24 |
+
author = {Yi Yang and Shawn Newsam},
|
25 |
+
title = {Bag-Of-Visual-Words and Spatial Extensions for Land-Use Classification},
|
26 |
+
booktitle = {ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM GIS)},
|
27 |
+
year = {2010}
|
28 |
+
}
|
29 |
+
"""
|
30 |
+
|
31 |
+
_DESCRIPTION = """\
|
32 |
+
This is a 21 class land use image dataset meant for research purposes.
|
33 |
+
|
34 |
+
There are 100 images for each of the following classes:
|
35 |
+
|
36 |
+
- agricultural
|
37 |
+
- airplane
|
38 |
+
- baseballdiamond
|
39 |
+
- beach
|
40 |
+
- buildings
|
41 |
+
- chaparral
|
42 |
+
- denseresidential
|
43 |
+
- forest
|
44 |
+
- freeway
|
45 |
+
- golfcourse
|
46 |
+
- harbor
|
47 |
+
- intersection
|
48 |
+
- mediumresidential
|
49 |
+
- mobilehomepark
|
50 |
+
- overpass
|
51 |
+
- parkinglot
|
52 |
+
- river
|
53 |
+
- runway
|
54 |
+
- sparseresidential
|
55 |
+
- storagetanks
|
56 |
+
- tenniscourt
|
57 |
+
|
58 |
+
Each image measures 256x256 pixels.
|
59 |
+
|
60 |
+
The images were manually extracted from large images from the
|
61 |
+
USGS National Map Urban Area Imagery collection for various urban areas around
|
62 |
+
the country. The pixel resolution of this public domain imagery is 1 foot.
|
63 |
+
|
64 |
+
For more information about the original UC Merced Land Use dataset,
|
65 |
+
please visit the official dataset page:
|
66 |
+
|
67 |
+
http://weegee.vision.ucmerced.edu/datasets/landuse.html
|
68 |
+
|
69 |
+
Please refer to the original dataset source for any additional details,
|
70 |
+
citations, or specific usage guidelines provided by the dataset creators.
|
71 |
+
"""
|
72 |
+
|
73 |
+
_HOMEPAGE = "http://weegee.vision.ucmerced.edu/datasets/landuse.html"
|
74 |
+
|
75 |
+
_LICENSE = "cc0-1.0"
|
76 |
+
|
77 |
+
_DATA_URL = "http://weegee.vision.ucmerced.edu/datasets/UCMerced_LandUse.zip"
|
78 |
+
|
79 |
+
_LABEL_NAMES = [
|
80 |
+
"agricultural",
|
81 |
+
"airplane",
|
82 |
+
"baseballdiamond",
|
83 |
+
"beach",
|
84 |
+
"buildings",
|
85 |
+
"chaparral",
|
86 |
+
"denseresidential",
|
87 |
+
"forest",
|
88 |
+
"freeway",
|
89 |
+
"golfcourse",
|
90 |
+
"harbor",
|
91 |
+
"intersection",
|
92 |
+
"mediumresidential",
|
93 |
+
"mobilehomepark",
|
94 |
+
"overpass",
|
95 |
+
"parkinglot",
|
96 |
+
"river",
|
97 |
+
"runway",
|
98 |
+
"sparseresidential",
|
99 |
+
"storagetanks",
|
100 |
+
"tenniscourt",
|
101 |
+
]
|
102 |
+
|
103 |
+
|
104 |
+
class UCMercedLandUse(datasets.GeneratorBasedBuilder):
|
105 |
+
"""A 21 class land use image dataset."""
|
106 |
+
|
107 |
+
VERSION = datasets.Version("1.0.0")
|
108 |
+
|
109 |
+
BUILDER_CONFIGS = [
|
110 |
+
datasets.BuilderConfig(
|
111 |
+
name="ucmerced_landuse",
|
112 |
+
version=VERSION,
|
113 |
+
description="UC Merced Land Use Dataset",
|
114 |
+
),
|
115 |
+
]
|
116 |
+
|
117 |
+
DEFAULT_CONFIG_NAME = "ucmerced_landuse"
|
118 |
+
|
119 |
+
def _info(self):
|
120 |
+
return datasets.DatasetInfo(
|
121 |
+
description=_DESCRIPTION,
|
122 |
+
features=datasets.Features(
|
123 |
+
{
|
124 |
+
"img": datasets.Image(),
|
125 |
+
"label": datasets.features.ClassLabel(names=_LABEL_NAMES),
|
126 |
+
}
|
127 |
+
),
|
128 |
+
homepage=_HOMEPAGE,
|
129 |
+
license=_LICENSE,
|
130 |
+
citation=_CITATION,
|
131 |
+
)
|
132 |
+
|
133 |
+
def _split_generators(self, dl_manager):
|
134 |
+
# data_dir = dl_manager.download_and_extract(_DATA_URL)
|
135 |
+
|
136 |
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
137 |
+
archive_path = os.path.join(script_dir, "UCMerced_LandUse.zip")
|
138 |
+
data_dir = dl_manager.extract(archive_path)
|
139 |
+
|
140 |
+
class_dirs = [
|
141 |
+
os.path.join(data_dir, "UCMerced_LandUse/Images", label)
|
142 |
+
for label in _LABEL_NAMES
|
143 |
+
]
|
144 |
+
|
145 |
+
return [
|
146 |
+
datasets.SplitGenerator(
|
147 |
+
name=datasets.Split.TRAIN,
|
148 |
+
gen_kwargs={
|
149 |
+
"class_dirs": class_dirs,
|
150 |
+
"split": "train",
|
151 |
+
},
|
152 |
+
),
|
153 |
+
]
|
154 |
+
|
155 |
+
def _generate_examples(self, class_dirs, split):
|
156 |
+
for key, class_dir in enumerate(class_dirs):
|
157 |
+
class_label = os.path.basename(class_dir)
|
158 |
+
|
159 |
+
# Iterate through the images in the class directory
|
160 |
+
for image_filename in os.listdir(class_dir):
|
161 |
+
image_path = os.path.join(class_dir, image_filename)
|
162 |
+
|
163 |
+
yield key, {
|
164 |
+
"img": image_path,
|
165 |
+
"label": class_label,
|
166 |
+
}
|