Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Aleph-Alpha-Research/magma
/ functions
Functions
90 in github.com/Aleph-Alpha-Research/magma
⨍
Functions
90
◇
Types & classes
12
↓ 10 callers
Function
print_main
(*msg)
magma/utils.py:21
↓ 6 callers
Function
get_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 callers
Function
reduce_losses
Reduce a tensor of losses across all GPUs.
magma/utils.py:26
↓ 5 callers
Function
is_main
()
magma/utils.py:15
↓ 4 callers
Function
wandb_log
(*args, **kwargs)
magma/utils.py:79
↓ 3 callers
Method
__init__
( self, dim: int, downsample_factor: int = 4, activation: nn.Module = nn.ReLU,
magma/adapters.py:7
↓ 2 callers
Function
_load_img_cpt_datasets
(dataset_dir, tokenizer, transforms)
train.py:34
↓ 2 callers
Function
_load_paths
(data_dir, sort=True)
magma/datasets/dataset.py:67
↓ 2 callers
Method
add_adapters
Adds an adapter layer to `self` at the specified location
magma/magma.py:102
↓ 2 callers
Function
cycle
(loader)
magma/utils.py:37
↓ 2 callers
Function
save_model
(model_engine, save_dir, global_step, config=None)
magma/utils.py:89
↓ 2 callers
Function
to_cuda_half
(*args)
magma/utils.py:313
↓ 1 callers
Function
_read_image_data
(data_dir)
magma/datasets/dataset.py:51
↓ 1 callers
Function
build_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 callers
Function
clip_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 callers
Function
clip_preprocess
(n_px, use_pad=False)
magma/transforms.py:121
↓ 1 callers
Function
configure_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 callers
Function
crop_or_pad
(n_px, pad=False)
magma/transforms.py:114
↓ 1 callers
Function
download_checkpoint
(checkpoint_url, save_as)
magma/utils.py:370
↓ 1 callers
Method
embed
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 callers
Function
eval_step
(config, eval_loader, model_engine)
magma/train_loop.py:48
↓ 1 callers
Method
from_checkpoint
Loads a model checkpoint from disk / downloads from url if not present
magma/magma.py:279
↓ 1 callers
Method
from_yml
(cls, path)
magma/config.py:140
↓ 1 callers
Function
generate
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 callers
Method
generate
Generates captions for a batch of embeddings.
magma/magma.py:215
↓ 1 callers
Function
get_gptj
Loads GPTJ language model from HF
magma/language_model.py:27
↓ 1 callers
Function
get_image_encoder
Loads image encoder module
magma/image_encoders.py:79
↓ 1 callers
Function
get_pretraining_datasets
(config, tokenizer, transforms)
train.py:45
↓ 1 callers
Function
get_tokenizer
Gets tokenizer for LM
magma/utils.py:43
↓ 1 callers
Method
get_transformed_image
(self, transform_fn: Callable)
magma/image_input.py:23
↓ 1 callers
Function
get_transforms
( image_size, encoder_name, input_resolution=None, use_extra_transforms=False )
magma/transforms.py:64
↓ 1 callers
Function
get_world_info
()
magma/utils.py:255
↓ 1 callers
Function
gptj_config
()
magma/language_model.py:12
↓ 1 callers
Function
inference_step
(config, eval_loader, model_engine)
magma/train_loop.py:85
↓ 1 callers
Function
load_config
(path, config_dir=Path("configs"))
magma/config.py:10
↓ 1 callers
Function
load_json
(filename)
magma/datasets/dataset.py:42
↓ 1 callers
Function
load_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 callers
Function
nfresnet50
Loads nfresnet50 model, removing the pooling layer and replacing it with an adaptive pooling layer.
magma/image_encoders.py:31
↓ 1 callers
Function
pad_img
(desired_size)
magma/transforms.py:94
↓ 1 callers
Function
pad_to_size
(x, size=256)
magma/transforms.py:8
↓ 1 callers
Function
parse_args
()
magma/utils.py:61
↓ 1 callers
Method
preprocess_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 callers
Function
read_jsonl
Iterator over data from a jsonl file
magma/datasets/dataset.py:22
↓ 1 callers
Function
remove_tokens_after_eos
(tensor, eos_token, image_token)
magma/sampling.py:33
↓ 1 callers
Function
save_images
(img_list, target_dir, mode="mv")
magma/datasets/convert_datasets.py:22
↓ 1 callers
Function
save_to_jsons
(data_list, target_dir, starting_idx=0)
magma/datasets/convert_datasets.py:10
↓ 1 callers
Method
to_dict
(self)
magma/config.py:143
↓ 1 callers
Function
top_k_filter
Top K sampling
magma/sampling.py:22
↓ 1 callers
Function
top_p_filter
Nucleus sampling
magma/sampling.py:7
↓ 1 callers
Function
train_step
(config, train_loader, model_engine)
magma/train_loop.py:7
↓ 1 callers
Function
wandb_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
Function
collate_fn
(batch_data: List[Tuple[torch.Tensor, torch.Tensor]], seq_len=2048)
magma/datasets/dataset.py:155
Function
collate_fn_classification
(batch_data, seq_len=2048)
magma/utils.py:272
Function
convert_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
Function
count_parameters
Counts the number of trainable parameters in a model
magma/utils.py:241
Function
eval_step_classification
(config, train_loader, model_engine, return_accuracy=True)
magma/train_loop.py:63
Function
fn
(im)
magma/transforms.py:95
Method
forward
(self, x: TensorType["b", "s", "d"])
magma/adapters.py:38
Method
forward
(self, x: TensorType["b", "s", "d"], **module_kwargs)
magma/adapters.py:63
Method
forward
(self, x: TensorType["b", "s", "d"], *attn_args, **attn_kwargs)
magma/adapters.py:85
Method
forward
(self, x: TensorType["b", "s", "d"], *attn_args, **attn_kwargs)
magma/adapters.py:109
Method
forward
( self, images: TensorType["b", "c", "h", "w"] = None, captions: Optional[TensorType["
magma/magma.py:238
Method
forward
(self, x)
magma/image_encoders.py:24
Method
forward
( self, x: TensorType["b", "c", "h", "w"] )
magma/image_prefix.py:78
Function
infer_checkpoint_path_from_config
(config)
magma/utils.py:285
Function
init_distributed
(backend="nccl")
magma/utils.py:262
Method
init_weights
(self, m: nn.Module, std=1e-3)
magma/adapters.py:28
Function
is_url
(string)
magma/utils.py:367
Function
log_table
(name, model_outputs, gt_answers_list, global_step)
magma/utils.py:248
Function
maybe_add_batch_dim
(t)
magma/transforms.py:87
Function
pad_to_size_tensor
(x, size=256)
magma/transforms.py:21
Method
print
(self)
magma/config.py:90
Function
read_img_captions
Yields image_path, image_caption from cc jsonl files
magma/datasets/dataset.py:31
Function
train_step_classification
(config, train_loader, model_engine, return_accuracy=True)
magma/train_loop.py:24