o
    Ni                     @   sz   d Z ddlmZ ddlmZ ddlm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G d
d dejjZdS )z7Healthy and unhealthy citrus fruits and leaves dataset.    )absolute_import)division)print_functionNa  
@article{rauf2019citrus,
  title={A citrus fruits and leaves dataset for detection and classification of
citrus diseases through machine learning},
  author={Rauf, Hafiz Tayyab and Saleem, Basharat Ali and Lali, M Ikram Ullah
and Khan, Muhammad Attique and Sharif, Muhammad and Bukhari, Syed Ahmad Chan},
  journal={Data in brief},
  volume={26},
  pages={104340},
  year={2019},
  publisher={Elsevier}
}
a"  
The original citrus dataset contains 759 images of healthy and unhealthy citrus
fruits and leaves. However, for now we only export 594 images of citrus leaves
with the following labels: Black Spot, Canker, Greening, and Healthy. The
exported images are in PNG format and have 256x256 pixels.

NOTE: Leaf images with Melanose label were dropped due to very small count and
other non-leaf images being present in the same directory.

Dataset URL: https://data.mendeley.com/datasets/3f83gxmv57/2
License: http://creativecommons.org/licenses/by/4.0
zehttps://data.mendeley.com/datasets/3f83gxmv57/2/files/6f809085-8c29-49f7-afbc-f90854fd45dc/Citrus.zip)z
Black spotcankergreeninghealthyc                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
CitrusLeavesz.Subset of the citrus dataset with just leaves.z0.1.0c              
   C   s>   t jj| tt jt j t j t jjt	ddddt
dS )N)namesimagezimage/filenamelabel)r   r   z/https://data.mendeley.com/datasets/3f83gxmv57/2)builderdescriptionfeaturessupervised_keyshomepagecitation)tfdscoreDatasetInfo_DESCRIPTIONr   FeaturesDictImageText
ClassLabel_LEAVES_LABELS	_CITATION)self r   c/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/citrus.py_info@   s   zCitrusLeaves._infoc                 C   s$   | t}tjjtjjd|idgS )zReturns SplitGenerators.datapath)name
gen_kwargs)download_and_extract_URLr   r   SplitGeneratorSplitTRAIN)r   
dl_managerpathr   r   r   _split_generatorsN   s
   
zCitrusLeaves._split_generatorsc                 c   sl    t D ]0}|dd}tj|d|d}tjj|D ]}tj	|}|||d}d
|||fV  qqdS )z0Yields examples based on the passed split index. z[_ ]zCitrus/Leavesz*.pngr
   z{}/{}N)r   replaceosr*   jointfiogfileglobbasenameformat)r   r!   r   fuzzy_label	glob_pathfpathfnamerecordr   r   r   _generate_examplesV   s   zCitrusLeaves._generate_examplesN)__name__
__module____qualname____doc__r   r   VersionVERSIONr    r+   r;   r   r   r   r   r   ;   s    r   )r?   
__future__r   r   r   r.   tensorflow.compat.v2compatv2r0   tensorflow_datasets.public_api
public_apir   r   r   r%   r   r   GeneratorBasedBuilderr   r   r   r   r   <module>   s   