2
$\begingroup$

I was applying this CNN fine-tuning example from Matlab.

The example shows how to fine-tune a pre-trained CNN on letters to classify images of digits. Now I would like to use this new fine-tuned CNN on new images of digits that i have on my computer. How can I do that?

$\endgroup$
5
  • $\begingroup$ Are you basically asking how to do what apparently is already explained in the link you provided above? $\endgroup$ – nbro May 17 '17 at 15:08
  • $\begingroup$ I want to use the newly trained CNN on digits for predicting the label of an image he has not seen before. An image that is not among the test images it was fine-tuned on. I tried using the predict function but it gives me an error. $\endgroup$ – F.Lin May 17 '17 at 15:56
  • $\begingroup$ Maybe your question is more appropriate for this website: stats.stackexchange.com, but though I think this type of questions should also be on-topic here! $\endgroup$ – nbro May 17 '17 at 15:58
  • $\begingroup$ @F.Lin There is a misunderstanding I think: "An image that is not among the test images it was fine-tuned on" - Test images are by definition images that were NOT used for training the CNN. So, your images should go in place of the variable testDigitData in the example from the link you give. The CNN is trained on trainDigitData. $\endgroup$ – Eskapp May 18 '17 at 20:55
  • $\begingroup$ Thank you Eskapp for the reply. The problem is that i don't have a dataset, actually i only have veriy few images. $\endgroup$ – F.Lin May 19 '17 at 9:17
2
$\begingroup$

As the question has been left unanswered, for future readers of the questions:

The documentation you link gives the answer to your question.

Given the fact you have a pre-trained model as you say:

YPred = classify(netTransfer,testDigitData);

where netTansfer is the pre-trained model and testDigitData is your test image that you want to predict the label.

Your image(s) need to be loaded following the instruction also given in the documentation:

digitDatasetPath = fullfile(matlabroot,'toolbox','nnet','nndemos', ...
    'nndatasets','DigitDataset');

digitData = imageDatastore(digitDatasetPath, ...
    'IncludeSubfolders',true,'LabelSource','foldernames');

(digitData will become testDigitData if the images that you load are for testing purpose only, which seems to be your case)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.