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?

Code:

from fastai.vision.all import *
from fastai.imports import *
from fastai.vision.core import *
from fastai.vision.data import * #kitchen sink
from pathlib import Path 

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

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

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