U
    ­Ê¹ja	  ã                   @   sL   d dl mZ d dlmZmZ ddlmZ ddlmZm	Z	 G dd„ deƒZ
dS )	é    )ÚPath)ÚCallableÚOptionalé   )ÚImageFolder)Údownload_and_extract_archiveÚverify_str_argc                       s^   e Zd ZdZdZdZdeeee ee e	ddœ‡ fdd	„Z
e	d
œdd„Zdd
œdd„Z‡  ZS )Ú
Country211a  `The Country211 Data Set <https://github.com/openai/CLIP/blob/main/data/country211.md>`_ from OpenAI.

    This dataset was built by filtering the images from the YFCC100m dataset
    that have GPS coordinate corresponding to a ISO-3166 country code. The
    dataset is balanced by sampling 150 train images, 50 validation images, and
    100 test images for each country.

    Args:
        root (string): Root directory of the dataset.
        split (string, optional): The dataset split, supports ``"train"`` (default), ``"valid"`` and ``"test"``.
        transform (callable, optional): A function/transform that  takes in an 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 into
            ``root/country211/``. If dataset is already downloaded, it is not downloaded again.
    z;https://openaipublic.azureedge.net/clip/data/country211.tgzZ 84988d7644798601126c29e9877aab6aÚtrainNF)ÚrootÚsplitÚ	transformÚtarget_transformÚdownloadÚreturnc                    sv   t |ddƒ| _t|ƒ ¡ }t|ƒ| _|d | _|r:|  ¡  |  ¡ sJt	dƒ‚t
ƒ jt| j| j ƒ||d� t|ƒ| _d S )Nr   )r
   ZvalidÚtestZ
country211z;Dataset not found. You can use download=True to download it)r   r   )r   Ú_splitr   Ú
expanduserÚstrr   Ú_base_folderÚ	_downloadÚ_check_existsÚRuntimeErrorÚsuperÚ__init__)Úselfr   r   r   r   r   ©Ú	__class__© ú^/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torchvision/datasets/country211.pyr      s    

zCountry211.__init__)r   c                 C   s   | j  ¡ o| j  ¡ S )N)r   ÚexistsÚis_dir©r   r   r   r   r   4   s    zCountry211._check_existsc                 C   s$   |   ¡ rd S t| j| j| jd� d S )N)Zdownload_rootÚmd5)r   r   Ú_URLr   Ú_MD5r"   r   r   r   r   7   s    zCountry211._download)r
   NNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r%   r   r   r   Úboolr   r   r   Ú__classcell__r   r   r   r   r	      s"       úùr	   N)Úpathlibr   Útypingr   r   Úfolderr   Úutilsr   r   r	   r   r   r   r   Ú<module>   s   