I made a multi class image classification model which does the identification of images into three catgegories. It worked great.
Now I have more similar data, but has 4 labels. I was wondering if I could use the above model( its weights) to retrain it for 4 labels. Does it sound good? If yes, how would I do that. I can certainly load the model like, but after that I am clueless.
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=False)
I think I found it. I used following for reference:
So, in the end, this is how my code looks like:
First, transfer learning (follows notebook from lesson3),
Load Resnet50 with the weights from imagenet:
from fastai.vision import *
from fastai import *
path = Config.data_path()/‘MYPATH’
df = pd.read_csv(path/‘train_v2.csv’)
tfms = get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.05, max_warp=0.)
src = (ImageList.from_csv(path, ‘train_v2.csv’, folder=‘train-jpg’, suf…
Though, instead of
I did learn.model[-2] = nn.Linear(in_features=512,out_features=5, bias=True), as for me the last layer was softmax
Though, I dont see any improvement. In fact I see either same level of performace or slightly worse. Is it due to less number of training data? The images are very similar though.