
    QЦi                    z    S SK Jr  S SKrS SKJr  S SKJrJrJrJ	r	J
r
  S SKrSSKJrJr  SSKJr   " S S	\5      rg)
    )annotationsN)Path)AnyCallableOptionalTupleUnion   )download_and_extract_archiveverify_str_arg)VisionDatasetc                     ^  \ rS rSrSrSr     S
             SU 4S jjjrSS jrSS jrSS jr	SS jr
S	rU =r$ )FGVCAircraft   a  `FGVC Aircraft <https://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/>`_ Dataset.

The dataset contains 10,000 images of aircraft, with 100 images for each of 100
different aircraft model variants, most of which are airplanes.
Aircraft models are organized in a three-levels hierarchy. The three levels, from
finer to coarser, are:

- ``variant``, e.g. Boeing 737-700. A variant collapses all the models that are visually
    indistinguishable into one class. The dataset comprises 100 different variants.
- ``family``, e.g. Boeing 737. The dataset comprises 70 different families.
- ``manufacturer``, e.g. Boeing. The dataset comprises 30 different manufacturers.

Args:
    root (str or ``pathlib.Path``): Root directory of the FGVC Aircraft dataset.
    split (string, optional): The dataset split, supports ``train``, ``val``,
        ``trainval`` and ``test``.
    annotation_level (str, optional): The annotation level, supports ``variant``,
        ``family`` and ``manufacturer``.
    transform (callable, optional): A function/transform that takes in a 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 in root directory. If dataset is already downloaded, it is not
        downloaded again.
zWhttps://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/archives/fgvc-aircraft-2013b.tar.gzc           
     6  > [         TU ]  XUS9  [        USS5      U l        [        USS5      U l        [
        R                  R                  U R                  S5      U l	        U(       a  U R                  5         U R                  5       (       d  [        S5      e[
        R                  R                  U R                  SS	S
SS.U R                     5      n[        US5       nU V	s/ s H  oR                  5       PM     sn	U l        S S S 5        [!        [#        U R                  [%        ['        U R                  5      5      5      5      U l        [
        R                  R                  U R                  SS5      n
[
        R                  R                  U R                  SSU R                   SU R                   S35      n/ U l        / U l        [        US5       nU H  n	U	R                  5       R/                  SS5      u  pU R*                  R1                  [
        R                  R                  X S35      5        U R,                  R1                  U R(                  U   5        M     S S S 5        g s  sn	f ! , (       d  f       GNw= f! , (       d  f       g = f)N)	transformtarget_transformsplit)trainvaltrainvaltestannotation_level)variantfamilymanufacturerzfgvc-aircraft-2013bz;Dataset not found. You can use download=True to download itdatazvariants.txtzfamilies.txtzmanufacturers.txtrimagesimages__z.txt r
   z.jpg)super__init__r   _split_annotation_levelospathjoinroot
_data_path	_download_check_existsRuntimeErroropenstripclassesdictziprangelenclass_to_idx_image_files_labelsr   append)selfr*   r   r   r   r   downloadannotation_fileflineimage_data_folderlabels_file
image_name
label_name	__class__s                 a/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torchvision/datasets/fgvc_aircraft.pyr$   FGVCAircraft.__init__+   s    	EUV$UG5YZ!/02W"
 '',,tyy2GHNN!!##\]]'',,OO)( 3 $$	&
 /3'1567QTJJLQ7DL ( !T\\5T\\9J3K!LMGGLL&(Kggll4??FgdF\F\E]]^_c_j_j^kko<pq+s#q)-););C)C&
!!((6G<W[I\)]^##D$5$5j$AB  $# 8 (' $#s+   "I8'I3 I8BJ
3I88
J

Jc                ,    [        U R                  5      $ N)r5   r7   r:   s    rD   __len__FGVCAircraft.__len__[   s    4$$%%    c                &   U R                   U   U R                  U   p2[        R                  R	                  U5      R                  S5      nU R                  (       a  U R                  U5      nU R                  (       a  U R                  U5      nXC4$ )NRGB)r7   r8   PILImager/   convertr   r   )r:   idx
image_filelabelimages        rD   __getitem__FGVCAircraft.__getitem__^   sp     --c2DLL4EE		z*2259>>NN5)E  ))%0E|rK   c                p    U R                  5       (       a  g[        U R                  U R                  5        g)zG
Download the FGVC Aircraft dataset archive and extract it under root.
N)r-   r   _URLr*   rH   s    rD   r,   FGVCAircraft._downloadj   s(     $TYY		:rK   c                    [         R                  R                  U R                  5      =(       a)    [         R                  R	                  U R                  5      $ rG   )r'   r(   existsr+   isdirrH   s    rD   r-   FGVCAircraft._check_existsr   s/    ww~~doo.Q277==3QQrK   )r&   r+   r7   r8   r%   r6   r1   )r   r   NNF)r*   zUnion[str, Path]r   strr   r^   r   Optional[Callable]r   r_   r;   boolreturnNone)ra   int)rQ   rc   ra   zTuple[Any, Any])ra   rb   )ra   r`   )__name__
__module____qualname____firstlineno____doc__rX   r$   rI   rU   r,   r-   __static_attributes____classcell__)rC   s   @rD   r   r      s    6 eD
   )(,/3.C.C .C 	.C
 &.C -.C .C 
.C .C`&
;R RrK   r   )
__future__r   r'   pathlibr   typingr   r   r   r   r	   	PIL.ImagerN   utilsr   r   visionr   r    rK   rD   <module>rr      s-    " 	  8 8  ? !fR= fRrK   