(solved) Not possible to collate samples of your dataset

Hey all,

I’ve seen this error on a few other posts but haven’t found a solution that works after the past few hours. I’m trying to make a cycleGAN instance that makes pictures of dogs cubic (like the art form), similar to the forests -> abstract art medium project. I used the download technique from dl1 lesson 2 to pull 300 pics of dogs/cubic art and stored them in folders called cubed/dogs and cubed/cubes, respectively. Since I’m using a cycleGAN project, however, I needed to create a custom ImageTupleList (which I directly copy/pasted from the dl2 tutorial). However, the following line of code (specifically the .databunch() part) throws the aforementioned error:

data = (ImageTupleList.from_folders(path, 'cubes', 'dogs')
                      .split_none()
                      .label_empty()
                      .transform(get_transforms(), size=128)
                      .databunch(bs=4))

I’m guessing this is because the image size pulled from google isn’t standardized but I’d think the size part of the transforms function would fix that? Would really appreciate any advice. Also, is there a better reference for implementing cycleGANS / modern GANs through the fastai library? Thanks in advance.

Cheers,
Charlie

EDIT: (solved)
I needed to add the following line to the apply_tfms method in the ImageTuple class
self.data = [-1+2self.img1.data,-1+2self.img2.data]

My transformations were being applied to to the images but not to the underlying tensors. This transformation/normalization fixed the problem.

1 Like

when you are creating your databunch/dataloader are you passing item_tfms = Resize(128) ? I also think it is because your images are not sized correctly

Would that Resize(128) go inside of the transform function? i.e. .transform(get_transforms(), Resize(128))?

Pretty sure this is V1, I’m just using the version from the most decent DL course

sorry the quickest thing i can think of is to resize your images before hand.
new_image = image.resize((400, 400))
for a few images (a batch may be) and then try to see if it fixes it

1 Like