
    hh                    r    S SK Jr  S SKrS SKJr  S SKJrJr  SSKJ	r	  SSK
JrJr  SSKJr   " S	 S
\5      rg)    )annotationsN)Path)AnyCallable   )default_loader)download_and_extract_archiveverify_str_arg)VisionDatasetc                     ^  \ rS rSrSrSrSSSSS\4               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 or torch.Tensor, depends on the given loader,
        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.
    loader (callable, optional): A function to load an image given its path.
        By default, it uses PIL as its image loader, but users could also pass in
        ``torchvision.io.decode_image`` for decoding image data into tensors directly.
zWhttps://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/archives/fgvc-aircraft-2013b.tar.gztrainvalvariantNFc           
     >  > [         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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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        Xpl        g s  sn
f ! , (       d  f       GN|= f! , (       d  f       N,= f)N)	transformtarget_transformsplit)trainvalr   testannotation_level)r   familymanufacturerzfgvc-aircraft-2013bz;Dataset not found. You can use download=True to download itdatazvariants.txtzfamilies.txtzmanufacturers.txt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loader)selfr'   r   r   r   r   downloadr7   annotation_fileflineimage_data_folderlabels_file
image_name
label_name	__class__s                  Z/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/fgvc_aircraft.pyr!   FGVCAircraft.__init__.   s    	EUV$UG5YZ!/02W"
 '',,tyy2GHNN!!##\]]'',,OO)( 3 $$	&
 /"a567QTJJLQ7DL # !T\\5T\\9J3K!LMGGLL&(Kggll4??FgdF\F\E]]^_c_j_j^kko<pq+!)-););C)C&
!!((6G<W[I\)]^##D$5$5j$AB  
  8 #" s+   !I<&I7?I<BJ7I<<
J
Jc                ,    [        U R                  5      $ N)r2   r4   r8   s    rB   __len__FGVCAircraft.__len__`   s    4$$%%    c                    U R                   U   U R                  U   p2U R                  U5      nU R                  (       a  U R                  U5      nU R                  (       a  U R	                  U5      nXC4$ rE   )r4   r5   r7   r   r   )r8   idx
image_filelabelimages        rB   __getitem__FGVCAircraft.__getitem__c   sa     --c2DLL4EEJ'>>NN5)E  ))%0E|rI   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'   rF   s    rB   r)   FGVCAircraft._downloado   s(     $TYY		:rI   c                    [         R                  R                  U R                  5      =(       a)    [         R                  R	                  U R                  5      $ rE   )r$   r%   existsr(   isdirrF   s    rB   r*   FGVCAircraft._check_existsw   s/    ww~~doo.Q277==3QQrI   )r#   r(   r4   r5   r"   r3   r.   r7   )r'   z
str | Pathr   strr   rX   r   Callable | Noner   rY   r9   boolr7   zCallable[[str], Any]returnNone)r[   int)rK   r]   r[   ztuple[Any, Any])r[   r\   )r[   rZ   )__name__
__module____qualname____firstlineno____doc__rR   r   r!   rG   rO   r)   r*   __static_attributes____classcell__)rA   s   @rB   r   r      s    < eD
   )%),0'500 0 	0
 #0 *0 0 %0 
0 0d&
;R RrI   r   )
__future__r   r$   pathlibr   typingr   r   folderr   utilsr	   r
   visionr   r    rI   rB   <module>rl      s*    " 	    " ? !kR= kRrI   