-
-
Notifications
You must be signed in to change notification settings - Fork 192
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.
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)
data = ImageDataBunch.from_df(".", idb_df, folder="./images", seed=42,
label_col="output.classification", bs=4, size=224,
ds_tfms=get_transforms()).normalize(imagenet_stats)
Now your databunch is ready for some learning!