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Zddl	m
  mZ ddlmZ dZdZdZd	Zd
ZdZdZG dd dejjZdS )WIDER FACE Dataset.    )absolute_import)division)print_functionNz!http://shuoyang1213.me/WIDERFACE/zKhttps://drive.google.com/uc?export=download&id=0B6eKvaijfFUDQUUwd21EckhUbWszKhttps://drive.google.com/uc?export=download&id=0B6eKvaijfFUDd3dIRmpvSk8tLUkzKhttps://drive.google.com/uc?export=download&id=0B6eKvaijfFUDbW4tdGpaYjgzZkUzPhttps://drive.google.com/uc?export=download&id=1sAl2oml7hK6aZRdgRjqQJsjV5CEr7nl4a   
@inproceedings{yang2016wider,
	Author = {Yang, Shuo and Luo, Ping and Loy, Chen Change and Tang, Xiaoou},
	Booktitle = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
	Title = {WIDER FACE: A Face Detection Benchmark},
	Year = {2016}}
a  
WIDER FACE dataset is a face detection benchmark dataset, of which images are 
selected from the publicly available WIDER dataset. We choose 32,203 images and 
label 393,703 faces with a high degree of variability in scale, pose and 
occlusion as depicted in the sample images. WIDER FACE dataset is organized 
based on 61 event classes. For each event class, we randomly select 40%/10%/50% 
data as training, validation and testing sets. We adopt the same evaluation 
metric employed in the PASCAL VOC dataset. Similar to MALF and Caltech datasets,
we do not release bounding box ground truth for the test images. Users are 
required to submit final prediction files, which we shall proceed to evaluate.
c                   @   s4   e Zd ZdZejdZdd Zdd Z	dd Z
d	S )
	WiderFacer   z0.1.0c                 C   sd   t jjddt j t jt j tjtjtjtjtjtjdd}t j	j
| tt j|ttdS )Njpeg)encoding_formatbboxblur
expressionillumination	occlusionposeinvalidimagezimage/filenamefaces)builderdescriptionfeatureshomepagecitation)tfdsr   ImageTextSequenceBBoxFeaturetfuint8boolcoreDatasetInfo_DESCRIPTIONFeaturesDict_PROJECT_URL	_CITATION)selfr    r(   c/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/object_detection/wider_face.py_infoE   s&   
zWiderFace._infoc                 C   s`   | ttttd}tjjtjj	d|ddtjjtjj
d|ddtjjtjjd|ddgS )zReturns SplitGenerators.)wider_train	wider_val
wider_testwider_annottrain)splitextracted_dirs)name
gen_kwargsvaltest)download_and_extract_WIDER_TRAIN_URL_WIDER_VAL_URL_WIDER_TEST_URL_WIDER_ANNOT_URLr   r!   SplitGeneratorSplitTRAIN
VALIDATIONTEST)r'   
dl_managerr1   r(   r(   r)   _split_generators^   s2   zWiderFace._split_generatorsc           #      c   sB   t d}t d}d}|dkrdnd| d }tj||}tj|d|  d	| d
}|d }tj||}	tjj|	d}
	 |
	 }|
|}|du rQn|d}tj||}g }|dkrtjj|d}tjjj|}|j\}}W d   n1 sw   Y  t|
	 }|dkr|
	  njt|D ]e}|
	 }|
|}|std| tt| \
}}}}}}}}}}tj|| d|d} tj|| d|d}!tj|d|d}tj|d|d}|tjj|| || | | |!| d||||||d q|||d}"||"fV  qCW d   dS 1 sw   Y  dS )zYields examples.z
(.*.jpg)\nz>(\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) \nwider_face_splitr5   zwider_face_test_filelist.txtwider_face_z_bbx_gt.txtwider_WIDER_imagesr.   rTN   rbr   zCannot parse: %s)a_mina_max)yminxminymaxxmaxr	   r   )recompileospathjoinr   iogfileGFilereadlinematchgroupr   r!   lazy_imports	PIL_Imageopensizeintrange
ValueErrormapgroupsnpclipappendr   BBox)#r'   r0   r1   pattern_fnamepattern_annot	annot_dirannot_fname
annot_file	image_dir
annot_pathflinerY   fnameimage_fullpathr   fpr   widthheightnbbox_rM   rL   wboxhboxr   r   r   r   r   r   rN   rO   recordr(   r(   r)   _generate_examples{   s   









$zWiderFace._generate_examplesN)__name__
__module____qualname____doc__r   r!   VersionVERSIONr*   rA   r{   r(   r(   r(   r)   r   @   s    r   )r   
__future__r   r   r   rR   rP   numpyrd   tensorflow.compat.v2compatv2r   tensorflow_datasets.public_api
public_apir   r%   r7   r8   r9   r:   r&   r#   r!   GeneratorBasedBuilderr   r(   r(   r(   r)   <module>   s"   