Image generator not working, "Your generator is empty."

I’m trying to make a unet generate images. Regardless of what I do, fine tuning shows a valid_loss of None, and warns “Your generator is empty.” However, I’ve verified that the dataloader is providing batches properly.

I think the issue may be associated with the loss function, but I’m not sure. Does anyone have any idea what I’m doing wrong or what I can do to troubleshoot?


from import *
from fastai.imports import *
from import *
from import * #kitchen sink
from pathlib import Path 

def labelFunc(f):
    return Path("outputPics/" +

img = DataBlock(blocks=(ImageBlock(cls=PILImage), ImageBlock(cls=PILImage)),
                   get_items = get_image_files,
                   get_y = labelFunc,
                   item_tfms=Resize(120, 200),
dls = img.dataloaders(Path("inputPics/"), bs=2)

learn = unet_learner(dls, models.resnet18, n_out=3, loss_func=nn.MSELoss())

learn.fine_tune(2, 3e-3)

how many images do you have?

Only 3 at this point, but the batch size is 2. Is it too few?

1 Like

Oh right. This would be too few, there needs to be enough for a validation set.
I just duplicated some images, and it started working. Thank you so much for your help!

1 Like