Spaces:
Runtime error
Runtime error
File size: 907 Bytes
3602056 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from fastcore.all import *
from fastai.vision.all import *
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
path = Path('data')
dls = DataBlock(
blocks=(ImageBlock, CategoryBlock),
get_items=get_image_files,
splitter=RandomSplitter(valid_pct=0.2, seed=42),
get_y=parent_label,
item_tfms=[Resize(500, method='squish')]
).new(item_tfms=RandomResizedCrop(128, min_scale=0.3)).new(item_tfms=Resize(250), batch_tfms=aug_transforms(mult=1.1)).dataloaders(path, bs=32)
learn = vision_learner(dls, resnet18, metrics=error_rate)
learnResult = learn.fine_tune(5)
learn.export('model.pkl')
# uncomment the following lines to generate some data debugging information
# interp = ClassificationInterpretation.from_learner(learn)
# interp.plot_confusion_matrix()
# plt.savefig('confusion_matrix.png')
#
# interp.plot_top_losses(12, nrows=4)
# plt.savefig('top_losses.png')
|