aigve.datasets
CLIPTempDataset
Bases: Dataset
Source code in aigve/datasets/cliptemp_dataset.py
__getitem__(index)
return video frame pairs
Source code in aigve/datasets/cliptemp_dataset.py
FidDataset
Bases: Dataset
Dataset for Fréchet Inception Distance (FID) evaluation.
For each sample, this dataset: - Loads both the ground-truth (real) and generated (predicted) videos. - Converts each video into a tensor of shape [T, C, H, W] using OpenCV. - Optionally pads or truncates videos to a fixed number of frames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_dir
|
str
|
Directory containing video files. |
required |
prompt_dir
|
str
|
Path to JSON file that lists ground-truth and generated video filenames. |
required |
max_len
|
int
|
Maximum number of frames to load per video. Default: 500. |
500
|
if_pad
|
bool
|
Whether to pad videos to exactly |
False
|
Source code in aigve/datasets/fid_dataset.py
__getitem__(index)
Returns:
Type | Description |
---|---|
tuple[Tensor, Tensor, str, str]
|
Tuple[torch.Tensor, torch.Tensor, str, str]: - Ground-truth (Real) video tensor of shape [T, C, H, W]. - Generated video tensor of shape [T, C, H, W]. - Ground-truth video name. - Generated video name. |
Source code in aigve/datasets/fid_dataset.py
GSTVQADataset
Bases: Dataset
Dataset for GSTVQA metric, supports feature extraction using VGG16 or ResNet.
Source code in aigve/datasets/gstvqa_dataset.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 |
|
__getitem__(index)
Returns a tuple of
deep_features (torch.Tensor): Shape [max_len, 2944] Mean and std features extracted from input frames using the chosen model (VGG16 or ResNet). Padded to self.max_len if the number of frames is less. num_frames (int): The number of frames in the video. video_name (str): The file name for the video.
Source code in aigve/datasets/gstvqa_dataset.py
LightVQAPlusDataset
Bases: Dataset
Dataset for LightVQA+. Extracts: - spatial_features (torch.Tensor): Extracted key frames. - temporal_features (torch.Tensor): SlowFast motion features. - BNS_features (torch.Tensor): Brightness & Noise features. - BC_features (torch.Tensor): Temporal CLIP-based brightness contrast features. - video_name (str): Video filename.
Source code in aigve/datasets/lightvqa_plus_dataset.py
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 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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
__getitem__(index)
Returns:
Name | Type | Description |
---|---|---|
spatial_features |
Tensor
|
Spatial features. Shape: [8, 3, 672, 1120]. |
bns_features |
Tensor
|
Brightness & Noise features. Shape: [8, 300]. |
bc_features (torch.Tensor
|
Temporal brightness contrast features. Shape: [8, final_dim].) |
|
temporal_features |
Tensor
|
SlowFast motion features. Shape: [1, feature_dim(2304)] |
video_name |
str
|
Video filename. |
Source code in aigve/datasets/lightvqa_plus_dataset.py
extract_bc_features(video_path)
Extracts Brightness Consistency features using CLIP-based temporal processing.
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Extracted BC feature (Shape: [8, final_dim]). |
Source code in aigve/datasets/lightvqa_plus_dataset.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
extract_bns_features(video_path)
Extracts Brightness & Noise Sensitivity (BNS) features using CLIP. Local Feature Extraction (res1) → Uses 8 key frames Global Feature Extraction (res2) → Uses all frames
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path
|
str
|
Path to the video file. |
required |
Returns:
Name | Type | Description |
---|---|---|
spatial_features |
Tensor
|
Extracted 8 evenly spaced key frames across the entire video duration. Shape [8, 3, 672, 1120] containing 8 key frames. |
final_res |
Tensor
|
Extracted BNS feature (Shape: [8, 300]). |
Source code in aigve/datasets/lightvqa_plus_dataset.py
extract_key_frames(video_path)
Extracts 8 evenly spaced key frames across the entire video duration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path
|
str
|
Path to the video file. |
required |
Returns:
Name | Type | Description |
---|---|---|
spatial_features |
Tensor
|
Shape [8, 3, 672, 1120] containing 8 key frames. |
Source code in aigve/datasets/lightvqa_plus_dataset.py
extract_temporal_features(video_path)
Extracts SlowFast motion features on the entire video segment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path
|
str
|
Path to the video file. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Extracted motion features (Shape: [1, feature_dim(2304)]). |
Source code in aigve/datasets/lightvqa_plus_dataset.py
get_global_sf(video_path)
Extracts global brightness & noise features across full video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path
|
str
|
Path to video file. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Extracted global features (Shape: [8, 150]). |
Source code in aigve/datasets/lightvqa_plus_dataset.py
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 |
|
SimpleVQADataset
Bases: Dataset
Dataset for SimpleVQA. Each sample returns: - spatial_features (torch.Tensor): Extracted spatial frames. - motion_features (torch.Tensor): Extracted motion-based clips. - video_name (str): Video filename.
Source code in aigve/datasets/simplevqa_dataset.py
13 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 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 |
|
__getitem__(index)
Returns:
Name | Type | Description |
---|---|---|
spatial_features |
Tensor
|
Shape [v_len_second, 3, 448, 448]
|
motion_features |
List[Tensor]
|
List of motion feature tensors. Each tensor has shape [32, 3, 224, 224]. Len(List) is total seconds of the video (i.e. v_len_second), with minium 8 (i.e. min_video_seconds). |
video_name |
str
|
Video filename |
Source code in aigve/datasets/simplevqa_dataset.py
video_processing_motion(video_path)
Extracts motion-based clips suitable for SlowFast. - Standard input size: It resizes frames to 224 * 224. - Motion-based clips: Processes at leaset 8-second clips, select 32 consecutive frames from each second. Return: transformed_video_all (List[torch.Tensor]): Tensor shape[video_length_clip(32), 3, 224, 224]. Len(List) is total seconds of the video, with minium 8. video_name (str)
Source code in aigve/datasets/simplevqa_dataset.py
video_processing_spatial(video_path)
Extracts spatial frames with proper resizing and normalization.
- Key frame extraction: It selects 1 frame per second.
- Standard input size: It resizes frames to 448 * 448 (after an initial resize to 520).
Return:
transformed_video (torch.Tensor): shape[video_length_read, 3, 448, 448].
video_length_read
is total seconds of the video (though 2 for toy dataset) with minium 8 (i.e. min_video_seconds).
video_name (str)
Source code in aigve/datasets/simplevqa_dataset.py
ToyDataset
Bases: BaseDataset
ToyDataset for testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_root
|
str
|
Root directory for data. |
None
|
ann_file
|
str
|
Annotation file path. |
''
|
metainfo
|
dict
|
Metadata information. |
None
|
data_prefix
|
dict
|
Prefix paths for different modalities. |
None
|
pipeline
|
List[Union[Callable, dict]]
|
Data transformation pipeline. |
[]
|
modality
|
dict
|
Specifies which modalities are used (video, text, image). |
dict(use_video=True, use_text=True, use_image=False)
|
image_frame
|
int
|
Number of frames for images. |
None
|
Source code in aigve/datasets/toy_dataset.py
parse_data_info(raw_data_info)
Parse raw data info.
Source code in aigve/datasets/toy_dataset.py
VideoPhyDataset
Bases: Dataset
Source code in aigve/datasets/videophy_dataset.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 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 |
|
__getitem__(idx)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
Index of the dataset |
required |
Returns: dict: Dictionary containing the video, text, video path and caption
Source code in aigve/datasets/videophy_dataset.py
__init__(data_path, video_root_path, hf_token, tokenizer=None, processor=None, max_length=2048, media_tokens=['<image>', '<|video|>'], hf_checkpoint='videophysics/videocon_physics')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_path
|
str
|
Path to the data folder, it should be a json file |
required |
tokenizer
|
Tokenizer
|
Tokenizer object |
None
|
processor
|
Processor
|
Processor object |
None
|
max_length
|
int
|
Maximum length of the input sequence |
2048
|
media_tokens
|
list
|
List of media tokens |
['<image>', '<|video|>']
|
Source code in aigve/datasets/videophy_dataset.py
VideoScoreDataset
Bases: BaseDataset
Source code in aigve/datasets/videoscore_dataset.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 |
|
__getitem__(idx)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index of the data |
required |
Source code in aigve/datasets/videoscore_dataset.py
__init__(ann_file='', metainfo=None, data_root='', data_prefix={'video_path_pd': ''}, filter_cfg=None, indices=None, serialize_data=True, pipeline=[], test_mode=False, lazy_init=False, max_refetch=1000, model_name=None, regression_query_prompt=None, max_num_frames=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ann_file
|
str
|
annotation file path |
''
|
metainfo
|
dict
|
meta information about the dataset |
None
|
data_root
|
str
|
the root path of the data |
''
|
data_prefix
|
dict
|
the prefix of the data, for example, the prefix of the image path |
{'video_path_pd': ''}
|
filter_cfg
|
dict
|
the filter configuration |
None
|
indices
|
list
|
the indices of the data |
None
|
serialize_data
|
bool
|
whether to serialize the data |
True
|
pipeline
|
list
|
the pipeline of the data |
[]
|
test_mode
|
bool
|
whether in test mode |
False
|
lazy_init
|
bool
|
whether to lazy initialize the dataset |
False
|
max_refetch
|
int
|
the maximum number of refetching data |
1000
|
model_name
|
str
|
the name of the model |
None
|
regression_query_prompt
|
str
|
the prompt for the regression query |
None
|
max_num_frames
|
int
|
the maximum number of frames |
None
|