I get an error when loading my model (last line of code below):
from fastai.imports import *
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *
PATH = “/media/Snaps/”
sz=224
arch=resnet34
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz),bs=8)
learn = ConvLearner.pretrained(arch, data, precompute=False)
learn.load(‘break_direction’)
error is:
RuntimeError: While copying the parameter named 16.weight, whose dimensions in the model are torch.Size([3, 512]) and whose dimensions in the checkpoint are torch.Size([2, 512]).
Rest of the code is:
trn_tfms, val_tfms = tfms_from_model(arch,sz) # get transformations
im = val_tfms(open_image(’/media/train/test/snaps87687_1.png’))
learn.precompute=False # We’ll pass in a raw image, not activations
preds = learn.predict_array(im[None])
np.argmax(preds) # preds are log probabilities of classes
I’m trying to re-use my model to predict a specific image.