MCPcopy Create free account

hub / github.com/cvg/megaflow / functions

Functions254 in github.com/cvg/megaflow

↓ 14 callersFunctionn_frame_wrapper
Unified wrapper to load N frames. - bidirectional=True : Loads N frames [0..N-1] and 2*(N-2) flows from center frames. -
megaflow/data/datasets.py:832
↓ 12 callersMethodpad
(self, input)
megaflow/utils/basic.py:96
↓ 7 callersMethodprocess_scenes
( self, frames=[(0, "left"), (1, "left")], flows=[((0, "left"), (1, "left"))], # (sou
megaflow/data/datasets.py:103
↓ 6 callersMethod__init__
(self, aug_params=None, root="datasets/HD1K", scene_params={})
megaflow/data/datasets.py:648
↓ 6 callersMethodresize_flow_bilinear
Resize flow back to original resolution. Handles both 4D (B, 2, H, W) and 5D (B, T, 2, H, W) inputs.
megaflow/model/megaflow.py:304
↓ 6 callersMethodunpad
(self, x)
megaflow/utils/basic.py:102
↓ 5 callersMethodfrom_pretrained
Load a pretrained MegaFlow model from HuggingFace Hub. Args: model_name: One of 'megaflow-flow' (optical flow), 'megaflow-chairs-
megaflow/model/megaflow.py:60
↓ 4 callersMethod__init__
(self, input_dim=128, hidden_dim=256, output_dim=2)
megaflow/model/refine.py:101
↓ 4 callersFunction_make_fusion_block
(features: int, size: int = None, has_residual: bool = True, groups: int = 1)
megaflow/model/flow_head.py:282
↓ 4 callersMethodextract_feature
Args: images (torch.Tensor): Input images with shape [B, S, 3, H, W], in range [0, 1]. B: batch size, S: sequence
megaflow/model/megaflow.py:332
↓ 4 callersFunctionflow_to_image
Expects a two dimensional flow image of shape. Args: flow_uv (np.ndarray): Flow UV image of shape [H,W,2] clip_flow (float,
megaflow/utils/flow_viz.py:110
↓ 4 callersFunctiongridcloud2d
(B, Y, X, norm=False, device='cuda')
megaflow/utils/basic.py:130
↓ 4 callersMethodprepare_tokens_with_masks
(self, x, masks=None)
megaflow/model/layers/vision_transformer.py:214
↓ 4 callersFunctionstandardize_test_data
(rgbs, trajs, visibs, valids, S_cap=600, only_first=False, seq_len=None)
megaflow/utils/data.py:17
↓ 4 callersFunctionupsample_flow_with_mask
(flow, up_mask, upsample_factor, is_depth=False)
megaflow/model/model_utils.py:96
↓ 3 callersMethod__init__
( self, dim_in: int, patch_size: int = 14, activation: str = "inv_log",
megaflow/model/flow_head.py:17
↓ 3 callersMethod__init__
( self, data_root='datasets/TAP_Vid/tapvid_davis', crop_size=(384,512),
megaflow/data/point_utils/tapvid_dataset.py:15
↓ 3 callersMethod_make_layer
(self, block, dim, stride=1, norm_layer=nn.BatchNorm2d, num=2)
megaflow/model/refine.py:72
↓ 3 callersMethodadd_datasets
(self, other)
megaflow/data/datasets.py:388
↓ 3 callersFunctioncoords_grid
(b, h, w, homogeneous=False, device=None)
megaflow/model/geometry.py:5
↓ 3 callersFunctioncustom_interpolate
Custom interpolate to avoid INT_MAX issues in nn.functional.interpolate.
megaflow/model/megaflow.py:890
↓ 3 callersFunctioncustom_interpolate
Custom interpolate to avoid INT_MAX issues in nn.functional.interpolate.
megaflow/model/flow_head.py:442
↓ 3 callersFunctiondraw_line
(rgb, coord_y, coord_x, color, linewidth)
megaflow/utils/visualizer.py:55
↓ 3 callersMethodforward_track
(self, imgs, num_reg_refine=1, stride=None, window_len=None)
megaflow/model/megaflow.py:604
↓ 3 callersFunctionglobal_correlation_softmax
(feature0, feature1, pred_bidir_flow=False, )
megaflow/model/matching.py:7
↓ 3 callersFunctionlocal_correlation_with_flow
(feature0, feature1, flow, local_radius,
megaflow/model/matching.py:86
↓ 3 callersFunctionparse_args
Parse command line arguments and merge them with JSON configuration. This function first parses command line arguments, then loads configuration
config/parser.py:26
↓ 2 callersMethod__init__
(self, normalized_shape, eps=1e-6, data_format="channels_last")
megaflow/model/layer.py:83
↓ 2 callersMethod_apply_1d_rope
Applies 1D rotary position embeddings along one dimension. Args: tokens: Input token features. positions: Position in
megaflow/model/layers/rope.py:133
↓ 2 callersMethod_apply_pos_embed
Apply positional embedding to tensor x.
megaflow/model/flow_head.py:217
↓ 2 callersMethod_forward_impl
Implementation of the forward pass through the DPT head. This method processes a specific chunk of frames from the sequence.
megaflow/model/flow_head.py:152
↓ 2 callersFunctionbilinear_sample_video
r"""Sample a tensor using bilinear interpolation `bilinear_sampler(input, coords)` samples a tensor :attr:`input` at coordinates :attr:`coord
megaflow/model/geometry.py:40
↓ 2 callersFunctioncalculate_dynamic_size
Calculates new dimensions by fixing the width and preserving the aspect ratio. Ensures the height is divisible by the patch_size constraint.
demo_track.py:28
↓ 2 callersFunctioncalculate_dynamic_size
Calculates new dimensions preserving the original aspect ratio. Aligns the longest edge to the target_fix_width and ensures divisibility.
demo_flow.py:34
↓ 2 callersFunctionconv1x1
1x1 convolution without padding
megaflow/model/layer.py:5
↓ 2 callersFunctionconv3x3
3x3 convolution with padding
megaflow/model/layer.py:10
↓ 2 callersFunctiondrop_add_residual_stochastic_depth
( x: Tensor, residual_func: Callable[[Tensor], Tensor], sample_drop_ratio: float = 0.0, pos=None )
megaflow/model/layers/block.py:101
↓ 2 callersFunctiondrop_add_residual_stochastic_depth_list
( x_list: List[Tensor], residual_func: Callable[[Tensor, Any], Tensor], sample_drop_ratio: float =
megaflow/model/layers/block.py:175
↓ 2 callersFunctionfetch_dataloader
Create the data loader for the corresponding training set
megaflow/data/datasets.py:1043
↓ 2 callersFunctionfill_invalid
(flow, valid)
megaflow/utils/flow_utils.py:83
↓ 2 callersMethodforward
(self, imgs, num_reg_refine=1)
megaflow/model/megaflow.py:737
↓ 2 callersFunctiongenerate_window_grid
(h_min, h_max, w_min, w_max, len_h, len_w, device=None)
megaflow/model/geometry.py:24
↓ 2 callersMethodget_T_padded_images
(self, images, T, is_training, stride=None, pad=True)
megaflow/model/megaflow.py:410
↓ 2 callersFunctionget_attn_bias_and_cat
this will perform the index select, cat the tensors, and provide the attn_bias from cache
megaflow/model/layers/block.py:151
↓ 2 callersFunctionget_video_frames
(input_path, fix_width, mode="track")
demo_gradio.py:38
↓ 2 callersFunctionload_ckpt
Load checkpoint into a LightningModule or nn.Module. Supports: - None: load default pretrained weights (e.g., safetensors) -
megaflow/utils/basic.py:8
↓ 2 callersFunctionmake_2tuple
(x)
megaflow/model/layers/patch_embed.py:16
↓ 2 callersFunctionmake_sincos_pos_embed
This function generates a 1D positional embedding from a given grid using sine and cosine functions. Args: - embed_dim: The embedding di
megaflow/model/model_utils.py:142
↓ 2 callersFunctionnormalize_coords
(coords, h, w)
megaflow/model/geometry.py:35
↓ 2 callersFunctionsequence_loss
Loss function defined over sequence of flow predictions
megaflow/train/loss.py:108
↓ 2 callersMethodvisualize
( self, video: torch.Tensor, # (B,T,C,H,W) tracks: torch.Tensor, # (B,T,N,2)
megaflow/utils/visualizer.py:94
↓ 1 callersMethod__build_patch_embed__
Build the patch embed layer. If 'conv', we use a simple PatchEmbed conv layer. Otherwise, we use a vision transformer.
megaflow/model/megaflow.py:235
↓ 1 callersMethod__init__
Initializes the position generator with an empty cache.
megaflow/model/layers/rope.py:35
↓ 1 callersMethod__init__
( self, in_features: int, hidden_features: Optional[int] = None, out_features:
megaflow/model/layers/swiglu_ffn.py:15
↓ 1 callersMethod__init__
(self, args: argparse.Namespace)
megaflow/train/flow_trainer.py:360
↓ 1 callersMethod__init__
(self, args: argparse.Namespace)
megaflow/train/track_trainer.py:248
↓ 1 callersMethod_build_dataset
(self)
megaflow/data/datasets.py:804
↓ 1 callersMethod_compute_frequency_components
Computes frequency components for rotary embeddings. Args: dim: Feature dimension (must be even). seq_len: Maximum se
megaflow/model/layers/rope.py:86
↓ 1 callersMethod_draw_gt_tracks
( self, rgb: np.ndarray, # H x W x 3, gt_tracks: np.ndarray, # T x 2 )
megaflow/utils/visualizer.py:339
↓ 1 callersMethod_draw_pred_tracks
( self, rgb: np.ndarray, # H x W x 3 tracks: np.ndarray, # T x 2 vector_colo
megaflow/utils/visualizer.py:304
↓ 1 callersMethod_flow_bfs
(flows, s, t, max_depth)
megaflow/data/datasets.py:68
↓ 1 callersMethod_get_intermediate_layers_chunked
(self, x, n=1)
megaflow/model/layers/vision_transformer.py:285
↓ 1 callersMethod_get_intermediate_layers_not_chunked
(self, x, n=1)
megaflow/model/layers/vision_transformer.py:273
↓ 1 callersMethod_init_weights
(self)
megaflow/model/refine.py:43
↓ 1 callersFunction_make_scratch
(in_shape: List[int], out_shape: int, groups: int = 1, expand: bool = False)
megaflow/model/flow_head.py:296
↓ 1 callersMethod_process_frame_attention
Process frame attention blocks. We keep tokens in shape (B*S, P, C).
megaflow/model/megaflow.py:843
↓ 1 callersMethod_process_global_attention
Process global attention blocks. We keep tokens in shape (B, S*P, C).
megaflow/model/megaflow.py:867
↓ 1 callersMethod_rotate_features
Performs feature rotation by splitting and recombining feature dimensions. Args: x: Input tensor to rotate. Returns:
megaflow/model/layers/rope.py:120
↓ 1 callersMethodadd_photometric_augs
(self, rgbs, trajs, visibles, eraser=True, replace=True, augscale=1.0)
megaflow/data/point_utils/pointdataset.py:81
↓ 1 callersFunctionadd_residual
(x, brange, residual, residual_scale_factor, scaling_vector=None)
megaflow/model/layers/block.py:136
↓ 1 callersMethodadd_spatial_augs
(self, rgbs, trajs, visibles, crop_size, augscale=1.0)
megaflow/data/point_utils/pointdataset.py:166
↓ 1 callersFunctionadd_weighted
(rgb, alpha, original, beta, gamma)
megaflow/utils/visualizer.py:65
↓ 1 callersFunctioncalculate_dynamic_size
(orig_h, orig_w, target_fix_width, patch_size=14, mode="track")
demo_gradio.py:25
↓ 1 callersMethodcolor_transform
Photometric augmentation
megaflow/utils/augmentor.py:49
↓ 1 callersMethodcolor_transform
(self, imgs)
megaflow/utils/augmentor.py:317
↓ 1 callersFunctionconvert_qkv_to_q_and_kv_proj
Convert a self-attention qkv projection layer (dim -> 3*dim) into separate q_proj (dim -> dim) and kv_proj (dim -> 2*dim) layers. Re
megaflow/model/layers/attention.py:176
↓ 1 callersFunctioncreate_uv_grid
Create a normalized UV grid of shape (width, height, 2). The grid spans horizontally and vertically according to an aspect ratio, ensuri
megaflow/model/model_utils.py:169
↓ 1 callersMethodcrop
(self, rgbs, trajs, crop_size)
megaflow/data/point_utils/pointdataset.py:313
↓ 1 callersFunctiondecode
(frame)
megaflow/data/point_utils/tapvid_dataset.py:81
↓ 1 callersFunctiondetect_cluster
(args: argparse.Namespace)
scripts/train_mf.py:17
↓ 1 callersFunctiondetect_cluster
(args: argparse.Namespace)
scripts/train_track.py:17
↓ 1 callersFunctiondraw_circle
(rgb, coord, radius, color=(255, 0, 0), visible=True, color_alpha=None)
megaflow/utils/visualizer.py:39
↓ 1 callersMethoddraw_tracks_on_video
( self, video: torch.Tensor, tracks: torch.Tensor, visibility: torch.Tensor =
megaflow/utils/visualizer.py:170
↓ 1 callersFunctiondrop_path
(x, drop_prob: float = 0.0, training: bool = False)
megaflow/model/layers/drop_path.py:14
↓ 1 callersMethoderaser_transform
Occlusion augmentation (only for last frame)
megaflow/utils/augmentor.py:69
↓ 1 callersMethoderaser_transform
(self, imgs)
megaflow/utils/augmentor.py:326
↓ 1 callersMethodfetch
(self, index)
megaflow/data/datasets.py:237
↓ 1 callersFunctionflow_loss_func
Compute hierarchical flow loss with optional initial prediction loss. Parameters ---------- outputs : Dict[str, List[torch.Tenso
megaflow/train/loss.py:157
↓ 1 callersFunctionflow_uv_to_colors
Applies the flow color wheel to (possibly clipped) flow components u and v. According to the C++ source code of Daniel Scharstein Accord
megaflow/utils/flow_viz.py:71
↓ 1 callersMethodforward
(self, x: Tensor, pos=None)
megaflow/model/layers/block.py:77
↓ 1 callersMethodforward
(self, x: Tensor, pos=None)
megaflow/model/layers/attention.py:81
↓ 1 callersMethodforward_features
(self, x, masks=None)
megaflow/model/layers/vision_transformer.py:252
↓ 1 callersMethodforward_features_list
(self, x_list, masks_list)
megaflow/model/layers/vision_transformer.py:228
↓ 1 callersMethodforward_local_window_attn
(self, feature0, flow, local_window_radius=1,
megaflow/model/model_utils.py:56
↓ 1 callersMethodforward_nested
x_list contains a list of tensors to nest together and run
megaflow/model/layers/block.py:199
↓ 1 callersMethodforward_track_sliding
(self, imgs, num_reg_refine=1, stride=None, window_len=None)
megaflow/model/megaflow.py:436
↓ 1 callersFunctionfreeze_bn_affine
(model)
megaflow/train/flow_trainer.py:342
↓ 1 callersFunctionfreeze_bn_affine
(model)
megaflow/train/track_trainer.py:230
↓ 1 callersFunctionget_branges_scales
(x, sample_drop_ratio=0.0)
megaflow/model/layers/block.py:128
↓ 1 callersFunctionget_frames
Generator that yields (RGB frame, original_shape_tuples, native_fps). If fix_width is provided, resizes the frame preserving aspect ratio before y
demo_track.py:39
next →1–100 of 254, ranked by callers