MCPcopy Create free account

hub / github.com/FarinaMatteo/rethinking_fewshot_vlms / functions

Functions188 in github.com/FarinaMatteo/rethinking_fewshot_vlms

↓ 21 callersMethodgenerate_fewshot_dataset
Generate a few-shot dataset (typically for the training set). This function is useful when one wants to evaluate a model in a few-sho
datasets/utils.py:250
↓ 21 callersMethodload_preprocessed_jsonl
(preprocessed: str)
datasets/oxford_pets.py:81
↓ 20 callersMethodtranspose
(self, w: torch.Tensor)
loralib/layers.py:70
↓ 12 callersMethod__init__
( self, in_channels: int, out_channels: int, kernel_size: int, r: in
loralib/layers.py:212
↓ 11 callersMethodforward
(self, x: torch.Tensor, **kwargs)
loralib/layers.py:243
↓ 10 callersMethodbase2new_split
(train, val, test)
datasets/oxford_pets.py:64
↓ 10 callersMethodtrain
(self, mode: bool = True)
loralib/layers.py:239
↓ 9 callersMethodread_split
(filepath, path_prefix)
datasets/oxford_pets.py:164
↓ 8 callersMethodencode_text
(self, text)
clip/model.py:348
↓ 7 callersFunctioncls_acc
(output, target, topk=1)
fs/utils/eval_utils.py:7
↓ 7 callersMethodencode_image
(self, image)
clip/model.py:345
↓ 7 callersFunctionevaluate
(clip_model, loader, template, classnames)
fs/utils/eval_utils.py:74
↓ 7 callersMethodsub_lora_data
r"""NOT differentiable
loralib/layers.py:94
↓ 6 callersMethod__init__
(self, embed_dim: int, # vision image_resolution: int,
clip/model.py:249
↓ 6 callersMethodlora_train
(self, mode: bool = True)
loralib/layers.py:100
↓ 6 callersMethodmerge_lora_param
r"""p_new = p + scaling * B @ A and keep differentiable to A and B
loralib/layers.py:80
↓ 5 callersMethodinit_lora_param
(self)
loralib/layers.py:63
↓ 5 callersFunctiontokenize_texts
(template, classnames, device='cuda')
fs/utils/eval_utils.py:96
↓ 4 callersMethod_make_layer
(self, planes, blocks, stride=1)
clip/model.py:126
↓ 4 callersFunctionbuild_data_loader
( data_source=None, data_root='', batch_size=64, input_size=224, tfm=None, is_train=Tr
datasets/utils.py:410
↓ 4 callersMethodget_lab2cname
Get a label-to-classname mapping (dict). Args: data_source (list): a list of Datum objects.
datasets/utils.py:201
↓ 4 callersMethodmerge_BA
(self, param_name: str)
loralib/layers.py:73
↓ 4 callersMethodsubsample_classes
Divide classes into two groups. The first group represents base classes while the second group represents new classes. Args:
datasets/oxford_pets.py:187
↓ 3 callersFunctionevaluate_selective_inference
( model: SingleStreamClassifier, loader: torch.utils.data.DataLoader, template: str, classn
fs/twostage.py:117
↓ 3 callersMethodread_data
(self, cname2lab, split_file)
datasets/fgvc.py:61
↓ 2 callersFunction_transform
(n_px)
clip/clip.py:76
↓ 2 callersMethod_transform_image
(self, tfm, img0)
datasets/utils.py:397
↓ 2 callersFunctionapply_lora
(args, clip_model, verbose=True)
loralib/utils.py:107
↓ 2 callersFunctionbytes_to_unicode
Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you
clip/simple_tokenizer.py:16
↓ 2 callersFunctionclip_classifier
(classnames, template, clip_model)
fs/utils/eval_utils.py:15
↓ 2 callersFunctionget_lora_parameters
(model, bias='none')
loralib/utils.py:86
↓ 2 callersFunctionget_pairs
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
clip/simple_tokenizer.py:38
↓ 2 callersMethodis_input_domain_valid
(self, input_domains)
datasets/utils.py:220
↓ 2 callersFunctionlistdir_nohidden
List non-hidden items in a directory. Args: path (str): directory path. sort (bool): sort the items.
datasets/utils.py:71
↓ 2 callersFunctionmark_only_lora_as_trainable
(model: nn.Module, bias: str = 'none')
loralib/utils.py:47
↓ 2 callersFunctionnamed_modules_with_index
(clip_model: nn.Module)
fs/utils/model_utils.py:6
↓ 2 callersFunctionpatch_device
(module)
clip/clip.py:144
↓ 2 callersFunctionpatch_float
(module)
clip/clip.py:168
↓ 2 callersMethodread_data
(self, classnames, split_dir)
datasets/imagenet.py:265
↓ 2 callersFunctionread_json
Read json file from a path.
datasets/utils.py:33
↓ 2 callersMethodregister_lora_param
r"""Register LoRA matrix
loralib/layers.py:50
↓ 2 callersFunctionset_param
r"""Refer to https://github.com/Baijiong-Lin/MOML/blob/main/MTL/utils.py
loralib/layers.py:11
↓ 2 callersFunctiontrainable_norm_params
(model, modality='both', vision_start=0, text_start=0)
fs/utils/model_utils.py:26
↓ 1 callersFunction_download
(url: str, root: str)
clip/clip.py:40
↓ 1 callersMethod_init_classifier
(self, template, classnames)
fs/twostage.py:59
↓ 1 callersMethodadd_lora_data
r"""NOT differentiable
loralib/layers.py:89
↓ 1 callersMethodattention
(self, x: torch.Tensor)
clip/model.py:182
↓ 1 callersFunctionavailable_models
Returns the names of available CLIP models
clip/clip.py:86
↓ 1 callersFunctionbasic_clean
(text)
clip/simple_tokenizer.py:50
↓ 1 callersMethodbpe
(self, token)
clip/simple_tokenizer.py:80
↓ 1 callersMethodbuild_attention_mask
(self)
clip/model.py:333
↓ 1 callersFunctionbuild_dataloaders
(args, dataset, preprocess)
datasets/__init__.py:36
↓ 1 callersFunctionbuild_dataset
(dataset, root_path, shots, setting, seed)
datasets/__init__.py:32
↓ 1 callersFunctionbuild_model
(state_dict: dict)
clip/model.py:404
↓ 1 callersFunctionconvert_weights
Convert applicable model parameters to fp16
clip/model.py:380
↓ 1 callersMethoddecode
(self, tokens)
clip/simple_tokenizer.py:129
↓ 1 callersFunctiondefault_bpe
()
clip/simple_tokenizer.py:11
↓ 1 callersFunctiondict2datum
(item: dict)
datasets/utils.py:24
↓ 1 callersFunctiondump
(result: dict, args: dict, decimals: int = 4)
fs/utils/eval_utils.py:102
↓ 1 callersMethodencode
(self, text)
clip/simple_tokenizer.py:121
↓ 1 callersMethodforward
(self, image, text)
clip/model.py:363
↓ 1 callersMethodforward_module
( self, query, key, value, key_padding_mask=None,
loralib/layers.py:425
↓ 1 callersFunctionget_arguments
()
main.py:31
↓ 1 callersMethodget_num_classes
Count number of classes. Args: data_source (list): a list of Datum objects.
datasets/utils.py:190
↓ 1 callersFunctionhmean
(a, b)
summarize.py:24
↓ 1 callersMethodinfer
(self, x: torch.Tensor, categories: list[str], template: str = "a photo of {}."
fs/twostage.py:80
↓ 1 callersMethodinit_lora_param
(self)
loralib/layers.py:132
↓ 1 callersMethodinitialize_parameters
(self)
clip/model.py:304
↓ 1 callersFunctionlistdir_nohidden
List non-hidden items in a directory. Args: path (str): directory path. sort (bool): sort the items.
datasets/imagenet.py:196
↓ 1 callersFunctionload_jsonl
Load a .jsonl file and return a list of dictionaries.
datasets/utils.py:17
↓ 1 callersFunctionmain
(args)
summarize.py:28
↓ 1 callersFunctionmain
(args)
main.py:94
↓ 1 callersFunctionnum_params
(model, trainable=True)
fs/utils/model_utils.py:59
↓ 1 callersFunctionparse_path
(path: Path)
summarize.py:19
↓ 1 callersFunctionpre_load_features
(clip_model, loader)
fs/utils/eval_utils.py:33
↓ 1 callersFunctionprepare_for_first_stage
(clip_model, args)
fs/twostage.py:12
↓ 1 callersMethodread_classnames
Return a dictionary containing key-value pairs of <folder name>: <class name>.
datasets/imagenet.py:250
↓ 1 callersFunctionread_image
Read image from path using ``PIL.Image``. Args: path (str): path to an image. Returns: PIL image
datasets/utils.py:48
↓ 1 callersFunctionreproducible_setup
(seed)
main.py:21
↓ 1 callersFunctionsave_lora
(args, list_lora_layers)
loralib/utils.py:137
↓ 1 callersMethodsplit_dataset_by_label
Split a dataset, i.e. a list of Datum objects, into class-specific groups stored in a dictionary. Args: data_source (list
datasets/utils.py:294
↓ 1 callersFunctiontrain_epoch
(clip_model, optimizer, scheduler, scaler, train_loader, tokenized_texts, count_iters, total_iters, args)
fs/twostage.py:192
↓ 1 callersFunctiontrain_epoch
(clip_model, optimizer, scheduler, scaler, train_loader, tokenized_texts, count_iters, total_iters, args)
fs/ln_only.py:9
↓ 1 callersFunctiontrain_epoch_second_stage
(model, optimizer, scheduler, scaler, train_loader, count_iters, total_iters)
fs/twostage.py:145
↓ 1 callersFunctiontrainable_bias_params
(model, modality='both', vision_start=0, text_start=0)
fs/utils/model_utils.py:41
↓ 1 callersFunctionwhitespace_clean
(text)
clip/simple_tokenizer.py:56
↓ 1 callersFunctionwrite_json
Writes to a json file.
datasets/utils.py:40
↓ 1 callersMethodzero_pad
(self, x)
loralib/layers.py:572
Method__getitem__
(self, idx)
datasets/utils.py:362
Method__init__
(self, bpe_path: str = default_bpe())
clip/simple_tokenizer.py:63
Method__init__
(self, inplanes, planes, stride=1)
clip/model.py:13
Method__init__
(self, spacial_dim: int, embed_dim: int, num_heads: int, output_dim: int = None)
clip/model.py:57
Method__init__
(self, layers, output_dim, heads, input_resolution=224, width=64)
clip/model.py:101
Method__init__
(self, d_model: int, n_head: int, attn_mask: torch.Tensor = None, save_last: bool = False)
clip/model.py:168
Method__init__
(self, width: int, layers: int, heads: int, attn_mask: torch.Tensor = None)
clip/model.py:195
Method__init__
(self, input_resolution: int, patch_size: int, width: int, layers: int, heads: int, output_dim: int)
clip/model.py:212
Method__init__
(self, root, num_shots, setting="standard", seed=1)
datasets/fgvc.py:14
Method__init__
(self, root, num_shots, setting="standard", seed=1)
datasets/imagenet.py:214
Method__init__
(self, impath='', label=0, domain=-1, classname='')
datasets/utils.py:94
Method__init__
(self, train_x=None, train_u=None, val=None, test=None, test_new=None)
datasets/utils.py:131
next →1–100 of 188, ranked by callers