Spaces:
Sleeping
Sleeping
File size: 749 Bytes
e8ab84a | 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 | from pathlib import Path
from fastai.vision.all import *
if __name__ == '__main__': # Add this block to handle multiprocessing on Windows
path = Path('images')
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(192, method='squish')]
).dataloaders(path, bs=32)
print("Dataloader defined")
learn = vision_learner(dls, resnet18, metrics=error_rate)
print("Learning complete")
learn.fine_tune(3)
print("Fine tuning complete")
#learn.save("bird-or-forest-model")
learn.export("./model/vehicles.pkl")
print("Saved model as: vehicles.pkl")
|