Regression on Images for navigation

Fastai documentation shows neat functions for doing image classification but I am interested in image regression, i.e. predicting continuous not discrete quantities from images. The particular application I am working on is vehicle navigation where camera images are used to predict throttle and steering.

I have written a function (get_image_files) to produce lists of image filenames with a corresponding function (get_y) to produce a list of target outputs, i.e. list of lists. The documentation suggests that I can use the DataBlock class like this.

nav = DataBlock(
    blocks=(ImageBlock, RegressionBlock(n_out=2)),   # 
    get_items=get_image_files,   #outputs list of filenames
    splitter=RandomSplitter(valid_pct=0.2, seed=42),
    get_y = get_y,   #outputs list of target lists of floats
    item_tfms=Resize(128))

Question 1: There are neat functions to check the resulting datablock for category outputs but I am lost how to verify results for the regression case. Has anyone plowed this road before? I am not sure if the target should be a list of lists or a list of tuples.

Question 2: The 02_production notebook says

The get_image_files function takes a path, and returns a list of all of the images in that path (recursively, by default)

What does it mean by “recursively”? Is this similar to a python generator where each time you call the function you get a new member of the list?

1 Like

@cmasenas check out my notebook example here:

2: this means if I have a folder of images, and inside that folder is also a folder of images, etc etc it will look for and grab all of those, rather than simply checking the top most directory

I also have a multi-point regression (4 instead of 2) here: https://github.com/muellerzr/Practical-Deep-Learning-for-Coders-2.0/blob/master/Computer%20Vision/06_Multi_Point_Regression.ipynb

2 Likes