aigve.metrics
This module provides the videos evaluation metrics that can be used within the AIGVE toolkit.
BlipSimScore
Bases: BaseMetric
Initialize the BLIPSimScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the BLIP model. Defaults to |
'Salesforce/blip-itm-base-coco'
|
logit_scale
|
bool
|
Whether to calcualte the cosine similarity as logits. Defaults to False. |
False
|
Source code in aigve/metrics/text_video_alignment/similarity_based/blipscore/blipsim.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/similarity_based/blipscore/blipsim.py
process(data_batch, data_samples)
BLIPSimScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/similarity_based/blipscore/blipsim.py
CLIPSimScore
Bases: BaseMetric
Initialize the CLIPSimScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
processor_name
|
str
|
The name of the CLIP processor, which wraps a CLIP feature extractor and a CLIP tokenizer into this single procesor.
Defaults to |
'openai/clip-vit-base-patch32'
|
model_name
|
str
|
The name of the CLIP model. Defaults to |
'openai/clip-vit-base-patch32'
|
logit_scale
|
bool
|
Whether to calcualte the cosine similarity as logits. Defaults to False. |
False
|
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/clipsim.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/clipsim.py
process(data_batch, data_samples)
CLIPSimScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/clipsim.py
CLIPTempScore
Bases: BaseMetric
Initialize the CLIPTempScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the CLIP encoder model. Defaults to |
'openai/clip-vit-base-patch32'
|
logit_scale
|
bool
|
Whether to calcualte the cosine similarity as logits. Defaults to False. |
False
|
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/cliptemp.py
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/cliptemp.py
process(data_batch, data_samples)
CLIPTempScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/similarity_based/clipscore/cliptemp.py
DSGScore
Bases: BaseMetric
Initialize the DSGScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vqa_model_name
|
str
|
The name of the VQA model used in the DSGScore evaluator. Defaults to |
'InstructBLIP'
|
verbose
|
bool
|
Whether the intermediate output processes is required. Defaults to False. |
False
|
Source code in aigve/metrics/text_video_alignment/gpt_based/dsg/dsg_eval.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/gpt_based/dsg/dsg_eval.py
evaluate_image_dsg(qid_list, frame_index, frame)
Evaluate a generated image with DSG evaluator; this is the intermediate process of the process
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qid_list
|
List[str]
|
The list of DSG parse question generation results. |
required |
frame_index
|
int
|
The index number of the currently evaluated frame. |
required |
frame
|
List[List[float]]
|
The current evaluated frame. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Union[int, dict, float]]
|
Dict[str, Union[int, dict, float]]: A dictionary containing evaluation results with the following keys: - 'frame_index' (int): The index of the evaluated frame. - 'qid2tuple' (dict): Mapping of question IDs to tuples. - 'qid2dependency' (dict): Mapping of question IDs to dependencies. - 'qid2question' (dict): Mapping of question IDs to actual questions. - 'qid2answer' (dict): Mapping of question IDs to predicted answers. - 'qid2scores' (dict): Mapping of question IDs to scores before dependency filtering. - 'qid2validity' (dict): Mapping of question IDs to boolean validity after dependency filtering. - 'average_score_with_dependency' (float): Average score considering dependency filtering. - 'average_score_without_dependency' (float): Average score before dependency filtering. |
Source code in aigve/metrics/text_video_alignment/gpt_based/dsg/dsg_eval.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
process(data_batch, data_samples)
DSGScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/gpt_based/dsg/dsg_eval.py
FIDScore
Bases: BaseMetric
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
calculate_fid(real, fake)
Calculate FID score between real and generated videos.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
real
|
Tensor
|
Real video tensor [T, C, H, W]. |
required |
fake
|
Tensor
|
Generated video tensor [T, C, H, W]. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
FID score. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
calculate_statistics(video_tensor)
Calculate activation statistics (mean and covariance) from video frames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_tensor
|
Tensor
|
Video tensor [T, C, H, W]. |
required |
Returns:
Type | Description |
---|---|
tuple[ndarray, ndarray]
|
Tuple of mean and covariance matrix. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
compute_metrics(results)
Compute the final FID score.
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
preprocess_tensor(video_tensor)
Resize and normalize a video tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_tensor
|
Tensor
|
Tensor of shape [T, C, H, W]. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Preprocessed tensor of shape [T, C, H, W]. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
process(data_batch, data_samples)
Process one batch of data samples and compute FID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
dict
|
A batch of data from the dataloader (not used here). |
required |
data_samples
|
List[Tuple[Tensor], Tuple[Tensor], Tuple[str], Tuple[str]]
|
A list containing four tuples:
- A tuple of |
required |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fid_metric.py
FVDScore
Bases: BaseMetric
Fréchet Video Distance (FVD) computation using I3D model. Users can first download the pretrained I3D model from: https://github.com/hassony2/kinetics_i3d_pytorch/blob/master/model/model_rgb.pth Then put in the folder: AIGVE_Tool/aigve/metrics/video_quality_assessment/distribution_based/fvd/
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_path
|
str
|
Path to pre-trained I3D model. |
required |
feature_layer
|
int
|
Layer to extract features from. Default is -2 (penultimate layer). |
-2
|
is_gpu
|
bool
|
Whether to use GPU. Default is True. |
True
|
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
calculate_fvd(real, fake)
Compute FVD score between real and generated videos.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
real
|
Tensor
|
Real video tensor [T, C, H, W]. |
required |
fake
|
Tensor
|
Generated video tensor [T, C, H, W]. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
FVD score. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
calculate_statistics(video_tensor)
Extract activation statistics from video frames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_tensor
|
Tensor
|
Video tensor [T, C, H, W]. |
required |
Returns:
Type | Description |
---|---|
tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: Mean and covariance of extracted features. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
compute_metrics(results)
Compute the final FVD score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
List of FVD scores for each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: Dictionary containing mean FVD score. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
load_i3d_model(model_path, feature_layer)
Load a pre-trained I3D model and modify it to extract features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_path
|
str
|
Path to the I3D model checkpoint. |
required |
feature_layer
|
int
|
The layer index from which to extract features. |
required |
Returns:
Type | Description |
---|---|
Module
|
torch.nn.Module: I3D feature extraction model. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
preprocess_tensor(video_tensor)
Resize and normalize a video tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_tensor
|
Tensor
|
Tensor of shape [T, C, H, W]. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Preprocessed tensor of shape [T, C, H, W]. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
process(data_batch, data_samples)
Process a batch of videos and compute FVD.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
dict
|
Not used here. |
required |
data_samples
|
List[Tuple[Tensor], Tuple[Tensor], Tuple[str], Tuple[str]]
|
A list containing four tuples:
- A tuple of |
required |
Source code in aigve/metrics/video_quality_assessment/distribution_based/fvd/fvd_metric.py
GstVqa
Bases: BaseMetric
GstVQA metric modified for the toy dataset. (Supporting 2944-dim features).
Source code in aigve/metrics/video_quality_assessment/nn_based/gstvqa/gstvqa_metric.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
compute_metrics(results)
Compute final GSTVQA-based metrics.
Source code in aigve/metrics/video_quality_assessment/nn_based/gstvqa/gstvqa_metric.py
compute_stat_features(features, num_valid_frames)
Compute statistical features mean_var, std_var, mean_mean, std_mean from extracted deep features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features
|
Tensor
|
Tensor of shape [T, 2944]. |
required |
num_valid_frames
|
int
|
Number of valid frames before padding. |
required |
Returns:
Type | Description |
---|---|
Tuple[Tensor]
|
Tuple[torch.Tensor]: (mean_var, std_var, mean_mean, std_mean), each of shape [1472]. |
Source code in aigve/metrics/video_quality_assessment/nn_based/gstvqa/gstvqa_metric.py
process(data_batch, data_samples)
Process a batch of extracted deep features for GSTVQA evaluation and store results in a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
SequencTuplee
|
A batch of data from the dataloader (not used here). |
required |
data_samples
|
List[[Tensor], Tuple[int], Tuple[str]]
|
A list containing three tuples:
- A tuple of |
required |
Source code in aigve/metrics/video_quality_assessment/nn_based/gstvqa/gstvqa_metric.py
ISScore
Bases: BaseMetric
Inception Score (IS) implementation.
The Inception Score measures the quality and diversity of generated images by evaluating the KL divergence between the conditional class distribution and the marginal class distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
Name of the model to use. Currently only 'inception_v3' is supported. |
'inception_v3'
|
input_shape
|
tuple
|
Input shape for the model (height, width, channels). |
(299, 299, 3)
|
splits
|
int
|
Number of splits to use when calculating the score. |
10
|
is_gpu
|
bool
|
Whether to use GPU. Defaults to True. |
True
|
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
calculate_is(preds)
Calculate the Inception Score (IS) for a set of predicted class probabilities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
preds
|
ndarray
|
Array of predicted softmax probabilities with shape [N, num_classes]. |
required |
Returns:
Type | Description |
---|---|
float
|
Inception Score. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
compute_inception_features(images)
Compute Inception features for a batch of images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images
|
Tensor
|
Preprocessed image tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Feature activations from InceptionV3. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
compute_metrics(results)
Compute the final IS score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
List of IS scores for each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: Dictionary containing mean IS score and standard deviation. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
preprocess_tensor(images)
Resize and normalize images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images
|
Tensor
|
Tensor of shape [B, C, H, W]. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Preprocessed images. |
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
process(data_batch, data_samples)
Process one batch of data samples and compute IS.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
dict
|
A batch of data from the dataloader (not used here). |
required |
data_samples
|
List[Tuple[Tensor], Tuple[Tensor], Tuple[str], Tuple[str]]
|
A list containing four tuples:
- A tuple of |
required |
Source code in aigve/metrics/video_quality_assessment/distribution_based/is_score_metric.py
LightVQAPlus
Bases: BaseMetric
LightVQA+ metric for evaluating video quality.
Source code in aigve/metrics/video_quality_assessment/nn_based/lightvqa_plus/lightvqa_plus_metric.py
compute_metrics(results)
Compute final LightVQA+ metrics.
Source code in aigve/metrics/video_quality_assessment/nn_based/lightvqa_plus/lightvqa_plus_metric.py
process(data_batch, data_samples)
Process a batch of extracted deep features for LightVQA+ evaluation. Args: data_batch (Sequence): A batch of data from the dataloader (not used here). data_samples (List[Tuple[torch.Tensor], Tuple[torch.Tensor], Tuple[torch.Tensor], Tuple[str]]): A list containing five tuples: - spatial_features (torch.Tensor): Extracts 8 evenly spaced key frames. Shape: [8, 3, 672, 1120]. - temporal_features (torch.Tensor): Motion features from SlowFast. Shape: [1, feature_dim(2304)]. - bns_features (torch.Tensor): Brightness & Noise features. Shape: [8, 300]. - bc_features (torch.Tensor): Temporal brightness contrast features. Shape: [8, final_dim(20)]. - video_name (str): Video filename. The len of each tuples are the batch size.
Source code in aigve/metrics/video_quality_assessment/nn_based/lightvqa_plus/lightvqa_plus_metric.py
PickScore
Bases: BaseMetric
Initialize the PickScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the PickScore model. Defaults to |
'yuvalkirstain/PickScore_v1'
|
logit_scale
|
bool
|
Whether to calcualte the cosine similarity as logits. Defaults to False. |
False
|
Source code in aigve/metrics/text_video_alignment/similarity_based/pickscore/pick_infer.py
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/similarity_based/pickscore/pick_infer.py
process(data_batch, data_samples)
PickScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/similarity_based/pickscore/pick_infer.py
SimpleVqa
Bases: BaseMetric
SimpleVQA metric for evaluating video quality.
Source code in aigve/metrics/video_quality_assessment/nn_based/simplevqa/simplevqa_metric.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
compute_metrics(results)
Compute final SimpleVQA-based metrics.
Source code in aigve/metrics/video_quality_assessment/nn_based/simplevqa/simplevqa_metric.py
process(data_batch, data_samples)
Process a batch of extracted deep features for SimpleVQA evaluation.
Args:
data_batch (Sequence): A batch of data from the dataloader (not used here).
data_samples (List[ Tuple[torch.Tensor], List[Tuple[torch.Tensor]], Tuple[str] ]):
A list containing three tuples:
- A tuple of spatial_features
(torch.Tensor): Shape [v_len_second, 3, 448, 448].
v_len_second
is total seconds of the video (though 2 for toy dataset) with minium 8 (i.e. min_video_seconds).
The len of the tuple is the batch size.
- A list of motion_features
(Tuple[torch.Tensor]):
len(List) is total seconds of the video, with minium 8 (i.e. min_video_seconds).
Each item of the list is a Tuple of motion feature tensors. Each has shape [32, 3, 224, 224].
The len of the tuple is the batch size.
- A tuple of video_name
(str): Video filename. The len of the tuple is the batch size.
Source code in aigve/metrics/video_quality_assessment/nn_based/simplevqa/simplevqa_metric.py
TIFAScore
Bases: BaseMetric
Initialize the TIFAScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
openai_key
|
str
|
The user's api key of the LLM models openai provides. |
required |
llm_model
|
str
|
The name of the LLM model used in the TIFAScore evaluator. Defaults to |
'gpt-3.5-turbo'
|
unifiedqa_model_name
|
str
|
The name of the |
'allenai/unifiedqa-v2-t5-large-1363200'
|
vqa_model_name
|
str
|
The name of the |
'mplug-large'
|
Source code in aigve/metrics/text_video_alignment/gpt_based/TIFA/tifa_eval.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/gpt_based/TIFA/tifa_eval.py
process(data_batch, data_samples)
TIFAScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/gpt_based/TIFA/tifa_eval.py
VIEEvalScore
Bases: BaseMetric
Initialize the VIEEvalScore
evaluator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
llm_backbone
|
str
|
The name of the LLM model used in the VIEEvalScore evaluator. Defaults to |
'gpt4o'
|
api_key_path
|
str
|
The user's api key path to initialize LLM models provides by openai. |
'AIGVE_Tool/metrics/text_video_alignment/gpt_based/VIE/api_key.txt'
|
task
|
str
|
The task the VIEEvalScore evaluator conducts. Defaults to ''t2v''. |
't2v'
|
Source code in aigve/metrics/text_video_alignment/gpt_based/VIE/vie_eval.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
compute_metrics(results)
Compute the metrics from processed results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The processed results of each batch. |
required |
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: The computed metrics. The keys are the names of |
Dict[str, float]
|
the metrics, and the values are corresponding results. |
Source code in aigve/metrics/text_video_alignment/gpt_based/VIE/vie_eval.py
process(data_batch, data_samples)
VIEScore process
Process one batch of data samples and predictions. The processed
results should be stored in self.results
, which will be used to
compute the metrics when all batches have been processed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Sequence
|
A batch of data from the dataloader. |
required |
data_samples
|
Sequence
|
A batch of data samples that contain annotations and predictions. |
required |
Source code in aigve/metrics/text_video_alignment/gpt_based/VIE/vie_eval.py
VideoPhy
Bases: BaseMetric
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
__init__(hf_token, collect_device=None, prefix=None, metric_path=None, model_path='videophysics/videocon_physics', datainfo_path=None, test_index=None, **kwargs)
This function is used to initialize the VideoPhy metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collect_device
|
str or device
|
The device to use for collecting the data |
None
|
prefix
|
str
|
The prefix to use for the metric name |
None
|
metric_path
|
str
|
The path to the metric |
None
|
model_path
|
str
|
The path to the model |
'videophysics/videocon_physics'
|
datainfo_path
|
str
|
The path to the data info |
None
|
test_index
|
int
|
The index of the test |
None
|
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
compute_metrics(results)
This function is used to compute the metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
A list of results |
required |
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
get_entail(logits, input_ids)
This function is used to get the entailment scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logits
|
Tensor
|
A tensor containing the logits |
required |
input_ids
|
Tensor
|
A tensor containing the input IDs |
required |
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
get_logits(data_batch)
This function is used to get the logits for each input in the data batch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
dict
|
A dictionary containing the data batch |
required |
Returns: logits (torch.Tensor): A tensor containing the logits for each input in the data batch
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
process(data_batch, data_samples)
This function is used to process the data batch and compute the metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
dict
|
A dictionary containing the data batch |
required |
data_samples
|
list
|
A list of dictionaries containing the data samples |
required |
Source code in aigve/metrics/multi_aspect_metrics/videophy/videophy_metric.py
VideoScore
Bases: BaseMetric
Source code in aigve/metrics/multi_aspect_metrics/videoscore/videoscore_metric.py
__init__(collect_device=None, prefix=None, metric_path=None, model_path='TIGER-Lab/VideoScore-v1.1', datainfo_path=None, test_index=None, **kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collect_device
|
Optional[Union[str, device]]
|
The device to collect the data on. |
None
|
prefix
|
Optional[str]
|
The prefix to use for the metric. |
None
|
metric_path
|
str
|
The path to the metric file. |
None
|
model_path
|
str
|
The path to the model file. |
'TIGER-Lab/VideoScore-v1.1'
|
datainfo_path
|
str
|
The path to the datainfo file. |
None
|
test_index
|
int
|
The index of the test data. |
None
|
Source code in aigve/metrics/multi_aspect_metrics/videoscore/videoscore_metric.py
compute_metrics(results)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
list
|
The results to compute the metrics from. |
required |
Source code in aigve/metrics/multi_aspect_metrics/videoscore/videoscore_metric.py
process(data_batch, data_samples)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_batch
|
Any
|
The data batch to process. |
required |
data_samples
|
Sequence[dict]
|
The data samples to process. |
required |