§
    ù²Åj  ã                   óv   — d dl Z d dlmZ d dlmZmZmZmZmZ d dl	Z
ddlmZmZ ddlmZ  G d„ de¦  «        ZdS )	é    N)ÚPath)ÚAnyÚCallableÚOptionalÚTupleÚUnioné   )Údownload_and_extract_archiveÚverify_str_arg)ÚVisionDatasetc                   óÂ   ‡ — e Zd ZdZdZdZ	 	 	 	 ddeeef         ded	e	e
         d
e	e
         deddfˆ fd„Zdefd„Zdedeeef         fd„Zdefd„Zdefd„Zdd„Zˆ xZS )ÚFood101a¼  `The Food-101 Data Set <https://data.vision.ee.ethz.ch/cvl/datasets_extra/food-101/>`_.

    The Food-101 is a challenging data set 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.


    Args:
        root (str or ``pathlib.Path``): Root directory of the dataset.
        split (string, optional): The dataset split, supports ``"train"`` (default) and ``"test"``.
        transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed
            version. E.g, ``transforms.RandomCrop``.
        target_transform (callable, optional): A function/transform that takes in the target and transforms it.
        download (bool, optional): If True, downloads the dataset from the internet and
            puts it in root directory. If dataset is already downloaded, it is not
            downloaded again. Default is False.
    z1http://data.vision.ee.ethz.ch/cvl/food-101.tar.gzÚ 85eeb15f3717b99a5da872d97d918f87ÚtrainNFÚrootÚsplitÚ	transformÚtarget_transformÚdownloadÚreturnc           
      óÌ  •‡ — t          ¦   «                              |||¬¦  «         t          |dd¦  «        ‰ _        t	          ‰ j        ¦  «        dz  ‰ _        ‰ j        dz  ‰ _        ‰ j        dz  ‰ _        |r‰  	                    ¦   «          ‰  
                    ¦   «         st          d¦  «        ‚g ‰ _        g ‰ _        t          ‰ j        |› d�z  ¦  «        5 }t          j        |                     ¦   «         ¦  «        }d d d ¦  «         n# 1 swxY w Y   t%          |                     ¦   «         ¦  «        ‰ _        t+          t-          ‰ j        t/          t1          ‰ j        ¦  «        ¦  «        ¦  «        ¦  «        ‰ _        |                     ¦   «         D ]M\  }}	‰ xj        ‰ j        |         gt1          |	¦  «        z  z  c_        ‰ xj        ˆ fd	„|	D ¦   «         z  c_        ŒNd S )
