link: image classifier using fastai and google colab

wonderful world·2021년 10월 2일
0

https://medium.com/@swapp19902/image-classifier-using-fastai-and-google-colab-87dfc4e90e63

from fastai import *
from fastai.vision import *
import numpy as np

!pip install google_images_download

from google_images_download import google_images_downloadresponse = google_images_download.googleimagesdownload()arguments = {"keywords":"Rabbit,Racoon","limit":60,"print_urls":False}paths = response.download(arguments)print(paths)

tfms = get_transforms(do_flip=False)
path = '/content/drive/My Drive/fastai/IC1'
data = ImageDataBunch.from_folder(path,ds_tfms=tfms, size=100)

data.show_batch(rows=3, figsize=(10,10))

my_trained_mod = create_cnn(data, models.resnet34, metrics=error_rate)
my_trained_mod.fit_one_cycle(6)


pred = my_trained_mod.predict(img)
print(pred)
```(Category rabbit, tensor(0), tensor([0.7942, 0.2058]))``

my_trained_mod.lr_find()
my_trained_mod.recorder.plot()

my_trained_mod.fit_one_cycle(3, max_lr=slice(1e-6,1e-1))

profile
hello wirld

0개의 댓글