TypeError: 'list' object is not callable

ky_Pa: <p>May I ask where is the error? Why are the objects of the list uncallable? I checked the path is no problem.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/e/1ef5f3269f96e3b2406503506dc64f3a50ac15d4.png" data-download-href="https://discuss.pytorch.org/uploads/default/1ef5f3269f96e3b2406503506dc64f3a50ac15d4" title="微信图片_20200624161452"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/e/1ef5f3269f96e3b2406503506dc64f3a50ac15d4.png" alt="微信图片_20200624161452" data-base62-sha1="4pTgGBhAzHn9YSWDmJvUxI6Gnf6" width="690" height="139" data-dominant-color="0D0D0D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">微信图片_20200624161452</span><span class="informations">1093×221 13.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<pre><code class="lang-auto">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()
</code></pre>
<pre><code class="lang-auto">src_dataloader = get_data_loader(name=opt.src_datasets, dataset_root=opt.dataroot, batch_size=opt.batchSize, train=True)
</code></pre>
<pre><code class="lang-auto">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')
</code></pre>
<pre><code class="lang-auto">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</code></pre>

ptrblck: <p><code>pre_process</code> is a plain <code>list</code>, while a transformation is expected.<br>
You could pass the list to <code>transforms.Compose</code> to make it callable.</p>

ky_Pa: <p>Thank! According to your method I solved the problem. But I still want to ask you a question. The input image size is 256<em>256. During preprocessing, it is resized to 256</em>1.12, and then cropped to 256. What is the purpose of doing this? What is Image.BICUBIC?</p>

ptrblck: <p>The resolution of the image is increased a bit and then randomly cropped back to <code>256x256</code>.<br>
This will basically crop smaller image parts from the original image and make sure the spatial resolution stays the same.</p>