Python data.collate_fn() Examples
The following are 1
code examples of data.collate_fn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
data
, or try the search function
.
Example #1
Source File: test_modules.py From CAMP_iccv19 with Apache License 2.0 | 6 votes |
def test_f30k_dataloader(): data_name = "f30k" data_path = "./data/f30k" vocab_path = "./vocab/" vocab = pickle.load(open(os.path.join(vocab_path, '%s_vocab.pkl' % data_name), 'rb')) roots, ids = data.get_paths(data_path, data_name, False) transform = transforms.Compose([transforms.RandomSizedCrop(224), transforms.ToTensor()]) print (roots, ids) train_loader = data.get_loader_single(data_name, "train", # !!! roots["train"]["img"], roots["train"]["cap"], vocab, transform, ids=ids["train"], batch_size=16, shuffle=False, num_workers=1, collate_fn=data.collate_fn, distributed=False) print ("f30k dataloader output:", train_loader.dataset.img_num) #for (id, x) in enumerate(train_loader): #if id > 0 : break #print (id, x)