-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathautoshot_dataset.py
31 lines (26 loc) · 1.34 KB
/
autoshot_dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import glob
import os
class AutoShotDataset:
"""
The AutoShot Dataset (test splits) proposed by Zhu et al. in AutoShot: A Short Video Dataset and State-of-the-Art Shot Boundary Detection
Link: https://openaccess.thecvf.com/content/CVPR2023W/NAS/html/Zhu_AutoShot_A_Short_Video_Dataset_and_State-of-the-Art_Shot_Boundary_Detection_CVPRW_2023_paper.html
The original test set consists of 200 videos, but 36 videos are missing (AutoShot/videos/<video_id>.mp4).
The annotated scenes are provided in corresponding files (AutoShot/annotations/<video_id>.txt)
"""
def __init__(self, dataset_dir: str):
self._video_files = [
file for file in sorted(glob.glob(os.path.join(dataset_dir, "videos", "*.mp4")))
]
self._scene_files = [
file for file in sorted(glob.glob(os.path.join(dataset_dir, "annotations", "*.txt")))
]
for video_file, scene_file in zip(self._video_files, self._scene_files):
video_id = os.path.basename(video_file).split(".")[0]
scene_id = os.path.basename(scene_file).split(".")[0]
assert video_id == scene_id
def __getitem__(self, index):
video_file = self._video_files[index]
scene_file = self._scene_files[index]
return video_file, scene_file
def __len__(self):
return len(self._video_files)