Images in one directory, labels in CSV file

Hi,

Apologies for the very basic question, but I am trying to run Fast.Ai on an image recognition problem where my training images are all in one directory and the labels are in a CSV file… I am totally stuck… can anybody give some guidance ? Running in Colab!

Hello. You can make DataLoaders from the CSV while relating the column that includes a clue of the related files to its path in the training images directory. For example, regarding the following data frame:
image

and this file tree:

image

you can do this way:

dls = ImageDataLoaders.from_csv(
    path='./data',
    csv_fname='labels.csv',
    fn_col=0,
    suff='.tif',
    folder='train',
    label_col=1,
)
3 Likes

thank you so much!!!

1 Like