o
    ϯiC                     @   s   d dl Z dd Zdd ZdS )    Nc                 C   s,   |   } d| v rdddddS dddddS )	NvitgMb@??g\(\?gư>)lrbeta1beta2epsg+?g:0yE>)lower)
model_name r
   N/home/ubuntu/.local/lib/python3.10/site-packages/laion_clap/training/params.pyget_default_params   s   r   c                  C   s  t  } | 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 dd | jdtd dd | jdtd dd | jdg 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(d)d d*d+ | jd,d)d d-d+ | jd.d)d d/d+ | jd0d)d d1d+ | jd2td3d4d | jd5ddd6d
 | jd7td d8d | jd9td:d;d | jd<td=d>d | jd?ddd@dA | jdBtd dCd | jdDtdEdFd | jdGtdHdId | jdJtdKdLd | jdMtd dNd | jdOtd dPd | jdQtd dRd | jdStd dTd | jdUtd dVd | jdWtdXdYd | jdZddd[dA | jd\td d]d | jd^td d_d | jd`td dad | jdbtd dcd | jddtdXded | jdftdgdhd | jditd djd | jdktd dld | jdmtd dnd | jdotd dpd | jdqtdXdrd | jdstdgdtd | jdutdvdwd | jdxdddyd
 | jdzddd[dA | jd{tdEd|d | jd}td~dd | jdddddA | jdtddd | jdtdEdd | jdd tdd | jdg dddd | jdtddd | jdtddd | jddtdd | jddtdd | jddtdd | jddddd
 | jddddd
 | jdtd~dd | jddddd
 | jddddd
 | jddddd
 | jddddd
 | jddddd
 | jddddd
 | jddtdd | jddtdd | jddtdd | jddt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ddd | jdtddd | jdtddd | jdtddd | jdtddd | jddddd
 | jddddd
 | jddddd
 | jddddd
 | jddtdd | jdtddd | jdtddd | jdtddd | jdtd~dd | jdtddd | jdtddd | jddddd
 | jdtd dd | jdtd~dd | jddddd
 | jdtddd | jddddd
 | jdtd dd | jdtd dd |  }t|j}|	 D ]\}}t
||d u rt||| q|S )Nz--train-dataz!Path to h5 filewith training data)typedefaulthelpz
--val-dataz$Path to h5 file with validation dataz--freeze-textF
store_truez6if you need to freeze the text encoder, make this True)r   actionr   z--freeze-text-afterziif you need to freeze the text encoder after (include) epoch x, set this param to x. Set -1 to disable itz--train-ipczEPath to npy file of the number of instance per class in training dataz	--val-ipczGPath to npy file of the number of instance per class in 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)
webdatasetcsvautotoyr   z!Which type of dataset to process.)choicesr   r   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--datasetnames+z|If loading webdataset, spedify the dataset names to load. Can be some of these: Clotho, audioset, audiocaps, BBCSoundEffects)nargsr   r   z--full-train-datasetz@Which dataset will be trained with all the subsets. (train+test)z--exclude-eval-datasetz.Which dataset will be excluded with evaluationz--datasetinfoszIf loading webdataset, spedify the dataset types to load. Can be some of these: train, test, valid, unbalanced_train, balanced_train, evalz--dataset-proportiong      ?z0How much proportion of dataset we want to train.z--remotedataz'if the dataset is remote, set this flagz--class-label-pathz*The path of the class label pickle or csv.z--datasetpathz/mnt/audio_clip/webdataset_tarzThe path to the datasetz--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 workers per GPU.z--batch-size@   zBatch size per GPU.z--epochs    zNumber of epochs to train for.z--lrzLearning rate.z--beta1zAdam beta 1.z--beta2zAdam beta 2.z--epszAdam epsilon.z
--momentumzSGD epsilon.z--wdg?zWeight decay.z--split-optz.Use this flag to skip the learning rate decay.z--lr-pretrainedzLearning rate for text.z--beta1-pretrainedzAdam beta 1 for text.z--beta2-pretrainedzAdam beta 2 for text.z--eps-pretrainedzAdam epsilon for text.z--wd-pretrainedzWeight decay for text.z--momentum-pretrainedr   zMomentum for text.z--lr-newzLearning rate for audio.z--beta1-newzAdam beta 1 for audio.z--beta2-newzAdam beta 2 for audio.z	--eps-newzAdam epsilon for audio.z--wd-newzWeight decay for audio.z--momentum-newzMomentum for audio.z--warmupi'  zNumber of steps to warmup for.z--use-bn-synczWhether to use batch norm sync.z--skip-schedulerz--save-frequencyzHow often to save checkpoints.z--save-top-performancer   z2Save the top x performance weights if the value >0z--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)ampfp16fp32r!   zFloating point precision.z--amodelRN50z"Name of the audio backbone to use.z--tmodeltransformerzKName of the text backbone to use. Can be [transformer, bert, roberta, bart]z--pretrained-audio zBUse a pretrained audio model weights for the audio encoder of CLAPz--pretrained-textz@Use a pretrained text model weights for the text encoder of CLAPz--pretrainedzHUse 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-groupsz/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--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-quick-geluzDForce use of QuickGELU activation for non-OpenAI transformer models.z--torchscriptzZtorch.jit.script the model, also uses jit version of OpenAI models if pretrained=='openai'z--tracez3torch.jit.trace the model for inference / eval onlyz
--dist-urlzenv://z'url used to set up distributed trainingz--dist-backendncclzdistributed backendz--report-toz9Options are ['wandb', 'tensorboard', 'wandb,tensorboard']z--wandb-noteszNotes if logging with wandbz--CgHzG	@z%inverse regularizer for logistic reg.z--debugz$If true, more information is logged.z--copy-codebasezMIf true, we copy the entire base on the log diretory, 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--seedi  zDefault random seed.z!--top-k-checkpoint-select-datasetallz*The dataset of selecting top-k checkpoint.z --top-k-checkpoint-select-metricz_R@10z*The metric for selecting top-k checkpoint.z--openai-model-cache-dirz~/.cache/clipz$Directory to download OpenAI models.z--optimizeradamwzcan be AdamW or SGDz--parallel-evalz)Eval in parallel (multi-GPU, multi-node).z	--no-evalzTraining without evaluation.z--lp-mlpz$Linear Probe using MLP layer or not.z--lp-freezez%Linear Probe using Freeze CLAP or notz--lp-actNonez6Options are ['relu','elu','prelu','softmax','sigmoid']z	--lp-lossbcezLoss func of Linear Probe.z--lp-metricszmap,mauc,acczMetrics of Linear Probe.z--lp-lrg-C6?zlearning rate of linear probez--kappaz`the kappa in the weighted contrastive loss, default is to turn off the weighted contrastive lossz--data-fillingpadz}type of data filling when the audio length is shorter than the max length.Can be one of the following: repeat, repeatpad, padz--data-truncating
rand_truncz{type of data truncation when the audio length is longer than the max length.Can be one of the following: rand_trunc, fusionz--clap-mlplossz$Using MLP loss for CLAP model or notz
--wandb-idz&the id of wandb experiment to restore.z--sleepz%sleep n seconds before start trainingz--enable-fusionz/Enable feature funsion for variable-length dataz--fusion-typezVType is among ['channel_map', 'daf_1d','aff_1d','iaff_1d','daf_2d','aff_2d','iaff_2d']z--mixupz$Enable mixup in finetuning training.z--text-augment-selectionzUFor selecting levels of augmented text. Type is among ['all', 'augment_only', 'none']z--prefetch-factorzYThe prefetch factor for dataloader. Larger value will use more memory and CPU but faster.)argparseArgumentParseradd_argumentstrintfloat
parse_argsr   amodelitemsgetattrsetattr)parserargsdefault_paramsnamevalr
   r
   r   r4      s"  
r4   )r.   r   r4   r
   r
   r
   r   <module>   s    	