May I ask where is the error? Why are the objects of the list uncallable? I checked the path is no problem.
微信图片_202006241614521093×221 13.1 KB
B_data_iter = iter(tgt_dataloader)

for epoch in range(opt.epoch, opt.n_epochs):
    for step, (src_image, src_label) in enumerate(src_dataloader):
       
        # Idefinitely loop over target data loader
        try:
            (tgt_image, _) = B_data_iter.next()
        except StopIteration:
            B_data_iter = iter(tgt_dataloader)
            (tgt_image, _) = B_data_iter.next()

src_dataloader = get_data_loader(name=opt.src_datasets, dataset_root=opt.dataroot, batch_size=opt.batchSize, train=True)

def get_data_loader(name, dataset_root, batch_size, train=True):

    if name == "sandy_train":
        return get_train_data(dataset_root, batch_size, 'train', 'sandy')

def get_train_data(dataset_root, batch_size, datatype, category):
    # image pre-processing
    pre_process = [ transforms.Resize(int(256*1.12), Image.BICUBIC), 
                transforms.RandomCrop(256), 
                transforms.RandomHorizontalFlip(),
                transforms.ToTensor(),
                transforms.Normalize((0.5,0.5,0.5), (0.5,0.5,0.5)) ]
    
    # datasets and data_loader
    train_dataset = datasets.ImageFolder(               
        os.path.join(dataset_root, datatype, category),
        transform=pre_process)

    train_dataloader = data.DataLoader(
        dataset=train_dataset,
        batch_size=batch_size,
        shuffle=True,
        num_workers=0)

    return train_dataloader