From_folder not working

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.

1 Like

I’m also struggling with this.

So far, so good.

What am I doing wrong? Thanks!

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?

@panaceus can u explain this code a little bit

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
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:
I also found this helpful as a reference:, specifically the first two sections under “A classification problem” and “A multilabel problem.”

1 Like

Here is my databunch creation, maybe it helps (basically a shorter version of @panaceus) :

data = (ImageList.from_folder("./images")
                .transform(get_transforms(), size=224)
1 Like

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')
data = (ImageList.from_folder(path)
                .transform(get_transforms(), size=224)
1 Like