Skip to content

Usage with Fast.ai

Severin Ibarluzea edited this page Mar 27, 2020 · 6 revisions

Universal Data Tool files integrate easily with fast.ai libraries. First, export your project to a *.udt.csv file.

Usage with ImageDataBunch

Move all your files into some kind of "images" directory on the GPU machine. Then run code similar to something below. The example below is for image classification, but you should be able to modify the steps for other image tasks.

from fastai import *
from fastai.vision import *

df = pd.read_csv("./myfile.udt.csv")

# Create a filename column with just the filenames, remove the other columns
df["filename"] = [a.split("/")[-1] if isinstance(a,str) else a for a in list(df["imageUrl"])]
df = df[["filename", "output.classification"]]

# Remove any invalid entries
df.set_index("filename", inplace=True)
df.drop(np.NaN, inplace=True)
df.reset_index(inplace=True)

databunch = ImageDataBunch.from_df(".", df, folder="./images", seed=42, label_col="filename")

Now your databunch is ready for some models!

Clone this wiki locally