N)r   r   r   )r   Útestzfood-101ÚmetaÚimagesz;Dataset not found. You can use download=True to download itz.jsonc                 óZ   •— g | ]'} ‰j         j        |› d �                     d¦  «        Ž ‘Œ(S )z.jpgú/)Ú_images_folderÚjoinpathr   )Ú.0Úim_rel_pathÚselfs     €úMC:\Projects\Historical\venv\Lib\site-packages\torchvision/datasets/food101.pyú
<listcomp>z$Food101.__init__.<locals>.<listcomp>A   sK   ø€ ð "ð "ð "ØS^Ð,�Ô#Ô,°Ð.BÐ.BÐ.B×.HÒ.HÈÑ.MÔ.MÐNð"ð "ð "ó    )ÚsuperÚ__init__r   Ú_splitr   r   Ú_base_folderÚ_meta_folderr   Ú	_downloadÚ_check_existsÚRuntimeErrorÚ_labelsÚ_image_filesÚopenÚjsonÚloadsÚreadÚsortedÚkeysÚclassesÚdictÚzipÚrangeÚlenÚclass_to_idxÚitems)r!   r   r   r   r   r   ÚfÚmetadataÚclass_labelÚim_rel_pathsÚ	__class__s   `         €r"   r&   zFood101.__init__#   s  øø€ õ 	‰Œ×Ò˜¨ÐEUÐÑVÔVÐVÝ$ U¨GÐ5FÑGÔGˆŒÝ  ¤™OœO¨jÑ8ˆÔØ Ô-°Ñ6ˆÔØ"Ô/°(Ñ:ˆÔàð 	Ø�NŠNÑÔÐà×!Ò!Ñ#Ô#ð 	^ÝÐ\Ñ]Ô]Ð]àˆŒØˆÔÝ�$Ô#¨ o o oÑ5Ñ6Ô6ð 	,¸!Ý”z !§&¢&¡(¤(Ñ+Ô+ˆHð	,ð 	,ð 	,ñ 	,ô 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,øøøð 	,ð 	,ð 	,ð 	,õ ˜hŸmšm™oœoÑ.Ô.ˆŒÝ ¥ T¤\µ5½¸T¼\Ñ9JÔ9JÑ3KÔ3KÑ!LÔ!LÑMÔMˆÔà)1¯ªÑ)9Ô)9ð 	ð 	Ñ%ˆK˜ØˆLŒL˜TÔ.¨{Ô;Ð<½sÀ<Ñ?PÔ?PÑPÑPˆLŒLØÐÔð "ð "ð "ð "Øbnð"ñ "ô "ñ ÐÔÐð	ð 	s   Ã'DÄDÄDc                 ó*   — t          | j        ¦  «        S ©N)r9   r.   ©r!   s    r"   Ú__len__zFood101.__len__E   s   € Ý�4Ô$Ñ%Ô%Ð%r$   Úidxc                 ó  — | j         |         | j        |         }}t          j                             |¦  «                             d¦  «        }| j        r|                      |¦  «        }| j        r|                      |¦  «        }||fS )NÚRGB)r.   r-   ÚPILÚImager/   Úconvertr   r   )r!   rE   Ú
image_fileÚlabelÚimages        r"   Ú__getitem__zFood101.__getitem__H   s~   € Ø Ô-¨cÔ2°D´LÀÔ4E�Eˆ
Ý”	—’˜zÑ*Ô*×2Ò2°5Ñ9Ô9ˆàŒ>ð 	*Ø—N’N 5Ñ)Ô)ˆEàÔ ð 	1Ø×)Ò)¨%Ñ0Ô0ˆEà�eˆ|Ðr$   c                 ó   — d| j         › �S )Nzsplit=)r'   rC   s    r"   Ú
extra_reprzFood101.extra_reprT   s   € Ø%˜œÐ%Ð%Ð%r$   c                 óL   — t          d„ | j        | j        fD ¦   «         ¦  «        S )Nc              3   óf   K  — | ],}|                      ¦   «         o|                     ¦   «         V — Œ-d S rB   )ÚexistsÚis_dir)r   Úfolders     r"   ú	<genexpr>z(Food101._check_exists.<locals>.<genexpr>X   s7   è è € ÐnÐn¸6�6—=’=‘?”?Ð6 v§}¢}¡¤ÐnÐnÐnÐnÐnÐnr$   )Úallr)   r   rC   s    r"   r+   zFood101._check_existsW   s+   € ÝÐnÐnÀdÔFWÐY]ÔYlÐEmÐnÑnÔnÑnÔnÐnr$   c                 ót   — |                       ¦   «         rd S t          | j        | j        | j        ¬¦  «         d S )N)Údownload_rootÚmd5)r+   r
   Ú_URLr   Ú_MD5rC   s    r"   r*   zFood101._downloadZ   s<   € Ø×ÒÑÔð 	ØˆFÝ$ T¤Y¸d¼iÈTÌYÐWÑWÔWÐWÐWÐWr$   )r   NNF)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r[   r\   r   Ústrr   r   r   Úboolr&   ÚintrD   r   r   rN   rP   r+   r*   Ú__classcell__)r@   s   @r"   r   r      sP  ø€ € € € € ðð ð( ?€DØ-€Dð
 Ø(,Ø/3Øð ð  à�C˜�IÔð ð ð ð ˜HÔ%ð	 ð
 # 8Ô,ð ð ð ð 
ð ð  ð  ð  ð  ð  ðD&˜ð &ð &ð &ð &ð
˜sð 
 u¨S°#¨X¤ð 
ð 
ð 
ð 
ð&˜Cð &ð &ð &ð &ðo˜tð oð oð oð oðXð Xð Xð Xð Xð Xð Xð Xr$   r   )r0   Úpathlibr   Útypingr   r   r   r   r   Ú	PIL.ImagerH   Úutilsr
   r   Úvisionr   r   © r$   r"   ú<module>rk      sÈ   ðØ €€€Ø Ð Ð Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8à Ð Ð Ð à ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø !Ð !Ð !Ð !Ð !Ð !ðRXð RXð RXð RXð RXˆmñ RXô RXð RXð RXð RXr$   