Lesson 2, pepper detector not creating val set

(Mitchell Murphy) #1

Hi, I am trying to create a basic model that predicts if a pepper is mild, medium or hot just from an image. I followed a similar process as to the bear classifier (from lesson 2), downloaded the images from Google Images, placed them in 3 folders and used the same code to create a databunch:

tfms = get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.1, max_warp=0.5, max_rotate=90)
np.random.seed(42)
data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2,
ds_tfms=tfms, size=224, num_workers=4).normalize(imagenet_stats)

Even though I specified I would like to use 20% of my data as a validation set, the above code only created the train set. I have done some reading and cannot figure out why this is happening, any suggesstions?

0 Likes

(Zachary Mueller) #2

Can you show what calling data outputs after you make the databunch?

0 Likes

(Mitchell Murphy) #3

Train: LabelList (149 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
hot,hot,hot,hot,hot
Path: /content/gdrive/My Drive/fastai-v3/data/peppers;

Valid: LabelList (37 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
medium,mild,mild,medium,medium
Path: /content/gdrive/My Drive/fastai-v3/data/peppers;

Test: None

0 Likes

(Zachary Mueller) #4

Your validation set is in there :slight_smile: See Valid: it has 37 items (or images in our case) which is about 20% of your overall images

0 Likes

(Mitchell Murphy) #5

Ah I see. I thought I was augmenting my data, how do I confirm this? (I suspect it is not augmenting at all as each epoch only takes a few seconds).

0 Likes

(Zachary Mueller) #6

You can call learn.show_batch(), and it is augmenting it too :wink:

0 Likes

(Mitchell Murphy) #7

Ah thanks so much! I guess what I was looking for was some stats on how much the data is being augmented…

0 Likes

(Zachary Mueller) #8

The documentation should have what you’re looking for then:

https://docs.fast.ai/vision.transform.html

Or do you mean individually per image?

0 Likes