Editor's Note: This file was selected as MATLAB Central Pick of the Week
MATLAB code associated with the demo in 'Deep Learning in 11 Lines of MATLAB Code' video.
https://www.mathworks.com/videos/deep-learning-in-11-lines-of-matlab-code-1481229977318.html
This demo uses AlexNet, a pretrained deep convolutional neural network (CNN or ConvNet) that has been trained on over a million images.
The example has two parts: setting up the camera and performing object recognition. The first part shows how to use the webcam command to acquire images from the camera. Using the drawnow command, MATLAB is able to continuously update and display images taken by the camera.
You can download the webcam support package here:
https://www.mathworks.com/matlabcentral/fileexchange/45182-matlab-support-package-for-usb-webcams
The second part illustrates how to download a pretrained deep neural network called AlexNet and use MATLAB to continuously process the camera images. AlexNet takes the image as input and provides a label for the object in the image. You can experiment with objects in your surroundings to see how accurate AlexNet is.
You can download the AlexNet support package here:
https://www.mathworks.com/matlabcentral/fileexchange/59133-neural-network-toolbox-tm--model-for-alexnet-network
MathWorks Deep Learning Toolbox Team (2021). Deep Learning in 11 Lines of MATLAB Code (https://www.mathworks.com/matlabcentral/fileexchange/60659-deep-learning-in-11-lines-of-matlab-code), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
which camera do you use?
please I need the images, to be able to develop the example. thank you very much, my email is kmilo0717@hotmail.com
fast, nice and easy
I solved this problem! It works
I have errors
>> webcam_object_classification
Error using webcam (line 116)
No webcams have been detected. Please ensure the webcam is connected to the system.
Error in webcam_object_classification (line 5)
camera = webcam; % Connect to the camera
Is it possible to work with laptop built-in webcam? Or it works only with usb web-cams?
Hello everyone.
I was wondering if someone can help me with this matter.
I trained Alexnet for my pictures, I give it random images and it can detect them.
Now, I want to test it with a shot video. How should I modify the code to feed the video as a test? just to see how it works for video. I do not want to use the camera, I will use the shot video. Please feel free to contact me.
My email address: dorsa_dorsa@hotmail.com
my skype id: dorsa_dorsa@hotmail.com
work very well.
I am getting the that error while starting the TransferLearningVideo.m.
hi, there is an error when i run the codes: CUDA driver version is insufficient for CUDA runtime version. And i want to know what kind of CUDA does Alexnet need?
I could ony classify key board
when mouse was shone it was being classified as something else
I am getting the that error while starting the TransferLearningVideo.m. these errors ;
>> TransferLearningVideo
Error using trainNetwork (line 64)
The output size (5) of the last layer doesn't match the number of classes (1).
Error in TransferLearningVideo (line 17)
myNet = trainNetwork(trainingImages, layers, opts);
Thanks, Nice explanation!, please consider next time using less toolboxes that we need not to purchase.
Undefined function or variable 'alexnet'.
Error in DeepLearning_in_11_Lines (line 3)
nnet = alexnet;
I tried running this example, but it does not work. It is trying to use classify for statistics toolbox and not net classify - can you please help me solve this issue?
I have nnet installed as well.
Error ----
> In alexnet (line 46)
In MyFirstDeepLearningTest (line 4)
Error using classify (line 122)
Requires at least three arguments.
Error in MyFirstDeepLearningTest (line 10)
label = classify(nnet, picture); % Classify the picture
@Anthony, this submission requires the Neural Network Toolbox. You may not have that toolbox installed.
I tried to run this code and it returns an error saying that "classify requires 3 parameters". What is the 3rd parameter?