Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/KlingAIResearch/VideoAlign
/ functions
Functions
63 in github.com/KlingAIResearch/VideoAlign
⨍
Functions
63
◇
Types & classes
9
↓ 4 callers
Function
build_prompt
(prompt, dimension, template_type)
prompt_template.py:100
↓ 4 callers
Function
ceil_by_factor
Returns the smallest integer greater than or equal to 'number' that is divisible by 'factor'.
vision_process.py:45
↓ 4 callers
Function
round_by_factor
Returns the closest integer to 'number' that is divisible by 'factor'.
vision_process.py:40
↓ 4 callers
Function
set_requires_grad
(parameters, requires_grad)
train_reward.py:65
↓ 4 callers
Function
smart_resize
Rescales the image so that the following conditions are met: 1. Both dimensions (height and width) are divisible by 'factor'. 2. The to
vision_process.py:55
↓ 3 callers
Function
floor_by_factor
Returns the largest integer less than or equal to 'number' that is divisible by 'factor'.
vision_process.py:50
↓ 3 callers
Function
process_vision_info
( conversations: list[dict] | list[list[dict]], )
vision_process.py:358
↓ 2 callers
Method
__init__
(self, config, output_dim=4, reward_token="last", special_token_ids=None)
trainer.py:60
↓ 2 callers
Method
_clean_message
remove unnecessary keys from message(very very necessary)
data.py:142
↓ 2 callers
Method
_pad_sequence
Pad the sequences to the maximum length.
data.py:171
↓ 2 callers
Method
_prepare_inputs
Prepare `inputs` before feeding them to the model, converting them to tensors if they are not already and handling potential state.
inference.py:112
↓ 2 callers
Function
calc_accuracy_with_ties
algorithm: https://arxiv.org/abs/2305.14324 O(N^2logN) Input: h: list of N human labels, 1 for prefer A, -1 for prefer B, 0 for t
calc_accuracy.py:37
↓ 2 callers
Function
calc_accuracy_without_ties
Input: h: list of N human labels, 1 for prefer A, -1 for prefer B, 0 for ties m: list of N model predictions, can be obtained by
calc_accuracy.py:102
↓ 2 callers
Function
create_dataset
(data_config, meta_file=None)
train_reward.py:141
↓ 2 callers
Function
create_model_and_processor
( model_config, peft_lora_config, training_args, cache_dir=None, )
train_reward.py:69
↓ 2 callers
Function
fetch_image
(ele: dict[str, str | Image.Image], size_factor: int = IMAGE_FACTOR)
vision_process.py:84
↓ 2 callers
Function
load_model_from_checkpoint
( model, checkpoint_dir, checkpoint_step )
utils.py:163
↓ 2 callers
Function
maybe_zero_3
(param, ignore_status=False, name=None)
utils.py:89
↓ 2 callers
Method
reward
Inputs: video_paths: List[str], B paths of the videos. prompts: List[str], B prompts for the videos. eval
inference.py:176
↓ 2 callers
Function
smart_nframes
calculate the number of frames for video used for model inputs. Args: ele (dict): a dict contains the configuration of video.
vision_process.py:129
↓ 2 callers
Function
suff_stats
+------------+-----------+-----------+-----------+ | Notation | Model Prediction | | | < | =
calc_accuracy.py:1
↓ 1 callers
Function
_convert_A_B_to_chosen_rejected
Inputs: rewards_A: [B, N] rewards_B: [B, N] scores_A: [B, N] scores_B: [B, N] chosen_label: [B, N] Ou
trainer.py:176
↓ 1 callers
Function
_insert_adapter_name_into_state_dict
Utility function to remap the state_dict keys to fit the PEFT model by inserting the adapter name.
utils.py:136
↓ 1 callers
Method
_norm
(self, reward)
inference.py:67
↓ 1 callers
Method
_prepare_input
Prepare `inputs` before feeding them to the model, converting them to tensors if they are not already and handling potential state.
inference.py:92
↓ 1 callers
Function
add_idx
(example, idx)
train_reward.py:145
↓ 1 callers
Function
calc_acc
(C, D, Th, Tm, Thm)
calc_accuracy.py:33
↓ 1 callers
Method
compute_loss
( self, model, inputs, return_outputs=False, )
trainer.py:424
↓ 1 callers
Function
convert_GSB_csv_to_reward_data
Convert Good/Same/Bad csv data to reward data. Args: example (dict): A dataframe containing the GSB csv data. data_dir (str)
data.py:31
↓ 1 callers
Function
convert_pair_to_single
(df_pair_anno)
eval_videogen_rewardbench.py:16
↓ 1 callers
Function
convert_single_to_pair
(df_pair_anno, df_single_pred)
eval_videogen_rewardbench.py:31
↓ 1 callers
Function
extract_vision_info
(conversations: list[dict] | list[list[dict]])
vision_process.py:340
↓ 1 callers
Function
fetch_video
(ele: dict, image_factor: int = IMAGE_FACTOR)
vision_process.py:293
↓ 1 callers
Function
find_target_linear_names
Find the target linear modules for LoRA.
train_reward.py:43
↓ 1 callers
Function
get_peft_state_non_lora_maybe_zero_3
(named_params, require_grad_only=True)
utils.py:127
↓ 1 callers
Function
get_video_reader_backend
()
vision_process.py:282
↓ 1 callers
Function
is_decord_available
()
vision_process.py:221
↓ 1 callers
Function
load_configs_from_json
(config_path)
inference.py:18
↓ 1 callers
Function
main
()
eval_videogen_rewardbench.py:51
↓ 1 callers
Method
prepare_batch
(self, video_paths, prompts, fps=None, num_frames=None, max_pixels=None,)
inference.py:122
↓ 1 callers
Function
save_configs_to_json
Save all configurations to a JSON file.
train_reward.py:21
↓ 1 callers
Function
train
()
train_reward.py:164
Method
__call__
Preprocess inputs to token sequences and return a batch
data.py:187
Method
__init__
(self, processor, add_noise=False, p_shuffle_frames=0.0, p_color_jitter=0.0)
data.py:132
Method
__init__
(self, load_from_pretrained, load_from_pretrained_step=-1, device='cuda', dtype=torch.bfloat16)
inference.py:30
Method
__init__
(self, special_token_ids)
trainer.py:223
Method
__init__
(self, loss_type="regular", enable_noise_in_eval=False, *args, **kwargs)
trainer.py:245
Method
__post_init__
(self)
utils.py:47
Method
__post_init__
(self)
utils.py:77
Method
_pad_sequence
Pad the sequences to the maximum length.
inference.py:76
Function
_read_video_decord
read video using decord.VideoReader Args: ele (dict): a dict contains the configuration of video. support keys: - vid
vision_process.py:227
Function
_read_video_torchvision
read video using torchvision.io.read_video Args: ele (dict): a dict contains the configuration of video. support keys:
vision_process.py:169
Method
_save
(self, output_dir: Optional[str] = None, state_dict=None)
trainer.py:559
Method
_save_checkpoint
(self, model, trial, metrics=None)
trainer.py:528
Function
compute_multi_attr_accuracy
(eval_pred, metainfo_idxs=None, eval_dims=None, save_path=None)
trainer.py:602
Method
create_optimizer
Setup the optimizer. We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the
trainer.py:318
Method
forward
( self, input_ids: torch.LongTensor = None, attention_mask: Optional[torch.Tensor] = N
trainer.py:71
Method
get_eval_dataloader
Returns the evaluation [`~torch.utils.data.DataLoader`]. Subclass and override this method if you want to inject some custom behavio
trainer.py:257
Function
get_peft_state_maybe_zero_3
(named_params, bias)
utils.py:103
Method
on_step_end
(self, args, state, control, **kwargs)
trainer.py:232
Method
on_train_begin
(self, args, state, control, **kwargs)
trainer.py:228
Method
prediction_step
( self, model, inputs, prediction_loss_only, ignore_keys = None, )
trainer.py:500
Function
save_video
(tensor, path)
utils.py:155