%reload_ext autoreload
%autoreload 2
from fastai import *
from fastai.vision import *
path = untar_data(URLs.DOGS)
path
Downloading http://files.fast.ai/data/examples/dogscats
HBox(children=(IntProgress(value=0, max=839285364), HTML(value='')))
PosixPath('/home/ubuntu/fastai/fastai/../data/dogscats')
data = ImageDataBunch.from_folder(path, ds_tfms=get_transforms(), tfms=imagenet_norm, size=224)
img,label = data.valid_ds[-1]
img.show(title=data.classes[label])
learn = ConvLearner(data, models.resnet34, metrics=accuracy)
learn.fit_one_cycle(1)
VBox(children=(HBox(children=(IntProgress(value=0, max=1), HTML(value='0.00% [0/1 00:00<00:00]'))), HTML(value…
Total time: 03:24 epoch train loss valid loss accuracy 0 0.051807 0.019401 0.993000 (03:24)
learn.unfreeze()
learn.fit_one_cycle(6, slice(1e-5,3e-4), pct_start=0.05)
VBox(children=(HBox(children=(IntProgress(value=0, max=6), HTML(value='0.00% [0/6 00:00<00:00]'))), HTML(value…
Total time: 06:40 epoch train loss valid loss accuracy 0 0.045248 0.031617 0.986000 (01:05) 1 0.031750 0.021102 0.992000 (01:06) 2 0.016185 0.021817 0.993000 (01:06) 3 0.015322 0.023137 0.991500 (01:07) 4 0.009295 0.021500 0.994000 (01:07) 5 0.008227 0.020382 0.994000 (01:07)
accuracy(*learn.TTA())
HBox(children=(IntProgress(value=0, max=16), HTML(value='')))
HBox(children=(IntProgress(value=0, max=16), HTML(value='0.00% [0/16 00:00<00:00]')))
VBox(children=(HBox(children=(IntProgress(value=0, max=8), HTML(value='0.00% [0/8 00:00<00:00]'))), HTML(value…
Total time: 00:33
tensor(0.9965)
learn = ConvLearner(data, models.resnet50, metrics=accuracy)
learn.fit_one_cycle(6)
VBox(children=(HBox(children=(IntProgress(value=0, max=6), HTML(value='0.00% [0/6 00:00<00:00]'))), HTML(value…
Total time: 09:24 epoch train loss valid loss accuracy 0 0.054099 0.024692 0.992500 (01:36) 1 0.039004 0.025797 0.991500 (01:33) 2 0.040528 0.021088 0.992000 (01:33) 3 0.026295 0.022694 0.993000 (01:33) 4 0.019064 0.016771 0.994000 (01:33) 5 0.016541 0.015919 0.995500 (01:33)
learn.unfreeze()
learn.fit_one_cycle(6, slice(1e-5,3e-4), pct_start=0.05)
VBox(children=(HBox(children=(IntProgress(value=0, max=6), HTML(value='0.00% [0/6 00:00<00:00]'))), HTML(value…
Total time: 12:42 epoch train loss valid loss accuracy 0 0.031718 0.019076 0.991000 (02:07) 1 0.031773 0.025698 0.991000 (02:07) 2 0.014313 0.032038 0.990500 (02:06) 3 0.009425 0.024969 0.991500 (02:06) 4 0.006091 0.016411 0.995500 (02:06) 5 0.004848 0.016143 0.995500 (02:07)
accuracy(*learn.TTA())
HBox(children=(IntProgress(value=0, max=16), HTML(value='')))
HBox(children=(IntProgress(value=0, max=16), HTML(value='0.00% [0/16 00:00<00:00]')))
VBox(children=(HBox(children=(IntProgress(value=0, max=8), HTML(value='0.00% [0/8 00:00<00:00]'))), HTML(value…
Total time: 00:45
tensor(0.9965)