Help with understanding and predicting the model

Hi I just started with deep learning and based on the lecture 1 and 2 I created a classification model with custom images but I am stuck with a few things and I am unable to wrap my head around it.

I have uploaded all my images to a folder in jupyter and reading lablels from csv below is my code:

np.random.seed(42)
data = ImageDataBunch.from_csv(path, folder=".", valid_pct=0.2, csv_labels='labels.csv',
ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats)

#need to understand differnce between create_cnn and cnn_learner

 learn = create_cnn(data, models.resnet34, metrics=accuracy)
defaults.device = torch.device('cuda') 
learn.fit_one_cycle(4)
learn.unfreeze()
learn.lr_find()
learn.recorder.plot()
learn.fit_one_cycle(4, max_lr=slice(3e-5, 3e-4))
learn.save('my-first-model')
#now here i try to do an export()(but going through the forums I understand that export is only for inference but still having a tough time wrapping my head around it
learn.export()
also I get the below error
AttributeError: module 'fastai.vision.learner' has no attribute 'export'

main issue is how do I load my saved model and how do I predict my classes names (I have 4 classes), Lastly if I export the model into my local how can I run it to predict classes.

I tried the ImageDataBunch.from_single_classes its now load_empty as per documentation but all I get is
‘ImageDataBunch’ has no attribute ‘load_empty’

so in conclusion I have a saved model I am not sure how to load the model and how to predict my class names for a given image

any suggestions much appreciated.

ps: I believe I am posting in the appropriate forum if not please excuse me and point me to the right place.

Thanks,
bhanu

learn.load('my-first-model') should work.

Yes I tried this but It did not work for me.
So yesterday I saved a model ‘my-first-model’.

Trying to get predictions like this

classes = ['a,'b','c','d']
#create an empty databunch
data = ImageDataBunch.load_empty(path, classes, tfms=get_transforms(), 
           size=224).normalize(imagenet_stats)
learn = create_cnn(data, models.resnet34).load('my-first-model')

but I get the below error
type object ‘ImageDataBunch’ has no attribute ‘load_empty’

what am I doing wrong while trying to load my model? please advise

Hi,

i was able to use cnn_learner once i upgrade the fastai version and also was able to load my model.

Any ways I have one last confusion

ImageDataBunch.SIngle_from_classes has been deprecated to databunch.load_empty so I need to again define databunch.

So for testing also I have used the same

data = ImageDataBunch.from_csv(path, folder=".", valid_pct=0.2, csv_labels='labels.csv',
ds_tfms=get_transforms(), size=224, num_workers=4).normalize(imagenet_stats)

and then called
learn = cnn_learner(data,models.resnet34)
then
learn = learn.load(‘my-first-model’)
learn.predict(img)

my question is for testing after loading my model i need to create an empty databunch and not reuse the one which I created while training the model.

I am confused in this step any clarification is much appreciated.
Thanks