a
    d9                     @   s6   d dl Z d dlZdd ZG dd de jZdd ZdS )    Nc                 C   s0   |   } d| v rdddddS dddddS d S )	NZvitgMb@?g?g\(\?gư>)lrZbeta1Zbeta2Zepsg+?g:0yE>)lower)Z
model_name r   X/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/training/params.pyget_default_params   s    r   c                   @   s   e Zd ZdddZdS )ParseKwargsNc              	   C   s`   i }|D ]D}| d\}}zt|||< W q tyJ   t|||< Y q0 qt|| j| d S )N=)splitastliteral_eval
ValueErrorstrsetattrdest)selfparser	namespacevaluesoption_stringkwvaluekeyr   r   r   __call__   s    zParseKwargs.__call__)N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c                 C   s  t  }|jdtd dd |jdtd dd |jdtd dd |jdtd d	d |jd
td dd |jdg dddd |jddddd |jdtddd |jdtddd |jdtddd |jdtd d d |jd!td d"d |jd#td$d%d |jd&ddd'd( |jd)td d*d |jd+td,d-d |jd.td/d0d |jd1td2d3d |jd4td d5d |jd6td d7d |jd8td d9d |jd:td d;d |jd<td d=d |jd>td?d@d |jdAtdBdCd |jdDdddEd |jdFdddGd( |jdHtdIdJd |jdKtdLdMd |jdNtdOdPd |jdQtd,dRd |jdSdddTd( |jdUtdVdWd |jdXtd,dYd |jdZd td[d\ |jd]g d^d_d`d |jdatdbdcd |jdddetdfd\ |jdgdddhd |jdidddjd |jdktdldmd |jdndddod |jdptdqd drdsdt |jdutdqd dvdwdt |jdxdyi tdz |jd{ddd|d |jd}ddd~d |jddddd |jdtdqd dd |jddddd |jdd tdd\ |jddddd |jddddd |jddddd |jddddd |jdtd,dd |jddtdd\ |jddtdd\ |jddetdd\ |jddetdd\ |jdtddd |jddddd |jddddd |jddddd |jddddd |jddddd |jdtdldd |jdtd dd |jddddd |jdtdldmd |jddddod |jdtddd |jdtddd |jdtdOdd |jdtd dd |jdtddd |jdddgddd |jddddd |jdd ddƍ |jdd ddƍ |jdd ddƍ || } t| j	}|
 D ]&\}}t| |d u rt| || q| S )Nz--train-datazyPath to file(s) with training data. When using webdataset, multiple datasources can be combined using the `::` separator.)typedefaulthelpz--train-data-upsampling-factorsaU  When using multiple data sources with webdataset and sampling with replacement, this can be used to upsample specific data sources. Similar to --train-data, this should be a string with as many numbers as there are data sources, separated by `::` (e.g. 1::2::0.5) By default, datapoints are sampled uniformly regardless of the dataset sizes.z
