MCPcopy Create free account

hub / github.com/Aleph-Alpha-Research/magma / functions

Functions90 in github.com/Aleph-Alpha-Research/magma

↓ 10 callersFunctionprint_main
(*msg)
magma/utils.py:21
↓ 6 callersFunctionget_params_for_weight_decay_optimization
Divide params into with-weight-decay and without-weight-decay groups. Layernorms and biases will have no weight decay but the rest will.
magma/utils.py:120
↓ 6 callersFunctionreduce_losses
Reduce a tensor of losses across all GPUs.
magma/utils.py:26
↓ 5 callersFunctionis_main
()
magma/utils.py:15
↓ 4 callersFunctionwandb_log
(*args, **kwargs)
magma/utils.py:79
↓ 3 callersMethod__init__
( self, dim: int, downsample_factor: int = 4, activation: nn.Module = nn.ReLU,
magma/adapters.py:7
↓ 2 callersFunction_load_img_cpt_datasets
(dataset_dir, tokenizer, transforms)
train.py:34
↓ 2 callersFunction_load_paths
(data_dir, sort=True)
magma/datasets/dataset.py:67
↓ 2 callersMethodadd_adapters
Adds an adapter layer to `self` at the specified location
magma/magma.py:102
↓ 2 callersFunctioncycle
(loader)
magma/utils.py:37
↓ 2 callersFunctionsave_model
(model_engine, save_dir, global_step, config=None)
magma/utils.py:89
↓ 2 callersFunctionto_cuda_half
(*args)
magma/utils.py:313
↓ 1 callersFunction_read_image_data
(data_dir)
magma/datasets/dataset.py:51
↓ 1 callersFunctionbuild_labels
Builds labels from input embeddings. Masks out the labels with -100 in positions up to the seq length of the embeddings, so loss is only com
magma/utils.py:334
↓ 1 callersFunctionclip_encoder
Loads clip's image encoder module, discarding the lm component. If the variant is a resnet model, we also remove the attention pooling.
magma/image_encoders.py:48
↓ 1 callersFunctionclip_preprocess
(n_px, use_pad=False)
magma/transforms.py:121
↓ 1 callersFunctionconfigure_param_groups
Configures the different parameter groups in the model for training. If a separate learning rate for the image prefix is provided, we separat
magma/utils.py:164
↓ 1 callersFunctioncrop_or_pad
(n_px, pad=False)
magma/transforms.py:114
↓ 1 callersFunctiondownload_checkpoint
(checkpoint_url, save_as)
magma/utils.py:370
↓ 1 callersMethodembed
Embeds a list of tensors In the correct format to input into the LM (b, s, d). For each tensor, if it's 2d assume it's text and use w
magma/magma.py:195
↓ 1 callersFunctioneval_step
(config, eval_loader, model_engine)
magma/train_loop.py:48
↓ 1 callersMethodfrom_checkpoint
Loads a model checkpoint from disk / downloads from url if not present
magma/magma.py:279
↓ 1 callersMethodfrom_yml
(cls, path)
magma/config.py:140
↓ 1 callersFunctiongenerate
Generates captions for a batch of embeddings. :param model: The model to use for generation. :param embeddings: The embeddings to genera
magma/sampling.py:44
↓ 1 callersMethodgenerate
Generates captions for a batch of embeddings.
magma/magma.py:215
↓ 1 callersFunctionget_gptj
Loads GPTJ language model from HF
magma/language_model.py:27
↓ 1 callersFunctionget_image_encoder
Loads image encoder module
magma/image_encoders.py:79
↓ 1 callersFunctionget_pretraining_datasets
(config, tokenizer, transforms)
train.py:45
↓ 1 callersFunctionget_tokenizer
Gets tokenizer for LM
magma/utils.py:43
↓ 1 callersMethodget_transformed_image
(self, transform_fn: Callable)
magma/image_input.py:23
↓ 1 callersFunctionget_transforms
( image_size, encoder_name, input_resolution=None, use_extra_transforms=False )
magma/transforms.py:64
↓ 1 callersFunctionget_world_info
()
magma/utils.py:255
↓ 1 callersFunctiongptj_config
()
magma/language_model.py:12
↓ 1 callersFunctioninference_step
(config, eval_loader, model_engine)
magma/train_loop.py:85
↓ 1 callersFunctionload_config
(path, config_dir=Path("configs"))
magma/config.py:10
↓ 1 callersFunctionload_json
(filename)
magma/datasets/dataset.py:42
↓ 1 callersFunctionload_model
Loads a model from disk and returns the global step to resume from if loading was successful, otherwise returns 0
magma/utils.py:99
↓ 1 callersFunctionnfresnet50
Loads nfresnet50 model, removing the pooling layer and replacing it with an adaptive pooling layer.
magma/image_encoders.py:31
↓ 1 callersFunctionpad_img
(desired_size)
magma/transforms.py:94
↓ 1 callersFunctionpad_to_size
(x, size=256)
magma/transforms.py:8
↓ 1 callersFunctionparse_args
()
magma/utils.py:61
↓ 1 callersMethodpreprocess_inputs
Expects a list of strings and instances of ImageInput Converts them into a list of tensors and then optionally runs self.embed over i
magma/magma.py:176
↓ 1 callersFunctionread_jsonl
Iterator over data from a jsonl file
magma/datasets/dataset.py:22
↓ 1 callersFunctionremove_tokens_after_eos
(tensor, eos_token, image_token)
magma/sampling.py:33
↓ 1 callersFunctionsave_images
(img_list, target_dir, mode="mv")
magma/datasets/convert_datasets.py:22
↓ 1 callersFunctionsave_to_jsons
(data_list, target_dir, starting_idx=0)
magma/datasets/convert_datasets.py:10
↓ 1 callersMethodto_dict
(self)
magma/config.py:143
↓ 1 callersFunctiontop_k_filter
Top K sampling
magma/sampling.py:22
↓ 1 callersFunctiontop_p_filter
Nucleus sampling
magma/sampling.py:7
↓ 1 callersFunctiontrain_step
(config, train_loader, model_engine)
magma/train_loop.py:7
↓ 1 callersFunctionwandb_init
(*args, **kwargs)
magma/utils.py:84
Method__call__
(self, img)
magma/transforms.py:51
Method__getitem__
(self, idx)
magma/datasets/dataset.py:85
Method__getitem__
( self, idx )
magma/datasets/dataset.py:114
Method__init__
(self, target_size)
magma/transforms.py:48
Method__init__
( self, module: nn.Module, dim: int, downsample_factor: int = 4, scale
magma/adapters.py:43
Method__init__
( self, module: nn.Module, dim: int, downsample_factor: int = 4, scale
magma/adapters.py:72
Method__init__
( self, attn_block: nn.Module, dim: int, downsample_factor: int = 4, a
magma/adapters.py:98
Method__init__
(self, config, device=None)
magma/magma.py:29
Method__init__
(self, fn: Callable)
magma/image_encoders.py:19
Method__init__
( self, config: MultimodalConfig, out_dim: int = 2048, device=None, )
magma/image_prefix.py:35
Method__init__
(self, path_or_url)
magma/image_input.py:11
Method__init__
(self, data_dir)
magma/datasets/dataset.py:79
Method__init__
( self, data_dir, tokenizer, transforms, seq_len=2048, load_data_in_memory=False )
magma/datasets/dataset.py:98
Method__len__
(self)
magma/datasets/dataset.py:82
Method__len__
(self)
magma/datasets/dataset.py:111
Method__post_init__
(self)
magma/config.py:96
Functioncollate_fn
(batch_data: List[Tuple[torch.Tensor, torch.Tensor]], seq_len=2048)
magma/datasets/dataset.py:155
Functioncollate_fn_classification
(batch_data, seq_len=2048)
magma/utils.py:272
Functionconvert_dataset
Builds a dataset directory in our standard format. ds_iterator should return data of the form image_path, {"captions": [...], "metadata": {..
magma/datasets/convert_datasets.py:33
Functioncount_parameters
Counts the number of trainable parameters in a model
magma/utils.py:241
Functioneval_step_classification
(config, train_loader, model_engine, return_accuracy=True)
magma/train_loop.py:63
Functionfn
(im)
magma/transforms.py:95
Methodforward
(self, x: TensorType["b", "s", "d"])
magma/adapters.py:38
Methodforward
(self, x: TensorType["b", "s", "d"], **module_kwargs)
magma/adapters.py:63
Methodforward
(self, x: TensorType["b", "s", "d"], *attn_args, **attn_kwargs)
magma/adapters.py:85
Methodforward
(self, x: TensorType["b", "s", "d"], *attn_args, **attn_kwargs)
magma/adapters.py:109
Methodforward
( self, images: TensorType["b", "c", "h", "w"] = None, captions: Optional[TensorType["
magma/magma.py:238
Methodforward
(self, x)
magma/image_encoders.py:24
Methodforward
( self, x: TensorType["b", "c", "h", "w"] )
magma/image_prefix.py:78
Functioninfer_checkpoint_path_from_config
(config)
magma/utils.py:285
Functioninit_distributed
(backend="nccl")
magma/utils.py:262
Methodinit_weights
(self, m: nn.Module, std=1e-3)
magma/adapters.py:28
Functionis_url
(string)
magma/utils.py:367
Functionlog_table
(name, model_outputs, gt_answers_list, global_step)
magma/utils.py:248
Functionmaybe_add_batch_dim
(t)
magma/transforms.py:87
Functionpad_to_size_tensor
(x, size=256)
magma/transforms.py:21
Methodprint
(self)
magma/config.py:90
Functionread_img_captions
Yields image_path, image_caption from cc jsonl files
magma/datasets/dataset.py:31
Functiontrain_step_classification
(config, train_loader, model_engine, return_accuracy=True)
magma/train_loop.py:24