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m  m	Z
 ddlmZ dZeedfZdZd	Zd
ZdZG dd dejjZdS )zQuickDraw dataset.    )absolute_import)division)print_functionN      zBhttps://storage.googleapis.com/quickdraw_dataset/full/numpy_bitmapz)image_classification/quickdraw_labels.txta  @article{DBLP:journals/corr/HaE17,
  author    = {David Ha and
               Douglas Eck},
  title     = {A Neural Representation of Sketch Drawings},
  journal   = {CoRR},
  volume    = {abs/1704.03477},
  year      = {2017},
  url       = {http://arxiv.org/abs/1704.03477},
  archivePrefix = {arXiv},
  eprint    = {1704.03477},
  timestamp = {Mon, 13 Aug 2018 16:48:30 +0200},
  biburl    = {https://dblp.org/rec/bib/journals/corr/HaE17},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}
z6https://github.com/googlecreativelab/quickdraw-datasetc                   @   s6   e Zd ZdZejddZdd Zdd Z	dd	 Z
d
S )QuickdrawBitmapzQuickdraw bitmap dataset.

  This is the version of the QuickDraw data in which 28x28 grayscale images
  are generated from the raw vector information (i.e. the 'bitmap' dataset, not
  the 'raw' or 'simplified drawings' datasets).
  z3.0.0z6New split API (https://tensorflow.org/datasets/splits)c              	   C   sF   t jt}t jj| dt jt jjtdt jj	|dddt
tdS )NzThe Quick Draw Dataset is a collection of 50 million drawings across 345 categories, contributed by players of the game Quick, Draw!. The bitmap dataset contains these drawings converted from vector format into 28x28 grayscale images)shape)
names_fileimagelabel)builderdescriptionfeaturessupervised_keyshomepagecitation)tfdscoreget_tfds_path_QUICKDRAW_LABELS_FNAMEDatasetInfor   FeaturesDictImage_QUICKDRAW_IMAGE_SHAPE
ClassLabel_URL	_CITATION)selflabels_path r    f/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image_classification/quickdraw.py_info?   s   zQuickdrawBitmap._infoc                 C   s@   | j jd j}dd |D }||}tjjtjjd|idgS )Nr   c                 S   s   i | ]	}|d  t|qS )z	{}/{}.npy)format_QUICKDRAW_BASE_URL).0r   r    r    r!   
<dictcomp>T   s    z5QuickdrawBitmap._split_generators.<locals>.<dictcomp>
file_paths)name
gen_kwargs)	infor   namesdownloadr   r   SplitGeneratorSplitTRAIN)r   
dl_managerlabelsurlsr'   r    r    r!   _split_generatorsQ   s   
z!QuickdrawBitmap._split_generatorsc           	   	   c   s    t | dd dD ];\}}tjj|d'}t|}t|D ]\}}|	t
|d}d||f |fV  q!W d   n1 sAw   Y  qdS )ac  Generate QuickDraw bitmap examples.

    Given a list of file paths with data for each class label, generate examples
    in a random order.

    Args:
      file_paths: (dict of {str: str}) the paths to files containing the data,
                  indexed by label.

    Yields:
      The QuickDraw examples, as defined in the dataset info features.
    c                 S   s   | d S )Nr   r    )xr    r    r!   <lambda>o   s    z4QuickdrawBitmap._generate_examples.<locals>.<lambda>)keyrbr
   z%s_%iN)sorteditemstfiogfileGFilenpload	enumeratereshaper   )	r   r'   r   pathfclass_imagesinp_imagerecordr    r    r!   _generate_examplesb   s   
z"QuickdrawBitmap._generate_examplesN)__name__
__module____qualname____doc__r   r   VersionVERSIONr"   r3   rH   r    r    r    r!   r   5   s    r   )rL   
__future__r   r   r   numpyr>   tensorflow.compat.v2compatv2r:   tensorflow_datasets.public_api
public_apir   _QUICKDRAW_IMAGE_SIZEr   r$   r   r   r   r   GeneratorBasedBuilderr   r    r    r    r!   <module>   s   
