| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| """UC Merced Land Use Dataset""" |
|
|
|
|
| import os |
|
|
| import datasets |
|
|
|
|
| _CITATION = """\ |
| @inproceedings{yang2010bagofvisualwords, |
| author = {Yi Yang and Shawn Newsam}, |
| title = {Bag-Of-Visual-Words and Spatial Extensions for Land-Use Classification}, |
| booktitle = {ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM GIS)}, |
| year = {2010} |
| } |
| """ |
|
|
| _DESCRIPTION = """\ |
| This is a 21 class land use image dataset meant for research purposes. |
| |
| There are 100 images for each of the following classes: |
| |
| - agricultural |
| - airplane |
| - baseballdiamond |
| - beach |
| - buildings |
| - chaparral |
| - denseresidential |
| - forest |
| - freeway |
| - golfcourse |
| - harbor |
| - intersection |
| - mediumresidential |
| - mobilehomepark |
| - overpass |
| - parkinglot |
| - river |
| - runway |
| - sparseresidential |
| - storagetanks |
| - tenniscourt |
| |
| Each image measures 256x256 pixels. |
| |
| The images were manually extracted from large images from the |
| USGS National Map Urban Area Imagery collection for various urban areas around |
| the country. The pixel resolution of this public domain imagery is 1 foot. |
| |
| For more information about the original UC Merced Land Use dataset, |
| please visit the official dataset page: |
| |
| http://weegee.vision.ucmerced.edu/datasets/landuse.html |
| |
| Please refer to the original dataset source for any additional details, |
| citations, or specific usage guidelines provided by the dataset creators. |
| """ |
|
|
| _HOMEPAGE = "http://weegee.vision.ucmerced.edu/datasets/landuse.html" |
|
|
| _LICENSE = "cc0-1.0" |
|
|
| _DATA_URL = "http://weegee.vision.ucmerced.edu/datasets/UCMerced_LandUse.zip" |
|
|
| _LABEL_NAMES = [ |
| "agricultural", |
| "airplane", |
| "baseballdiamond", |
| "beach", |
| "buildings", |
| "chaparral", |
| "denseresidential", |
| "forest", |
| "freeway", |
| "golfcourse", |
| "harbor", |
| "intersection", |
| "mediumresidential", |
| "mobilehomepark", |
| "overpass", |
| "parkinglot", |
| "river", |
| "runway", |
| "sparseresidential", |
| "storagetanks", |
| "tenniscourt", |
| ] |
|
|
|
|
| class UCMercedLandUse(datasets.GeneratorBasedBuilder): |
| """A 21 class land use image dataset.""" |
|
|
| VERSION = datasets.Version("1.0.0") |
|
|
| BUILDER_CONFIGS = [ |
| datasets.BuilderConfig( |
| name="ucmerced_landuse", |
| version=VERSION, |
| description="UC Merced Land Use Dataset", |
| ), |
| ] |
|
|
| DEFAULT_CONFIG_NAME = "ucmerced_landuse" |
|
|
| def _info(self): |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=datasets.Features( |
| { |
| "img": datasets.Image(), |
| "label": datasets.features.ClassLabel(names=_LABEL_NAMES), |
| } |
| ), |
| homepage=_HOMEPAGE, |
| license=_LICENSE, |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| data_dir = dl_manager.download_and_extract("UCMerced_LandUse.zip") |
|
|
| class_dirs = [ |
| os.path.join(data_dir, "UCMerced_LandUse/Images", label) |
| for label in _LABEL_NAMES |
| ] |
|
|
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "class_dirs": class_dirs, |
| "split": "train", |
| }, |
| ), |
| ] |
|
|
| def _generate_examples(self, class_dirs, split): |
| key = 0 |
| for class_dir in class_dirs: |
| class_label = os.path.basename(class_dir) |
|
|
| |
| for image_filename in os.listdir(class_dir): |
| image_path = os.path.join(class_dir, image_filename) |
|
|
| yield key, { |
| "img": image_path, |
| "label": class_label, |
| } |
|
|
| key += 1 |
|
|