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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 )z300W-LP Dataset.    )absolute_import)division)print_functionNzKhttps://drive.google.com/uc?export=download&id=0B7OEHD3T4eCkVGs0TkhUWFN6N1kzAhttp://www.cbsr.ia.ac.cn/users/xiangyuzhu/projects/3DDFA/main.htman  @article{DBLP:journals/corr/ZhuLLSL15,
  author    = {Xiangyu Zhu and
               Zhen Lei and
               Xiaoming Liu and
               Hailin Shi and
               Stan Z. Li},
  title     = {Face Alignment Across Large Poses: {A} 3D Solution},
  journal   = {CoRR},
  volume    = {abs/1511.07212},
  year      = {2015},
  url       = {http://arxiv.org/abs/1511.07212},
  archivePrefix = {arXiv},
  eprint    = {1511.07212},
  timestamp = {Mon, 13 Aug 2018 16:48:23 +0200},
  biburl    = {https://dblp.org/rec/bib/journals/corr/ZhuLLSL15},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}
a  300W-LP Dataset is expanded from 300W, which standardises multiple alignment databases with 68 landmarks, including AFW, LFPW, HELEN, IBUG and XM2VTS. With 300W, 300W-LP adopt the proposed face profiling to generate 61,225 samples across large poses (1,786 from IBUG, 5,207 from AFW, 16,556 from LFPW and 37,676 from HELEN, XM2VTS is not used).

The dataset can be employed as the training set for the following computer vision tasks: face attribute recognition and landmark (or facial part) locaization.
c                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
	The300wLpz300W-LP dataset.z1.0.0c                 C   s   t jj| tt jt jjdddt jjdtj	dt jjdtj	dt jjdtj	dt jjdtj	dt jjdtj	dt jjdtj	dt jjd	tj	dt jjd	tj	dt jjd
tj	dt jjdtj	ddt
tdS )N)  r      jpeg)shapeencoding_format)D      )r	   dtype)   )
   )   )   )   imagelandmarks_originlandmarks_2dlandmarks_3droiillum_paramscolor_params
tex_paramsshape_params
exp_paramspose_params)builderdescriptionfeatureshomepagecitation)tfdscoreDatasetInfo_DESCRIPTIONr!   FeaturesDictImageTensortffloat32_PROJECT_URL	_CITATION)self r0   X/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image/the300w_lp.py_infoF   s*   zThe300wLp._infoc                 C   s.   | t}tjjtjjdtj	|didgS )zReturns SplitGenerators.image_dir_path300W_LP)name
gen_kwargs)
download_and_extract_DATASET_URLr$   r%   SplitGeneratorSplitTRAINospathjoin)r/   
dl_managerextracted_pathr0   r0   r1   _split_generatorsg   s   
zThe300wLp._split_generatorsc                 c   s   t jjjtj|dd}dd |D }dd |D }t|||D ]\}}}t jj|d}t	j
jjj|}	W d   n1 sCw   Y  |	d j}
|
d	 tj}
|	d
 dtj}|	d dgtj}|	d dgtj}|	d dgtj}|	d dgtj}|	d dgtj}|	d dgtj}t jj|d%}t	j
jjj|}|d d	 tj}|d d	 tj}W d   n1 sw   Y  ||
|||||||||d}tj||fV  q"dS )zYields examples.z[!Code]*[!_Flip]/[!_]*.jpg)patternc                 S   s   g | ]}| d dqS )jpgmatreplace.0sr0   r0   r1   
<listcomp>v   s    z0The300wLp._generate_examples.<locals>.<listcomp>c                 S   s    g | ]}| d d ddqS )r4   z300W_LP/landmarksz.jpgz_pts.matrE   rG   r0   r0   r1   rJ   w   s    rbNpt2dg      |@r   r   
Illum_Para
Color_ParaTex_Para
Shape_ParaExp_Para	Pose_Parapts_2dpts_3dr   )r+   iogfileglobr<   r=   r>   zipGFiler$   r%   lazy_importsscipyloadmatTastypenpr,   reshapebasename)r/   r3   image_fileslabel_fileslandmark_files
image_file
label_filelandmark_filefrD   pt2d_originr   r   r   r   r   r   r   ldm_matrL   pt3drecordr0   r0   r1   _generate_examplesr   sT   
zThe300wLp._generate_examplesN)__name__
__module____qualname____doc__r$   r%   VersionVERSIONr2   rA   rn   r0   r0   r0   r1   r   A   s    !r   )rr   
__future__r   r   r   r<   numpyr`   tensorflow.compat.v2compatv2r+   tensorflow_datasets.public_api
public_apir$   r8   r-   r.   r'   r%   GeneratorBasedBuilderr   r0   r0   r0   r1   <module>   s   