
    RЦi!                        S r SSKrSSKJr  SSKJrJrJrJrJ	r	J
r
   SSKJr  Sr SSKJr  Sr SS	KJr  Sr SS
KJr  SrSSKJrJr  \" \\\\\	S9r\" SSS9r\" SSSSSS9rS r             S S\S\\   S\S\S\S\S\S\S\S\\   S\S\S\S\4S jjrg! \ a    Sr Nf = f! \ a    Sr Nf = f! \ a    Sr Nf = f! \ a    Sr Nf = f)!zDDataset Factory

Hacked together by / Copyright 2021, Ross Wightman
    N)Optional)CIFAR100CIFAR10MNISTKMNISTFashionMNISTImageFolder)	Places365TF)INaturalist)QMNIST)ImageNet   )IterableImageDatasetImageDataset)cifar10cifar100mnistkmnistfashion_mnist)traintraining)valvalid
validationeval
evaluationc                 $  ^  UR                  S5      S   n[        R                  R                  T U5      n[        R                  R	                  U5      (       a  U$ U 4S jnU[
        ;   a  U" [
        5      m T $ U[        ;   a  U" [        5      m T $ )N[r   c                    > U  HK  n[         R                  R                  TU5      n[         R                  R                  U5      (       d  MI  Us  $    T$ )N)ospathjoinexists)synstry_rootroots      X/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/timm/data/dataset_factory.py_try_search_split.<locals>._try2   s@    Aww||D!,Hww~~h''      )splitr    r!   r"   r#   _TRAIN_SYNONYM_EVAL_SYNONYM)r'   r,   
split_namer&   r)   s   `    r(   _search_splitr0   +   s{    S!!$Jww||D*-H	ww~~h ^#N# K 
}	$M"Kr+   namer'   r,   search_split	class_map
load_bytesis_trainingdownload
batch_sizenum_samplesseedrepeatsinput_img_modetrust_remote_codec                    UR                  5        VVs0 s H  u  nnUc  M  UU_M     nnnU R                  5       n U R                  S5      (       Ga  U R                  SS5      S   n [	        S'XS.UD6nU [
        ;   a  [
        U    nU[        ;   nU" S'SU0UD6nU$ U S:X  d  U S:X  a  [        (       d   S	5       eS
nUR                  S5      n[        U5      S:  a-  US   R                  S5      n[        U5      S:X  a  US   nUS   nU[        ;   a  SnOU[        ;   a  Sn[        S'UUS.UD6nU$ U S:X  a:  [        (       d   S5       eU[        ;   a  SnOU[        ;   a  Sn[        S'SU0UD6nU$ U S:X  a*  [        (       d   S5       eU[        ;   n[        S'SU0UD6nU$ U S:X  a>  UR                  S5        [         (       d   S5       eU[        ;   a  Sn[#        S'SU0UD6nU$ U S:X  d  U S:X  aD  U(       a/  [$        R&                  R)                  U5      (       a  [+        X5      n[-        U40 UD6nU$  SU  35       eU R                  S5      (       a  [/        U4U UUUUS.UD6nU$ U R                  S 5      (       a  [1        U4U UUUUUU	UU
UUS!.UD6nU$ U R                  S"5      (       a  [1        U4U UUUUUU	UU
US#.
UD6nU$ U R                  S$5      (       a  [1        U4U UUUUU	UU
US%.	UD6nU$ U(       a/  [$        R&                  R)                  U5      (       a  [+        X5      n[/        U4U UUUS&.UD6nU$ s  snnf )(a  Dataset factory method

In parentheses after each arg are the type of dataset supported for each arg, one of:
  * Folder - default, timm folder (or tar) based ImageDataset
  * Torch - torchvision based datasets
  * HFDS - Hugging Face Datasets
  * HFIDS - Hugging Face Datasets Iterable (streaming mode, with IterableDataset)
  * TFDS - Tensorflow-datasets wrapper in IterabeDataset interface via IterableImageDataset
  * WDS - Webdataset
  * All - any of the above

Args:
    name: Dataset name, empty is okay for folder based datasets
    root: Root folder of dataset (All)
    split: Dataset split (All)
    search_split: Search for split specific child fold from root so one can specify
        `imagenet/` instead of `/imagenet/val`, etc on cmd line / config. (Folder, Torch)
    class_map: Specify class -> index mapping via text file or dict (Folder)
    load_bytes: Load data, return images as undecoded bytes (Folder)
    download: Download dataset if not present and supported (HFIDS, TFDS, Torch)
    is_training: Create dataset in train mode, this is different from the split.
        For Iterable / TDFS it enables shuffle, ignored for other datasets. (TFDS, WDS, HFIDS)
    batch_size: Batch size hint for iterable datasets (TFDS, WDS, HFIDS)
    seed: Seed for iterable datasets (TFDS, WDS, HFIDS)
    repeats: Dataset repeats per iteration i.e. epoch (TFDS, WDS, HFIDS)
    input_img_mode: Input image color conversion mode e.g. 'RGB', 'L' (folder, TFDS, WDS, HFDS, HFIDS)
    trust_remote_code: Trust remote code in Hugging Face Datasets if True (HFDS, HFIDS)
    **kwargs: Other args to pass through to underlying Dataset and/or Reader classes

Returns:
    Dataset object
ztorch//   )r'   r6   r   inaturalistinatz@Please update to PyTorch 1.10, torchvision 0.11+ for Inaturalistfullr   r   _
2021_train
2021_valid)versiontarget_type	places365zGPlease update to a newer PyTorch and torchvision for Places365 dataset.ztrain-standardr   r,   qmnistzDPlease update to a newer PyTorch and torchvision for QMNIST dataset.imagenetr6   zFPlease update to a newer PyTorch and torchvision for ImageNet dataset.image_folderfolderzUnknown torchvision dataset zhfds/)readerr,   r3   r;   r<   zhfids/)rN   r,   r3   r5   r6   r7   r8   r:   r9   r;   r<   ztfds/)
rN   r,   r3   r5   r6   r7   r8   r:   r9   r;   zwds/)	rN   r,   r3   r5   r7   r8   r:   r9   r;   )rN   r3   r4   r;    )itemslower
startswithr,   dict_TORCH_BASIC_DSr-   has_inaturalistlenr.   r   has_places365r
   
has_qmnistr   pophas_imagenetr   r    r!   isdirr0   r	   r   r   )r1   r'   r,   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   kwargskvtorch_kwargsds_class	use_traindsrH   split_splits                          r(   create_datasetrd   ?   s   b  &||~?~tq!dad~F?::<Dx  zz#q!"%CCFC?"&t,H/I:	:\:B\ I[ ]"dfn"?f$ff? K++c*K;!#)!n2237{#q("-a.K#B&$-'$TUT|TB@ I [  =k"kk=&(-'77,7Br Iq X:eee:/I8i8<8Bj Ii ZZ(<i!ii<%666B^ I] ^#tx'7d 3 3$T1T,V,BR IO @8??5		!	! 
)/
 
F Iu 
	"	"!
#!#)/
 
r IU 
	!	!!
#!#)
 
R I7 
	 	 !
#!#)
 
4 I BGGMM$// -D
!)
 
 Im @s
   
MM)Nr   TNFFFr   N*   r   RGBF) __doc__r    typingr   torchvision.datasetsr   r   r   r   r   r	   r
   rW   ImportErrorr   rU   r   rX   r   rZ   datasetr   r   rS   rT   r-   r.   r0   strboolintrd   rO   r+   r(   <module>ro      s   
  \ \.M0O+J-L 8
 D40TdRVW, #!! !%)#"'ggsmg g 	g
 g g g g g c]g g g g  gg  M
  O
  J
  LsD   B B, B: C B)(B),B76B7:CCCC