tools/data/parse_file_list.py
def generate_class_index_file():
        """This function will generate a `ClassInd.txt` for HMDB51 in a format
        like UCF101, where class id starts with 1."""
        frame_path = 'data/hmdb51/rawframes'
        annotation_dir = 'data/hmdb51/annotations'

        class_list = sorted(os.listdir(frame_path))
        class_dict = dict()
        with open(class_index_file, 'w') as f:
            content = []
            for class_id, class_name in enumerate(class_list):
                # like `ClassInd.txt` in UCF-101, the class_id begins with 1
                class_dict[class_name] = class_id + 1
                cur_line = ' '.join([str(class_id + 1), class_name])
                content.append(cur_line)
            content = '\n'.join(content)
            f.write(content)

        for i in range(1, 4):
            train_content = []
            test_content = []
            for class_name in class_dict:
                filename = class_name + f'_test_split{i}.txt'
                filename_path = osp.join(annotation_dir, filename)
                with open(filename_path, 'r') as fin:
                    for line in fin:
                        video_info = line.strip().split()
                        video_name = video_info[0]
                        if video_info[1] == '1':
                            target_line = ' '.join([
                                osp.join(class_name, video_name),
                                str(class_dict[class_name])
                            ])
                            train_content.append(target_line)
                        elif video_info[1] == '2':
                            target_line = ' '.join([
                                osp.join(class_name, video_name),
                                str(class_dict[class_name])
                            ])
                            test_content.append(target_line)
            train_content = '\n'.join(train_content)
            test_content = '\n'.join(test_content)
            with open(train_file_template.format(i), 'w') as fout:
                fout.write(train_content)
            with open(test_file_template.format(i), 'w') as fout:
                fout.write(test_content)
This function will generate a `ClassInd.txt` for HMDB51 in a format
        like UCF101, where class id starts with 1.
This function will generate a `ClassInd.txt` for HMDB51 in a format
like UCF101, where class id starts with 1.
This function will generate a ` ClassInd . txt ` for HMDB51 in a format like UCF101 where class id starts with 1 .
def generate_class_index_file():
        frame_path = 'data/hmdb51/rawframes'
        annotation_dir = 'data/hmdb51/annotations'
        class_list = sorted(os.listdir(frame_path))
        class_dict = dict()
        with open(class_index_file, 'w') as f:
            content = []
            for class_id, class_name in enumerate(class_list):
                class_dict[class_name] = class_id + 1
                cur_line = ' '.join([str(class_id + 1), class_name])
                content.append(cur_line)
            content = '\n'.join(content)
            f.write(content)
        for i in range(1, 4):
            train_content = []
            test_content = []
            for class_name in class_dict:
                filename = class_name + f'_test_split{i}.txt'
                filename_path = osp.join(annotation_dir, filename)
                with open(filename_path, 'r') as fin:
                    for line in fin:
                        video_info = line.strip().split()
                        video_name = video_info[0]
                        if video_info[1] == '1':
                            target_line = ' '.join([
                                osp.join(class_name, video_name),
                                str(class_dict[class_name])
                            ])
                            train_content.append(target_line)
                        elif video_info[1] == '2':
                            target_line = ' '.join([
                                osp.join(class_name, video_name),
                                str(class_dict[class_name])
                            ])
                            test_content.append(target_line)
            train_content = '\n'.join(train_content)
            test_content = '\n'.join(test_content)
            with open(train_file_template.format(i), 'w') as fout:
                fout.write(train_content)
            with open(test_file_template.format(i), 'w') as fout:
                fout.write(test_content)
def generate_class_index_file ( ) : frame_path = 'data/hmdb51/rawframes' annotation_dir = 'data/hmdb51/annotations' class_list = sorted ( os . listdir ( frame_path ) ) class_dict = dict ( ) with open ( class_index_file , 'w' ) as f : content = [ ] for class_id , class_name in enumerate ( class_list ) : class_dict [ class_name ] = class_id + 1 cur_line = ' ' . join ( [ str ( class_id + 1 ) , class_name ] ) content . append ( cur_line ) content = '\n' . join ( content ) f . write ( content ) for i in range ( 1 , 4 ) : train_content = [ ] test_content = [ ] for class_name in class_dict : filename = class_name + f'_test_split{i}.txt' filename_path = osp . join ( annotation_dir , filename ) with open ( filename_path , 'r' ) as fin : for line in fin : video_info = line . strip ( ) . split ( ) video_name = video_info [ 0 ] if video_info [ 1 ] == '1' : target_line = ' ' . join ( [ osp . join ( class_name , video_name ) , str ( class_dict [ class_name ] ) ] ) train_content . append ( target_line ) elif video_info [ 1 ] == '2' : target_line = ' ' . join ( [ osp . join ( class_name , video_name ) , str ( class_dict [ class_name ] ) ] ) test_content . append ( target_line ) train_content = '\n' . join ( train_content ) test_content = '\n' . join ( test_content ) with open ( train_file_template . format ( i ) , 'w' ) as fout : fout . write ( train_content ) with open ( test_file_template . format ( i ) , 'w' ) as fout : fout . write ( test_content )
This function will generate a `ClassInd.txt` for HMDB51 in a format
like UCF101, where class id starts with 1.
This function will generate a ` ClassInd . txt ` for HMDB51 in a format like UCF101 where class id starts with 1 .
"""This function will generate a `ClassInd.txt` for HMDB51 in a format
        like UCF101, where class id starts with 1.""" # like `ClassInd.txt` in UCF-101, the class_id begins with 1