File size: 1,102 Bytes
4b86302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc19f9
4b86302
 
 
 
 
 
 
 
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
# Script to generate train_list.txt file which contains all the training videos

import logging
import os

DATA_DIR = os.path.abspath(os.path.join(__file__, "../../", "data"))
VIDEO_DIR = os.path.join(DATA_DIR, "video")
SUBDIRS = ["1-1004", "1005-2004", "2005-2804", "2805-3319", "3320-3954"]


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger(__name__)

    with open(os.path.join(DATA_DIR, "train_list.txt"), "w") as f:
        for subdir in SUBDIRS:
            subdir_path = os.path.join(VIDEO_DIR, subdir)
            logger.info(f"Processing subdir: {subdir_path}")

            try:
                for video in os.listdir(subdir_path):
                    f.write(f"{subdir}/{video.split('.mp4')[0]}\n")
            except FileNotFoundError as e:
                logger.error(
                    f"Error processing subdir: {subdir_path}: {e.__class__.__name__}"
                )
            except Exception as e:
                logger.error(f"Unknown error processing subdir: {subdir_path}: {e}")

    logger.info("Processing finished")