Update 1
After removed the EarlyStoppingCallback() my train/valid loss plot look much better now.
Unfortunately, although the valid_loss improved a lot, my trained mode has stopped recognizing birds and it does not detect birds AT ALL.
And here is the code to plot learner.recoder records:
learn.recorder.plot_lr()
learn.recorder.plot()
learn.recorder.plot_losses()
and here are the plots:
Here is the code:
tunedTransform = partial(get_transforms, max_zoom=1.5)
data = ImageDataBunch.from_folder(path=path_img, train=train_folder, valid=valid_folder, ds_tfms=tunedTransform(),
size=(299, 450), bs=40, classes=['birds', 'others'],
resize_method=ResizeMethod.SQUISH)
data = data.normalize(imagenet_stats)
data.show_batch(rows=6, figsize=(14,12))
learn = cnn_learner(data, models.resnet50, metrics=error_rate)
learn.lr_find()
learn.recorder.plot()
learn.fit_one_cycle(30, max_lr=slice(5e-5,5e-4))
I just trained my birds model. It works fine when I was testing it with close pictures.
But when I moved the pictures further away my camera, the model was not able to detect birds.
My guess is
data = ImageDataBunch.from_folder(path=path_img, bs=48, valid_pct= 0.2, ds_tfms=get_transforms(), size=299, classes=['birds', 'others'])
get_transforms()
size=299
the function and size parameters crop my training images to centralize the images, so that birds in the images appear to be closer to the camera.
How to fix it?