o
    Ni                     @   sv   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d	ZG d
d dejjZdS )#Describable Textures Dataset (DTD).    )absolute_import)division)print_functionNa  @InProceedings{cimpoi14describing,
Author    = {M. Cimpoi and S. Maji and I. Kokkinos and S. Mohamed and A. Vedaldi},
Title     = {Describing Textures in the Wild},
Booktitle = {Proceedings of the {IEEE} Conf. on Computer Vision and Pattern Recognition ({CVPR})},
Year      = {2014}}
a  The Describable Textures Dataset (DTD) is an evolving collection of textural
images in the wild, annotated with a series of human-centric attributes,
inspired by the perceptual properties of textures. This data is made available
to the computer vision community for research purposes.

The "label" of each example is its "key attribute" (see the official website).
The official release of the dataset defines a 10-fold cross-validation
partition. Our TRAIN/TEST/VALIDATION splits are those of the first fold.
z4https://www.robots.ox.ac.uk/~vgg/data/dtd/index.htmlzDhttps://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gzc                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
Dtdr   z3.0.1c              
   C   sR   t jtjdd}t jj| tt j	t j
 t j t jj|ddttdS )Nimage_classificationzdtd_key_attributes.txt)
names_file	file_nameimagelabel)builderdescriptionfeatureshomepagecitation)tfdscoreget_tfds_pathospathjoinDatasetInfo_DESCRIPTIONr   FeaturesDictTextImage
ClassLabel_URL	_CITATION)selfr    r!   `/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/dtd.py_info6   s   z	Dtd._infoc                 C   sn   | tjjttjjjd}tjjtj	j
t|dddtjjtj	jt|dddtjjtj	jt|dddgS )N)urlextract_methodtrain1)	data_path
split_name)name
gen_kwargstest1val1)download_and_extractr   downloadResource	_DATA_URLExtractMethodTARr   SplitGeneratorSplitTRAINdictTEST
VALIDATION)r    
dl_managerr'   r!   r!   r"   _split_generatorsD   s$   



zDtd._split_generatorsc              	   c   s    t jjtj|dd|d d,}|D ] }| }tj|d }|tj|dd||d}||fV  qW d    d S 1 sAw   Y  d S )Ndtdlabelsz.txtrr   imagesr	   )	tfiogfileGFiler   r   r   stripsplit)r    r'   r(   
split_filelinefnamer   recordr!   r!   r"   _generate_examplesW   s    "zDtd._generate_examplesN)__name__
__module____qualname____doc__r   r   VersionVERSIONr#   r:   rI   r!   r!   r!   r"   r   1   s    r   )rM   
__future__r   r   r   r   tensorflow.compat.v2compatv2r?   tensorflow_datasets.public_api
public_apir   r   r   r   r0   r   GeneratorBasedBuilderr   r!   r!   r!   r"   <module>   s   
