o
    Nik                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlm	  m
Z ddlmZ dZdZdZg d	Zd
ZdZG dd dejjZdd ZdS )zDUC Merced: Small remote sensing dataset for land use classification.    )absolute_import)division)print_functionNa  @InProceedings{Nilsback08,
   author = "Yang, Yi and Newsam, Shawn",
   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",
}aT  UC Merced is a 21 class land use remote sensing image dataset, with 100 images
per class. 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 0.3 m.
Each image measures 256x256 pixels.z7http://weegee.vision.ucmerced.edu/datasets/landuse.html)agriculturalairplanebaseballdiamondbeach	buildings	chaparraldenseresidentialforestfreeway
golfcourseharborintersectionmediumresidentialmobilehomeparkoverpass
parkinglotriverrunwaysparseresidentialstoragetankstenniscourtz?http://weegee.vision.ucmerced.edu/datasets/UCMerced_LandUse.zipzUCMerced_LandUse/Imagesc                   @   s6   e Zd ZdZejddZdd Zdd Z	dd	 Z
d
S )UcMercedz>Small 21 class remote sensing land use classification dataset.z2.0.0z6New split API (https://tensorflow.org/datasets/splits)c              	   C   s>   t jj| tt jt j t jjtdt j	 ddt
tdS )N)namesimagelabelfilename)r   r   )builderdescriptionfeaturessupervised_keyshomepagecitation)tfdscoreDatasetInfo_DESCRIPTIONr"   FeaturesDictImage
ClassLabel_LABELSText_URL	_CITATION)self r2   f/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/uc_merced.py_infoO   s   zUcMerced._infoc                 C   s.   | t}tjjtjjdtj	|t
idgS )zReturns SplitGenerators.path)name
gen_kwargs)download_and_extract_ZIP_URLr&   r'   SplitGeneratorSplitTRAINosr5   join_ZIP_SUBDIR)r1   
dl_managerr5   r2   r2   r3   _split_generators]   s   
zUcMerced._split_generatorsc                 c   sd    t jj|D ]'}t jjtj||dD ]}t|}tj	|}|||d}||fV  qqdS )zYields examples.z*.tifr   N)
tfiogfilelistdirglobr=   r5   r>   	_load_tifbasename)r1   r5   r   r   r   recordr2   r2   r3   _generate_examplesg   s   zUcMerced._generate_examplesN)__name__
__module____qualname____doc__r&   r'   VersionVERSIONr4   rA   rJ   r2   r2   r2   r3   r   I   s    
r   c                 C   sJ   t jj| d}tjjj|}W d    n1 sw   Y  t	
|S )Nrb)rB   rC   rD   GFiler&   r'   lazy_imports	PIL_Imageopennparray)r5   fpr   r2   r2   r3   rG   u   s   
rG   )rN   
__future__r   r   r   r=   numpyrV   tensorflow.compat.v2compatv2rB   tensorflow_datasets.public_api
public_apir&   r0   r)   r/   r-   r9   r?   r'   GeneratorBasedBuilderr   rG   r2   r2   r2   r3   <module>   s    ,