예제 #1
0
def get_dataloader(type='segment'):
    COMP_PATH = './'
    split = 'test'

    test_split = path.join(COMP_PATH, 'splits/test.split1.bundle')
    mapping_loc = path.join(COMP_PATH, 'splits/mapping_bf.txt')
    GT_folder = path.join(
        COMP_PATH,
        'groundTruth/')  #Ground Truth Labels for each training video
    DATA_folder = path.join(COMP_PATH,
                            'Data/')  #Frame I3D features for all videos

    actions_dict = read_mapping_dict(mapping_loc)

    test_feat = load_data(test_split,
                          actions_dict,
                          GT_folder,
                          DATA_folder,
                          datatype=split,
                          target=type)  #

    if type == 'segment':
        test_dataset = TestDataset(test_feat, test_seg_txt, seed=2)
    else:
        # todo
        pass

    test_dataloader = tud.DataLoader(test_dataset,
                                     batch_size=batch_size,
                                     shuffle=False,
                                     num_workers=8,
                                     pin_memory=True)

    return test_dataloader
test to load test set
'''
split = 'training'
#split = 'test'
train_split = os.path.join(COMP_PATH,
                           'splits/train.exclude_val.bundle')  #Train Split
# train_split =  os.path.join(COMP_PATH, 'splits/dev_train.split1.bundle') #Train Split
val_split = os.path.join(COMP_PATH, 'splits/val.split1.bundle')
test_split = os.path.join(COMP_PATH, 'splits/test.split1.bundle')  #Test Split
GT_folder = os.path.join(
    COMP_PATH, 'groundTruth/')  #Ground Truth Labels for each training video
DATA_folder = os.path.join(COMP_PATH,
                           'Data/')  #Frame I3D features for all videos
mapping_loc = os.path.join(COMP_PATH, 'splits/mapping_bf.txt')

actions_dict = read_mapping_dict(mapping_loc)

data_feat, data_labels = load_data(train_split,
                                   actions_dict,
                                   GT_folder,
                                   DATA_folder,
                                   datatype=split,
                                   target='file')  #
valid_feat, valid_labels = load_data(val_split,
                                     actions_dict,
                                     GT_folder,
                                     DATA_folder,
                                     datatype=split,
                                     target='file')  #

# balance data