(
        valid_images_txt,
        img_filename_format="{:05d}.jpg")
return images_info
Arguments:
        valid_images_txt {str}: path of the txt file that 
            specifies the indices and labels of training images.
    Return:
        images_info {list of list}: shape=PxN, where:
            P: number of training images
            N=5: number of tags of that image, including: 
                [cnt_action, cnt_clip, cnt_image, action_label, filepath]
                An example: [8, 49, 2687, 'wave', 'wave_03-02-12-35-10-194/00439.jpg']
Arguments:
        valid_images_txt {str}: path of the txt file that 
            specifies the indices and labels of training images.
    Return:
        images_info {list of list}: shape=PxN, where:
            P: number of training images
            N=5: number of tags of that image, including: 
                [cnt_action, cnt_clip, cnt_image, action_label, filepath]
                An example: [8, 49, 2687, 'wave', 'wave_03-02-12-35-10-194/00439.jpg']
Arguments : valid_images_txt { str } : path of the txt file that specifies the indices and labels of training images . Return : images_info { list of list } : shape = PxN where : P : number of training images N = 5 : number of tags of that image including : [ cnt_action cnt_clip cnt_image action_label filepath ] An example : [ 8 49 2687 wave wave_03 - 02 - 12 - 35 - 10 - 194 / 00439 . jpg ]
def get_training_imgs_info(
        valid_images_txt,
        img_filename_format="{:05d}.jpg"):
    '''
    Arguments:
        valid_images_txt {str}: path of the txt file that 
            specifies the indices and labels of training images.
    Return:
        images_info {list of list}: shape=PxN, where:
            P: number of training images
            N=5: number of tags of that image, including: 
                [cnt_action, cnt_clip, cnt_image, action_label, filepath]
                An example: [8, 49, 2687, 'wave', 'wave_03-02-12-35-10-194/00439.jpg']                
    '''
    images_info = list()

    with open(valid_images_txt) as f:

        folder_name = None
        action_label = None
        cnt_action = 0
        actions = set()
        action_images_cnt = dict()
        cnt_clip = 0
        cnt_image = 0

        for cnt_line, line in enumerate(f):

            if line.find('_') != -1:  # A new video type
                folder_name = line[:-1]
                action_label = folder_name.split('_')[0]
                if action_label not in actions:
                    cnt_action += 1
                    actions.add(action_label)
                    action_images_cnt[action_label] = 0

            elif len(line) > 1:  # line != "\n"
                # print("Line {}, len ={}, {}".format(cnt_line, len(line), line))
                indices = [int(s) for s in line.split()]
                idx_start = indices[0]
                idx_end = indices[1]
                cnt_clip += 1
                for i in range(idx_start, idx_end+1):
                    filepath = folder_name+"/" + img_filename_format.format(i)
                    cnt_image += 1
                    action_images_cnt[action_label] += 1

                    # Save: 5 values
                    image_info = [cnt_action, cnt_clip,
                                  cnt_image, action_label, filepath]
                    assert(len(image_info) == LEN_IMG_INFO)
                    images_info.append(image_info)
                    # An example: [8, 49, 2687, 'wave', 'wave_03-02-12-35-10-194/00439.jpg']

        print("")
        print("Number of action classes = {}".format(len(actions)))
        print("Number of training images = {}".format(cnt_image))
        print("Number of training images of each action:")
        for action in actions:
            print("  {:>8}| {:>4}|".format(
                action, action_images_cnt[action]))

    return images_info
def get_training_imgs_info ( valid_images_txt , img_filename_format = "{:05d}.jpg" ) : images_info = list ( ) with open ( valid_images_txt ) as f : folder_name = None action_label = None cnt_action = 0 actions = set ( ) action_images_cnt = dict ( ) cnt_clip = 0 cnt_image = 0 for cnt_line , line in enumerate ( f ) : if line . find ( '_' ) != - 1 : # A new video type folder_name = line [ : - 1 ] action_label = folder_name . split ( '_' ) [ 0 ] if action_label not in actions : cnt_action += 1 actions . add ( action_label ) action_images_cnt [ action_label ] = 0 elif len ( line ) > 1 : # line != "\n" # print("Line {}, len ={}, {}".format(cnt_line, len(line), line)) indices = [ int ( s ) for s in line . split ( ) ] idx_start = indices [ 0 ] idx_end = indices [ 1 ] cnt_clip += 1 for i in range ( idx_start , idx_end + 1 ) : filepath = folder_name + "/" + img_filename_format . format ( i ) cnt_image += 1 action_images_cnt [ action_label ] += 1 # Save: 5 values image_info = [ cnt_action , cnt_clip , cnt_image , action_label , filepath ] assert ( len ( image_info ) == LEN_IMG_INFO ) images_info . append ( image_info ) # An example: [8, 49, 2687, 'wave', 'wave_03-02-12-35-10-194/00439.jpg'] print ( "" ) print ( "Number of action classes = {}" . format ( len ( actions ) ) ) print ( "Number of training images = {}" . format ( cnt_image ) ) print ( "Number of training images of each action:" ) for action in actions : print ( "  {:>8}| {:>4}|" . format ( action , action_images_cnt [ action ] ) ) return images_info