--val-dataz$Path to file(s) with validation dataz--train-num-sampleszTNumber of samples in dataset. Required for webdataset if not available in info file.z--val-num-sampleszRNumber of samples in dataset. Useful for webdataset if not available in info file.z--dataset-type)Z
webdatasetcsvZ	syntheticautor    z!Which type of dataset to process.)choicesr   r   z--dataset-resampledF
store_truezHWhether to use sampling with replacement for webdataset shard selection.)r   actionr   z--csv-separator	z.For csv-like datasets, which separator to use.z--csv-img-keyfilepathz?For csv-like datasets, the name of the key for the image paths.z--csv-caption-keytitlez<For csv-like datasets, the name of the key for the captions.z--imagenet-valz=Path to imagenet val set for conducting zero shot evaluation.z--imagenet-v2z8Path to imagenet v2 for conducting zero shot evaluation.z--logsz./logs/z@Where to store tensorboard logs. Use None to avoid storing logs.z--log-localz8log files on local master, otherwise global master only.)r#   r   r   z--namezUOptional identifier for the experiment when storing logs. Otherwise use current time.z	--workers   z%Number of dataloader workers per GPU.z--batch-size@   zBatch size per GPU.z--epochs    zNumber of epochs to train for.z--epochs-cooldownz^When scheduler w/ cooldown used, perform cooldown from total_epochs - cooldown_epochs onwards.z--lrzLearning rate.z--beta1zAdam beta 1.z--beta2zAdam beta 2.z--epszAdam epsilon.z--wdg?zWeight decay.z--warmupi'  zNumber of steps to warmup for.z--use-bn-synczWhether to use batch norm sync.z--skip-schedulerz.Use this flag to skip the learning rate decay.z--lr-schedulerZcosinezlLR scheduler. One of: 'cosine', 'const' (constant), 'const-cooldown' (constant w/ cooldown). Default: cosinez--lr-cooldown-endg        z3End learning rate for cooldown schedule. Default: 0z--lr-cooldown-powerg      ?zCPower for polynomial cooldown schedule. Default: 1.0 (linear decay)z--save-frequencyzHow often to save checkpoints.z--save-most-recentz=Always save the most recent model trained to epoch_latest.pt.z--zeroshot-frequency   zHow often to run zero shot.z--val-frequencyz*How often to run evaluation with val data.z--resumez)path to latest checkpoint (default: none))r   r   r   z--precision)ampZamp_bf16Zamp_bfloat16Zbf16Zfp16Z	pure_bf16Z	pure_fp16Zfp32r+   zFloating point precision.z--modelZRN50z#Name of the vision backbone to use.z--pretrained zHUse a pretrained CLIP model weights with the specified tag or file path.z--pretrained-imagezGLoad imagenet pretrained weights for image tower backbone if available.z--lock-imagez-Lock full image tower by disabling gradients.z--lock-image-unlocked-groupsr   z/Leave last n image tower layer groups unlocked.z--lock-image-freeze-bn-statszDFreeze BatchNorm running stats in image tower for any locked layers.z--image-mean+ZMEANz,Override default image mean value of dataset)r   nargsr   metavarr   z--image-stdZSTDz2Override default image std deviation of of datasetz	--aug-cfg*)r.   r   r#   z--grad-checkpointingzEnable gradient checkpointing.z--local-lossz\calculate loss w/ local features @ global (instead of realizing full global @ global matrix)z--gather-with-gradz3enable full distributed gradient for feature gatherz--force-image-sizezOverride default image size)r   r.   r   r   z--force-quick-geluzDForce use of QuickGELU activation for non-OpenAI transformer models.z--force-patch-dropoutzhOverride the patch dropout during training, for fine tuning with no dropout near the end as in the paperz--force-custom-textz8Force use of CustomTextCLIP model (separate text-tower).z--torchscriptzZtorch.jit.script the model, also uses jit version of OpenAI models if pretrained=='openai'z--torchcompilez9torch.compile() the model, requires pytorch 2.0 or later.z--tracez3torch.jit.trace the model for inference / eval onlyz--accum-freqz)Update the model every --acum-freq steps.z
--dist-urlzenv://z'url used to set up distributed trainingz--dist-backendZncclzdistributed backendz--report-toz9Options are ['wandb', 'tensorboard', 'wandb,tensorboard']z--wandb-noteszNotes if logging with wandbz--wandb-project-namez	open-clipz*Name of the project if logging with wandb.z--debugz$If true, more information is logged.z--copy-codebasezNIf true, we copy the entire base on the log directory, and execute from there.z	--horovodz%Use horovod for distributed training.z--ddp-static-graphz<Enable static graph optimization for DDP in PyTorch >= 1.11.z--no-set-device-rankz^Don't set device index from local rank (when CUDA_VISIBLE_DEVICES restricted to one per proc).z--seedzDefault random seed.z--grad-clip-normzGradient clip.z--lock-textz,Lock full text tower by disabling gradients.z--lock-text-unlocked-layersz--lock-text-freeze-layer-normz--log-every-n-stepsd   z/Log every n steps to tensorboard/console/wandb.z--coca-caption-loss-weightg       @z(Weight assigned to caption loss in CoCa.z--coca-contrastive-loss-weightz7Weight assigned to contrastive loss when training CoCa.z--remote-syncz8Optinoally sync with a remote path specified by this argz--remote-sync-frequencyi,  zIHow frequently to sync to a remote directly if --remote-sync is not None.z--remote-sync-protocolZs3Zfsspecz>How to do the remote sync backup if --remote-sync is not None.z--delete-previous-checkpointz<If true, delete previous checkpoint after storing a new one.z--distill-modelz)Which model arch to distill from, if any.)r   r   z--distill-pretrainedz2Which pre-trained weights to distill from, if any.z--use-bnb-linearzeReplace the network linear layers from the bitsandbytes library. Allows int8 training/inference, etc.)argparseArgumentParseradd_argumentr   intfloatr   
parse_argsr   modelitemsgetattrr   )argsr   Zdefault_paramsnamevalr   r   r   r7      s>   




r7   )r2   r
   r   Actionr   r7   r   r   r   r   <module>   s   	