File Exchange

image thumbnail

Image Recognition using Machine Learning Demo

version 1.0.0.0 (2.32 KB) by Johanna Pingel
The code from the video: Image Recognition Using Machine Learning

45 Downloads

Updated 27 Mar 2017

View License

This demo explains how to perform scene classification using Bag Of Features and Machine Learning in MATLAB. This follows along with the video demonstration: https://www.mathworks.com/videos/image-recognition-using-machine-learning-122900.html

Cite As

Johanna Pingel (2020). Image Recognition using Machine Learning Demo (https://www.mathworks.com/matlabcentral/fileexchange/62193-image-recognition-using-machine-learning-demo), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

I have a similar problem as described by Ronny Guendel. I am using a very simple case with three sets (categories) of plant images. I have about 50 images per set, and the images are clear without "background noise" and distractions. I get very good accuracy (from 90-98%) but it will only predict one of the categories during validation. Any help would be very much appreciated!!

I really like the simple explanation and the clear code. However, I have 92% validation accuracy, whereas when I export my trainedClassifier, I do have below 25% accuracy which drives me nuts! All coming from the same folder Therefore, the accuracy should be approximately the same.
I think with exporting the model goes something wrong!
Can someone help me or had a similar problem?

Rahul Singh

To all those having the trainedClassifier.RequiredVariables issue, watch the video carefully. She steps through each code block at a time (run and advance), but then stops midway to train the model and export it to the workspace. The reason you're getting the error is that you have no 'trainedClassifier' or you have trained the model on the wrong variable. Make sure to train it on 'SceneImageData' not 'SceneData'. You can open up the trainedClassifier in the workspace and see the attribute RequireVariables if you've done it right.

Hope this helps.

sanjeeth a

I am getting an error at this part
Unable to resolve the name trainedClassifier.RequiredVariables.

Error in Scene_Identification (line 54)
testSceneData = array2table(testSceneData, 'VariableNames', trainedClassifier.RequiredVariables);

The downloaded code uses actualSceneType = actualSceneType = test_set.Labels;
but the code in the video uses actualSceneType = categorical(repelem({test_set.Description}', [test_set.Count], 1));

monica mane

I am getting the following error

Undefined variable "trainedClassifier" or class "trainedClassifier.RequiredVariables".

Error in Scene_Identification (line 100)

testSceneData = array2table(testSceneData,'VariableNames',trainedClassifier.RequiredVariables);

Also,

The following line is different in the code provided to us and the code which you are explaining in the video

actualSceneType = test_set.Labels;

I am getting the following error

Undefined variable "trainedClassifier" or class "trainedClassifier.RequiredVariables".

Error in Scene_Identification (line 100)

testSceneData = array2table(testSceneData,'VariableNames',trainedClassifier.RequiredVariables);

Alan Peters

There is an error in this code that occurs at least twice. Instead of

%% Create Visual Vocabulary
tic
bag = bagOfFeatures(training_set,...
'VocabularySize',250,'PointSelection','Detector');
scenedata = double(encode(bag, training_set));
toc

use

%% Create Visual Vocabulary
tic
bag = bagOfFeatures(imageSet(training_set.Files),...
'VocabularySize',250,'PointSelection','Detector');
scenedata = double(encode(bag,imageSet(training_set.Files)));
toc

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux