o
    Ni                     @   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g dZd	Zd
dgZG dd dejjZG dd dejjZdd ZdS ),Eurosat remote sensing benchmarking dataset.    )absolute_import)division)print_functionNa=  
@misc{helber2017eurosat,
    title={EuroSAT: A Novel Dataset and Deep Learning Benchmark for Land Use and Land Cover Classification},
    author={Patrick Helber and Benjamin Bischke and Andreas Dengel and Damian Borth},
    year={2017},
    eprint={1709.00029},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}
aw  EuroSAT dataset is based on Sentinel-2 satellite images covering 13 spectral
bands and consisting of 10 classes with 27000 labeled and
geo-referenced samples.

Two datasets are offered:
- rgb: Contains only the optical R, G, B frequency bands encoded as JPEG image.
- all: Contains all 13 bands in the original value range (float32).

URL: https://github.com/phelber/eurosat
)

AnnualCropForestHerbaceousVegetationHighway
IndustrialPasturePermanentCropResidentialRiverSeaLakez"https://github.com/phelber/eurosatrgballc                       s"   e Zd ZdZd fdd	Z  ZS )EurosatConfigzBuilderConfig for eurosat.Nc                    sL   |t vr
tdt  tt| jddtjdi| || _|| _	|| _
dS )zConstructs a EurosatConfig.

    Args:
      selection: `str`, one of `_DATA_OPTIONS`.
      download_url: `str`, download URL to the zip file.
      subdir: `str`, subdir within the zip file.
      **kwargs: keyword arguments forwarded to super.
    zselection must be one of %sversionz2.0.0N )_DATA_OPTIONS
ValueErrorsuperr   __init__tfdscoreVersion	selectiondownload_urlsubdir)selfr   r   r   kwargs	__class__r   d/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/eurosat.pyr   A   s   	
zEurosatConfig.__init__)NNN)__name__
__module____qualname____doc__r   __classcell__r   r   r!   r#   r   >   s    r   c                   @   sL   e Zd ZdZeddddddedddd	d
dgZdd Zdd Zdd ZdS )Eurosatr   r   z.http://madm.dfki.de/files/sentinel/EuroSAT.zip2750zSentinel-2 RGB channels)r   namer   r   descriptionr   z6http://madm.dfki.de/files/sentinel/EuroSATallBands.zipz5ds/images/remote_sensing/otherDatasets/sentinel_2/tifz13 Sentinel-2 channelsc                 C   s   | j jdkr"tjtjjg ddtjjtdtj d}d}n#| j jdkrEtjtjj	g dt
jd	tjjtdtj d
}d}tjj| t||ttdS )Nr   )@   r-      )shape)namesimagelabelfilename)r2   r3   r   )r-   r-      )r/   dtype	sentinel2r3   r4   )r8   r3   )builderr,   featuressupervised_keyshomepagecitation)builder_configr   r   r:   FeaturesDictImage
ClassLabel_LABELSTextTensortffloat32r   DatasetInfo_DESCRIPTION_URL	_CITATION)r   r:   r;   r   r   r#   _infof   s,   zEurosat._infoc                 C   s@   | | jj}tj|| jj}tjj	tj
j|| jjddgS )zReturns SplitGenerators.)pathr   )r+   
gen_kwargs)download_and_extractr>   r   osrL   joinr   r   r   SplitGeneratorSplitTRAINr   )r   
dl_managerrL   r   r   r#   _split_generators   s   zEurosat._split_generatorsc                 c   s    t jjtj|ddD ]/}tj|d dd }|dkr,||tj|d}nt	||tj|d}||fV  qdS )	zYields examples.*_r   r   r1   r7   N)
rE   iogfileglobrO   rL   rP   splitbasename_extract_channels)r   rL   r   r4   r3   recordr   r   r#   _generate_examples   s   

zEurosat._generate_examplesN)	r$   r%   r&   r'   r   BUILDER_CONFIGSrK   rU   r`   r   r   r   r#   r)   T   s(    r)   c                 C   s\   t jj| d}tjjjjj	
t| }W d    n1 s"w   Y  |d}|S )NrbrF   )rE   rY   rZ   GFiler   r   lazy_importsskimageexternaltifffileimreadBytesIOreadastype)r4   farrr   r   r#   r^      s   
r^   )r'   
__future__r   r   r   rY   rO   tensorflow.compat.v2compatv2rE   tensorflow_datasets.public_api
public_apir   rJ   rH   rB   rI   r   r   BuilderConfigr   GeneratorBasedBuilderr)   r^   r   r   r   r#   <module>   s    O