MultiFloatList - reimplementation of DeViSe in fastai v1

#1

Hi,

I was trying to get through devise in fastai 0.7 on google colab and got stack am problems on running out of memory while trying to get the first batch of images from DataSet.

Therefore, I decided to try to get it running in fastai v1, and got stuck on creation of databunch.

As input, I have a list of image names and a list of encoding (numpy vectors of size 300) for image classes for each image in the first list.

When I try to use the ImageDataBunch.from_lists,

tmd = ImageDataBunch.from_lists(PATH, images_full_path, img_vecs, 0.1)

I got for y type y: MultiCategoryList

I have searched a forum for similar topics, and found as well this post,

https://medium.com/@btahir/a-quick-guide-to-using-regression-with-image-data-in-fastai-117304c0af90,

but was not able to find how to do similar things with a vector of floats (regression on multiple outputs) instead of MultiCategoryList.

As well, I was not able to find something like MultiFloatList in fastai code.

Could you please advise, how to best proceed with this scenario in fastai v1?

0 Likes

#2

You will need to use the data block API in this case, and the label_cls you need is FloatList.

0 Likes

#3

Thanks a lot.

It seems to function at this stage.

The code that I have used for creating imagedatabunch from lists of imagepathes and imagevectors is the following:

fname2label = {f:l for (f,l) in zip(images_full_path, img_vecs)} 
data = (ImageList(images_full_path, path=PATH)
       .split_by_rand_pct(0.1)
       .label_from_func(lambda x:fname2label[x], label_cls=FloatList)
        .transform(get_transforms(), size=64).databunch()
      )
data.normalize(imagenet_stats)
1 Like