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
ZG dd deZG dd dejjZdS )+Healthy and unhealthy plant leaves dataset.    )absolute_import)division)print_functionNz
@misc{,
  author={Vippon Preet Kour, Sakshi Arora},
  title={PlantaeK: A leaf database of native plants of Jammu and Kashmir},
  howpublished={Mendeley Data},
  year={2019}
}
a  
This dataset contains 2153 images of healthy and unhealthy plant leaves divided
16 categories by species and state of health. The images are in high resolution
JPG format.

Note: Each image is a separate download. Some might rarely fail, therefore make
sure to restart if that happens. An exception will be raised in case one of the
downloads repeatedly fails.

Dataset URL: https://data.mendeley.com/datasets/t6j2h22jpx/1
License: http://creativecommons.org/licenses/by/4.0
))apple_dzAPPLE DISEASED)apple_hzAPPLE HEALTHY)	apricot_dzAPRICOT DISEASED)	apricot_hzAPRICOT HEALTHY)cherry_dzCHERRY DISEASED)cherry_hzCHERRY HEALTHY)cranberry_dzCRANBERRY DISEASED)cranberry_hzCRANBERRY HEALTHY)grapes_dzGRAPES DISEASED)grapes_hzGRAPES HEALTHY)peach_dzPEACH DISEASED)peach_hzPEACH HEALTHY)pear_dzPEAR DISEASED)pear_hzPEAR HEALTHY)walnut_dWALNUT DISEASED)walnut_hr   )zwalnut-hzWALNUT HEALTHYz'image_classification/plantae_k_urls.txt
   c                   @   s   e Zd ZdS )DownloadRetryLimitReachedErrorN)__name__
__module____qualname__ r   r   f/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/plantae_k.pyr   L   s    r   c                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
PlantaeKr   z0.1.0c              
   C   sV   t tttt d }tjj| ttj	
tj	 tj	 tj	j|ddddtdS )N   )namesimagezimage/filenamelabel)r"   r#   z/https://data.mendeley.com/datasets/t6j2h22jpx/1)builderdescriptionfeaturessupervised_keyshomepagecitation)sortedsetlistzip_LABEL_MAPPINGtfdscoreDatasetInfo_DESCRIPTIONr&   FeaturesDictImageText
ClassLabel	_CITATION)selflabelsr   r   r   _infoU   s   zPlantaeK._infoc              	   C   s   t jjtjtC}dd | D }d}i }	 z|	|}W n tj	j
y8   |d7 }|tkr6tdY nw qtjjtjjd|idgW  d	   S 1 sQw   Y  d	S )
zReturns SplitGenerators.c                 S   s"   i | ]}t j| | qS r   )ospathbasenamestrip).0lr   r   r   
<dictcomp>i   s    z.PlantaeK._split_generators.<locals>.<dictcomp>r   Tr   z7Retry limit reached. Try downloading the dataset again.image_files)name
gen_kwargsN)tfiogfileGFiler/   r0   get_tfds_path_URLS_FNAME	readlinesdownloadDownloadError_MAX_DOWNLOAD_RETRYr   SplitGeneratorSplitTRAIN)r8   
dl_managerfname_to_url_mapretry_countrB   r   r   r   _split_generatorsd   s2   

$zPlantaeK._split_generatorsc           	      c   sp    dd t D }td}| D ]$\}}||}|r5|d|v r5||d }|||d}||fV  qdS )zYields examples.c                 S   s   i | ]\}}||qS r   r   )r?   patternr#   r   r   r   rA      s    z/PlantaeK._generate_examples.<locals>.<dictcomp>z^(\w+[-_][dh])\d+\.JPG$r   r!   N)r.   recompileitemsmatchgroup)	r8   rB   	label_mapregexporiginal_fnamefpathr[   r#   recordr   r   r   _generate_examples   s   


zPlantaeK._generate_examplesN)r   r   r   __doc__r/   r0   VersionVERSIONr:   rV   rb   r   r   r   r   r   P   s    r   )rc   
__future__r   r   r   r;   rX   tensorflow.compat.v2compatv2rE   tensorflow_datasets.public_api
public_apir/   r7   r2   r.   rJ   rN   	Exceptionr   r0   GeneratorBasedBuilderr   r   r   r   r   <module>   s   	