MCPcopy Create free account

hub / github.com/apple/ml-4m / functions

Functions1,193 in github.com/apple/ml-4m

↓ 223 callersFunctionprint
(*args, **kwargs)
fourm/utils/dist.py:38
↓ 94 callersMethodupdate
(self, metrics)
fourm/utils/logger.py:210
↓ 56 callersMethodupdate
(self, **kwargs)
fourm/utils/logger.py:101
↓ 47 callersMethodload
(self, path)
fourm/data/modality_transforms.py:221
↓ 36 callersFunctiongenerate_uint15_hash
Generates a hash of the seed string as an unsigned int15 integer
fourm/utils/misc.py:39
↓ 35 callersFunctiondenormalize
Denormalizes an image. Args: img (torch.Tensor): Image to denormalize. mean (tuple): Mean to use for denormalization.
fourm/utils/misc.py:23
↓ 23 callersMethodreset
(self)
fourm/utils/timm/metrics.py:17
↓ 20 callersFunctionstring_to_list
Convert a string separated by hyphens into a list of a given data type, replacing invalid values with None. Args: input_str
run_generation.py:309
↓ 19 callersFunctionget_transform_key
(mod_name)
fourm/data/modality_transforms.py:39
↓ 19 callersMethodload_state_dict
(self, state_dict)
fourm/utils/native_scaler.py:52
↓ 18 callersMethodencode
Encodes an input image tensor and quantizes the latent code. Args: x: Input image tensor of shape B C H W or B H W
fourm/vq/vqvae.py:302
↓ 18 callersFunctionunwrap_model
Retrieves a model from a DDP wrapper, if necessary.
run_training_divae.py:75
↓ 17 callersMethodstate_dict
(self)
fourm/utils/native_scaler.py:49
↓ 17 callersFunctionunwrap_model
Retrieves a model from a DDP wrapper, if necessary.
run_training_vqvae.py:86
↓ 16 callersMethoddecode_tokens
Decodes discrete tokens back to an image. Args: tokens: Quantized indices of shape B H_Q W_Q Returns: Decode
fourm/vq/vqvae.py:368
↓ 16 callersFunctionget_value
Look up a default value belonging to a given domain and key.
fourm/demo_4M_sampler.py:174
↓ 16 callersFunctionrepeat_if_necessary
(lst, n)
run_generation.py:336
↓ 15 callersFunctionload_model
(model_id, model_class, device)
run_generation.py:339
↓ 15 callersMethodset_step
(self, step=None)
fourm/utils/logger.py:204
↓ 14 callersMethodlog_every
(self, iterable, print_freq, iter_len=None, header=None)
fourm/utils/logger.py:133
↓ 14 callersMethodmax
(self)
fourm/utils/logger.py:80
↓ 14 callersMethodtrain
Override the default train() to set the training mode to all modules except the encoder if freeze_enc is True. Args: mod
fourm/vq/vqvae.py:201
↓ 13 callersFunctionunwrap_model
Retrieves a model from a DDP wrapper, if necessary.
run_training_vqcontrolnet.py:74
↓ 12 callersFunctionconv_nd
Create a 1D, 2D, or 3D convolution module.
fourm/vq/models/unet/nn.py:35
↓ 12 callersFunctionload_model
Load a model from HuggingFace hub or a given .safetensors checkpoint path.
fourm/demo_4M_sampler.py:180
↓ 11 callersFunctionl2norm
(t)
fourm/vq/quantizers/quantize_lucid.py:35
↓ 11 callersMethodsynchronize_between_processes
(self)
fourm/utils/logger.py:126
↓ 11 callersMethodwandb_safe_log
(*args, **kwargs)
fourm/utils/logger.py:198
↓ 10 callersMethod__init__
(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0., bias=True)
fourm/models/fm_utils.py:112
↓ 10 callersMethodadd_meter
(self, name, meter)
fourm/utils/logger.py:130
↓ 10 callersMethoddevice
(self)
fourm/demo_4M_sampler.py:292
↓ 9 callersMethod__init__
(self, dim: int, fn: Callable, norm: str = "layer", norm_cond_dim: int = -1)
fourm/utils/hmr2_utils/hmr2/models/components/pose_transformer.py:33
↓ 9 callersMethod__init__
(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.)
fourm/vq/models/vit_models.py:146
↓ 9 callersMethoddecode
(self, tokens)
fourm/utils/clip/simple_tokenizer.py:134
↓ 8 callersMethod__init__
(self, in_features, temb_dim=None, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.)
fourm/vq/models/uvit.py:104
↓ 8 callersMethod__init__
(self, channels, use_conv, dims=2, out_channels=None)
fourm/vq/models/unet/unet.py:112
↓ 8 callersFunctioncfgs_get
Try to retrieve a key from the validation set config. If it does not exist, default to retrieving it from the train set config with the same
fourm/data/pretrain_utils.py:187
↓ 8 callersMethodforward_logits
Forward computation of logits for each modality. Args: y (torch.Tensor): Decoder output. Shape (B, M, D). decoder_mod
fourm/models/fm.py:521
↓ 8 callersMethodsample
(self, x)
fourm/vq/models/lm_models.py:128
↓ 8 callersFunctionsimple_span_masking
Span masking for a sequence Args: sequence: Sequence to mask sentinel_to_id: Mapping from sentinel to id keep_prob: Proba
fourm/data/masking.py:58
↓ 8 callersMethodzero_grad
(self)
fourm/vq/models/unet/fp16_util.py:193
↓ 7 callersFunction_check_args_tf
(kwargs)
fourm/utils/timm/auto_augment.py:55
↓ 7 callersFunctionrender_openpose
Render keypoints in the OpenPose format on input image. Args: img (np.array): Input image of shape (H, W, 3) with pixel values in the
fourm/utils/hmr2_utils/hmr2/utils/render_openpose.py:144
↓ 6 callersMethod__init__
(self, embed_dim: int, # 512 # vision image_resolution: int
fourm/utils/clip/model.py:309
↓ 6 callersMethod__init__
(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.)
fourm/utils/hmr2_utils/hmr2/models/backbones/vit.py:78
↓ 6 callersFunctioncutmix_bbox_and_lam
Generate bbox and apply lambda correction.
fourm/utils/timm/mixup.py:81
↓ 6 callersMethodforward_decoder
Forward pass for the decoder. Args: y (torch.Tensor): Decoder input tokens. Shape (B, M, D). context (torch.Tensor):
fourm/models/fm.py:497
↓ 6 callersMethodforward_embed
Forward pass through embedding module, transforming sequence of ids to sequence of embeddings. Creates corresponding modality and pos
fourm/models/decoder_embeddings.py:98
↓ 6 callersMethodforward_encoder
Forward pass for the encoder. Args: x (torch.Tensor): Encoder input tokens. Shape (B, N, D) where N is the number of enco
fourm/models/fm.py:477
↓ 6 callersFunctionmodulate
(x, shift, scale)
fourm/vq/models/uvit.py:45
↓ 6 callersFunctionnp_squeeze
Squeeses a numpy array along a given axis if that axis is one-dimensional. Otherwise, it returns the same array. Args: array
fourm/utils/plotting_utils.py:80
↓ 6 callersFunctionpair
(t)
fourm/models/fm_utils.py:25
↓ 6 callersFunctiontensor_to_images
Converts a (B C H W) tensor to numpy arrays. If B = 1, the tensor is unbatched and converted to a single image. If C = 1, the channel dim
fourm/utils/plotting_utils.py:47
↓ 5 callersFunction_randomly_negate
With 50% prob, negate the value
fourm/utils/timm/auto_augment.py:178
↓ 5 callersFunctioncreate_optimizer
Model can either be a single nn.Module, or a dictionary with {'model': model, 'balancer': balancer}.
fourm/utils/optim_factory.py:171
↓ 5 callersFunctiondecode_text
Decodes a text sequence from a model dictionary. Args: mod_dict (dict): Model output dictionary. key (str): Key of the text
fourm/utils/plotting_utils.py:473
↓ 5 callersMethodforward_enc_dec_maskgit_batched
(self, mod_dict, target_mod, seed=None)
fourm/models/generate.py:628
↓ 5 callersMethodforward_enc_dec_roar_batched
(self, mod_dict, target_mod, num_select, seed=None)
fourm/models/generate.py:745
↓ 5 callersMethodforward_mask_encoder_generation
Modification of forward_mask_encoder adapted for generation, with support for batching
fourm/models/generate.py:407
↓ 5 callersMethodgenerate
Generates a sequence of tokens from the input modalities. :param mod_dict: Dictionary of modalities. :param schedule: Schedule of mod
fourm/models/generate.py:1029
↓ 5 callersFunctionget_sentinel_to_id_mapping
(tokenizer, match_str="[S_")
fourm/utils/tokenizer/text_tokenizer.py:108
↓ 5 callersMethodimage_crop_and_resize
Crop and resize an image :param img: Image to crop and resize :param crop_coords: Coordinates of the crop (top, left, h, w) :
fourm/data/modality_transforms.py:181
↓ 5 callersMethodinit
Initialize parts of encoder that are dependent on dimension of tokens. Should be called when setting up FourM. Args:
fourm/models/encoder_embeddings.py:247
↓ 5 callersFunctionpca_visualize
Visualizes a feature map using PCA. Args: features (torch.Tensor): CxHxW feature map to visualize. n_components (int): Numbe
fourm/utils/plotting_utils.py:65
↓ 5 callersFunctionperspective_projection
Computes the perspective projection of a set of 3D points. Args: points (torch.Tensor): Tensor of shape (B, N, 3) containing the inpu
fourm/utils/hmr2_utils/hmr2/utils/geometry.py:71
↓ 5 callersMethodpil_loader
(path: str)
fourm/data/modality_transforms.py:160
↓ 5 callersFunctionplot_text_in_square
Plots text in a square. Args: ax (matplotlib.axes.Axes): Matplotlib axis to plot on text (str): Text to plot padding
fourm/utils/plotting_utils.py:1089
↓ 5 callersMethodstep
Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion process from the learned m
fourm/vq/scheduling/scheduling_pndm.py:234
↓ 5 callersFunctiontransform
(x, y, matrix)
fourm/utils/timm/auto_augment.py:111
↓ 5 callersMethodvae_decode
Decodes the vae latent representation into vae latent representaiton. Args: x: VAE latent representation clip
fourm/vq/vqvae.py:941
↓ 5 callersFunctionzero_module
Zero out the parameters of a module and return it.
fourm/vq/models/unet/nn.py:80
↓ 4 callersMethod__call__
(self, vertices, camera_translation, image, focal_length=5000, text=None, resize=None, side_view=False, baseCo
fourm/utils/hmr2_utils/hmr2/utils/mesh_renderer.py:105
↓ 4 callersMethod_make_layer
(self, planes, blocks, stride=1)
fourm/utils/clip/model.py:133
↓ 4 callersFunction_ntuple
(n)
fourm/utils/misc.py:45
↓ 4 callersMethod_params_per_elem
(self, batch_size)
fourm/utils/timm/mixup.py:126
↓ 4 callersFunction_pil_interp
(method)
fourm/utils/timm/transforms.py:49
↓ 4 callersMethodadd_noise
( self, original_samples: torch.FloatTensor, noise: torch.FloatTensor, timeste
fourm/vq/scheduling/scheduling_pndm.py:445
↓ 4 callersMethodautoencode
Autoencodes an input image tensor by encoding it, quantizing the latent code, and decoding it back to an image. Args: x:
fourm/vq/vqvae.py:333
↓ 4 callersFunctionbuild_chained_generation_schedules
Builds a list of chained generation schedules, where each schedule is a tuple of the form: (target_modality, schema, number of decoded tokens
fourm/models/generate.py:197
↓ 4 callersFunctioncustom_text
(sample, input_text, eos_token, key, device, text_tokenizer, target_max_len=50, start_token="[S_1]")
fourm/models/generate.py:154
↓ 4 callersFunctiondecode_dict
Decodes the model output dictionary into a dictionary of images and text. Args: mod_dict (dict): Model output dictionary. to
fourm/utils/plotting_utils.py:673
↓ 4 callersFunctionema_inplace
(moving_avg, new, decay)
fourm/vq/quantizers/quantize_lucid.py:56
↓ 4 callersFunctionempty_img_modality
(mod_dict, key)
fourm/models/generate.py:30
↓ 4 callersFunctionempty_seq_emb_modality
(mod_dict, key)
fourm/models/generate.py:65
↓ 4 callersFunctionempty_seq_modality
(mod_dict, key, s1_id=5)
fourm/models/generate.py:39
↓ 4 callersMethodencode
(self, text)
fourm/utils/clip/simple_tokenizer.py:126
↓ 4 callersFunctionevaluate
(model, data_loader, device, num_input_tokens, num_target_tokens, loss_type, all_domains: List[st
run_training_4m.py:799
↓ 4 callersFunctionevaluate
(model, data_loader, device, num_input_tokens, num_target_tokens, loss_type, all_domains: List[st
run_training_4m_fsdp.py:847
↓ 4 callersFunctionget_val_dataloader
(dataset_config, dataset_name, train_configs, modality_info, sampling_weights, text_tokenizer,
fourm/data/pretrain_utils.py:195
↓ 4 callersMethodimage_hflip
Crop and resize an image :param img: Image to crop and resize :param flip: Whether to flip the image :return: Flipped image (
fourm/data/modality_transforms.py:169
↓ 4 callersFunctioninit_empty_target_modality
Initializes an empty target modality dictionary for a given domain. Used to initialize target modality dictionaries for generation.
fourm/models/generate.py:83
↓ 4 callersMethodinit_from_ckpt
Loads the state_dict from a checkpoint file and initializes the model with it. Renames the keys in the state_dict if necessary (e.g. when load
fourm/vq/vqvae.py:217
↓ 4 callersFunctioninit_full_input_modality
(mod_dict, modality_info, domain, device, eos_id=3)
fourm/models/generate.py:117
↓ 4 callersFunctionmake_dataset
( directory: str, class_to_idx: Dict[str, int], extensions: Optional[Tuple[str, ...]]
fourm/data/multimodal_dataset_folder.py:56
↓ 4 callersFunctionmake_grid
Aggregate a list of PIL images into a grid of images.
run_training_divae.py:1485
↓ 4 callersFunctionmask_out_samples
(clean_inputs, mask_valid=None, mask_value=None)
run_training_vqcontrolnet.py:785
↓ 4 callersFunctionmask_out_samples
Optionally mask out invalid regions and concat mask to images. Useful when tokenizing simulated data that contains unlabeled regions. Args:
run_training_divae.py:810
↓ 4 callersFunctionnormalization
Make a standard normalization layer. :param channels: number of input channels. :return: an nn.Module for normalization.
fourm/vq/models/unet/nn.py:105
↓ 4 callersFunctionpad_or_truncate
(tensor, fixed_length, padding_value=0)
fourm/utils/generation_datasets/parti_prompts_dataset.py:91
↓ 4 callersFunctionpair
(t)
fourm/vq/models/vit_models.py:34
next →1–100 of 1,193, ranked by callers