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dZd	ZG d
d dejjZdS )z#Dataset class for Food-101 dataset.    )absolute_import)division)print_functionNz1http://data.vision.ee.ethz.ch/cvl/food-101.tar.gza  This dataset consists of 101 food categories, with 101'000 images. For each class, 250 manually reviewed test images are provided as well as 750 training images. On purpose, the training images were not cleaned, and thus still contain some amount of noise. This comes mostly in the form of intense colors and sometimes wrong labels. All images were rescaled to have a maximum side length of 512 pixels.z)image_classification/food-101_classes.txtz @inproceedings{bossard14,
  title = {Food-101 -- Mining Discriminative Components with Random Forests},
  author = {Bossard, Lukas and Guillaumin, Matthieu and Van Gool, Luc},
  booktitle = {European Conference on Computer Vision},
  year = {2014}
}
c                   @   sP   e Zd ZdZejdZejjdddejdgZdd Z	d	d
 Z
dd ZdS )Food101zFood-101 Images dataset.2.0.0z1.0.0(8cea22f06d74d5848608fe7ac6d6faac7bc05b55)tfds_version_to_preparez2.1.0c                 C   s^   t jt}t j t jj|dd}| jdkrt j |d< t jj	| t
t j|ddtdS )zDefine Dataset Info.)
names_fileimagelabelr   idz6https://www.vision.ee.ethz.ch/datasets_extra/food-101/)builderdescriptionfeaturessupervised_keyshomepagecitation)tfdscoreget_tfds_path_LABELS_FNAMEr   Image
ClassLabelversionTextDatasetInfo_DESCRIPTIONFeaturesDict	_CITATION)selfr	   features_dict r"   d/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/food101.py_info>   s   

zFood101._infoc                 C   sr   | t}tj|dd}tj|dd}tjjtjj	tj|d|ddtjjtjj
tj|d|ddgS )zDefine Splits.zfood-101metaimagesz
train.json)json_file_pathimage_dir_path)name
gen_kwargsz	test.json)download_and_extract	_BASE_URLospathjoinr   r   SplitGeneratorSplitTRAIN
VALIDATION)r    
dl_managerdl_path	meta_pathr(   r"   r"   r#   _split_generatorsP   s    
zFood101._split_generatorsc           
      c   s    t jj|}t| }W d   n1 sw   Y  | D ]%\}}|D ]}tj	
||d }||d}	| jdkrB||	d< ||	fV  q)q#dS )z&Generate images and labels for splits.Nz.jpgr
   r   r   )tfiogfileGFilejsonloadsreaditemsr-   r.   r/   r   )
r    r'   r(   fdatar   r&   
image_namer   r   r"   r"   r#   _generate_examplesi   s   

zFood101._generate_examplesN)__name__
__module____qualname____doc__r   r   VersionVERSIONSUPPORTED_VERSIONSr$   r7   rC   r"   r"   r"   r#   r   3   s    
r   )rG   
__future__r   r   r   r<   r-   tensorflow.compat.v2compatv2r8   tensorflow_datasets.public_api
public_apir   r,   r   r   r   r   GeneratorBasedBuilderr   r"   r"   r"   r#   <module>   s   
