Labeling images with float embedded in filename

Hi, I am having issues properly labeling images in an ImageDataBunch. I’ve explicitly defined the label as a FloatList, but it still keeps trying to label it using a CategoryList. I’ve verified that the regular expression does properly pull the float from the filename. Does anyone have any idea what I’m missing or doing wrong?

Example file names:

cryptopics/2017-09-22 00:00:00_1.0221594864258645.png
cryptopics/2013-11-26 00:00:00_1.1614170764976035.png
cryptopics/2017-09-26 00:00:00_0.9832723292169808.png


path = "cryptopics/"
fnames = get_image_files(path)
reg = r'(?!_)(.\.[^\.]*)'
data = (ImageDataBunch.from_name_re(path=path, fnames=fnames, pat=reg, size=24, label_cls= FloatList)


/home/luke/Documents/pythonscripts/fastai/venv/lib/python3.6/site-packages/fastai/ UserWarning: You are labelling your items with CategoryList.
Your valid set contained the following unknown labels, the corresponding items have been discarded.
0.980382398075567, 0.9753673292999135, 0.9847830967645371, 1.0117103822535345, 1.0020466865803739...
  if getattr(ds, 'warn', False): warn(ds.warn)

I researched this for hours, but of course fixed it a few minutes after posting. I changed the ImageDataBunch to an ImageList. Below is the code that got it to start working.

reg = r'(?!_)(.\.[^\.]*)'
data = (ImageList.from_folder(path)
            .label_from_re(reg, label_cls=FloatList)

learn = cnn_learner(data, models.resnet18)
1 Like