a
    PSich	                     @   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)verify_str_argdownload_and_extract_archivec                       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 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
   validtest
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/django/DPS/env/lib/python3.9/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)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   