What am I doing wrong?
I want to extract label from these above (first cell) folders.
is this right -> ImageDataBunch create separate train,test,valid on its own.
My solution is below, though I still don’t have line 59 working (the image transforms). Any suggestions would be welcome.
Evidently line 59 should be: data = data.transform(tfms=tfms, size=224). Though I’m not entirely sure why.
Now, is it possible to put this all together into one ImageDataBunch command?
The documentation says that when you use data block API the tfms function, size and resize transformation parameters should be passed in the transform method explicitly. Here is the link on the documentation https://docs.fast.ai/vision.transform.html#get_transforms
search for ImageList
Sure. So line 49 was to delete a checkpoints folder that was showing up in my directory; it probably won’t apply to you. You can also ignore all of the type(data) calls; that was just so I could see what was going on. The rest of the code is adapted from this Medium post: https://medium.com/@tmckenzie.nz/using-the-fastai-data-block-api-b4818e72155b
I also found this helpful as a reference: https://docs.fast.ai/tutorial.data.html, specifically the first two sections under “A classification problem” and “A multilabel problem.”
Here is my databunch creation, maybe it helps (basically a shorter version of @panaceus) :
data = (ImageList.from_folder("./images")
.split_by_rand_pct(0.2)
.label_from_folder()
.transform(get_transforms(), size=224)
.databunch(bs=bs))
Thank you! Much cleaner. I added a fixed seed, and a .normalize at the end. I’m using ‘path’, since I guess we’re all storing things in different places – thanks for showing the notation though, it forced me to look it up. Mine would have been ImageList.from_folder("./data/chess")
path = Path('/notebooks/course-v3/nbs/dl1/data/chess')
np.random.seed(5)
data = (ImageList.from_folder(path)
.split_by_rand_pct(0.2)
.label_from_folder()
.transform(get_transforms(), size=224)
.databunch(bs=bs)
.normalize(imagenet_stats))