Welp, that fixed it. Thank you. Updated code, internal notes-to-self and all:
class ImageScalarDataset(ImageDataset):
def __init__(self, df:DataFrame, path_column:str='file_path', dependent_variable:str=None):
# The superclass does nice things for us like tensorizing the numpy
# input
super().__init__(df[path_column], np.array(df[dependent_variable], dtype=np.float32))
# Old FastAI uses loss_fn, new FastAI uses loss_func
self.loss_func = layers.MSELossFlat()
self.loss_fn = self.loss_func
# We have only one "class" (i.e., the single output scalar)
self.classes = [0]
def __len__(self)->int:
return len(self.y)
def __getitem__(self, i):
# return x, y | where x is an image, and y is the scalar
return open_image(self.x[i]), self.y[i]