File Exchange

image thumbnail

Deep Learning in 11 Lines of MATLAB Code

version 1.0.0.0 (469 Bytes) by MathWorks Deep Learning Toolbox Team
Use MATLAB®, a simple webcam, and a deep neural network to identify objects in your surroundings.

111 Downloads

Updated 24 Feb 2017

View License

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

Cite As

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 .

Comments and Ratings (39)

Akshay Gore

Contact for code and support mycodeworklab@gmail.com
Whatsapp +91 9464894829

1. RGB-Image-encryption-based-on-chaotic-system-and-DNA-algorithm

2. Image-encryption-based-on-chaotic-system

3. Image encryption by generating Halton sequences

4. Chaos-based-Image-Encryption

5. Text-Encryption Matlab code for AES,DES,Hybrid AES-DES and AES w/ chaos

6. Image encryption and decryption using chaotic key sequence generated by sequence of logistic map and sequence of states of Linear Feedback Shift Register

7. A New Approach of Image Encryption Using 3D Chaotic Map to Enhance Security of Multimedia Component

8. MATLAB was used for the implementation of Chaotic Digital Image Encryption.

9. Multiple-Color-Image-Encryption

10. Cryptanalyzing an Image Scrambling Encryption Algorithm of Pixel Bits.

11. Novel Image Compression encryption hybrid algorithm based on a key-controlled measurement matrix in compressive sensing.

12. An Image Encryption Scheme Based on a Hybrid Model of DNA Computing, Chaotic Systems and Hash Functions.

13. Colour image encryption algorithm combining Arnold map, DNA sequence operation, and a Mandelbrot set.

14. Advanced Encryption Standard

15. Reversible-Data-Hiding-by-Reserving-Room-Before-Encryption-MATLAB.

16. Image Encryption and Decryption Using Logistic Map Equation and Linear Feedback Shift.

17. A simple Matlab implementation of the algorithm presented in the paper: "Reversible-data-hiding-in-Encrypted-image"

17. Image encryption and encoding methods

19. DES 64bit Encryption and Decryption

20. Matlab project on blind digital watermarking and encryption.

21. Encrypting an image using Salient Object Detection and K-Means Clustering.

22. Recurrent Scale Approximation for Object Detection in CNN.

23. Object detection via a multi-region & semantic segmentation-aware CNN model.

24. R-FCN: Object Detection via Region-based Fully Convolutional Networks

25. Adversarial Examples for Semantic Segmentation and Object Detection.

26. Object Detection in Videos toolkit for VisDrone2019

27. Computational biology and medical image processing scripts and programs.
28. A MATLAB library/toolbox providing access to image registration suitable for use with medical images.
29. Lung medical image analysis and visualisation software for Matlab.
30. Medical ultrasound image processing.Carotid ultrasoung segmentation using RF data.
31. A Phase Congruency and Local Laplacian Energy Based Multi-Modality Medical Image Fusion Method in NSCT Domain.
32. Automatic tool for landmark localisation in 3D medical images.
33. Advanced-Medical-Image-Processing.
34. Recognizing and Refining the location of Individual Vessels in Segmented Retinal Images.
35. Image segmentation method on medical image is provided and tested.
36. 3D non-rigid image registration for medical and synthetic images using truncated hierarchical B-splines (THB-Splines).
37. Laplacian Re-Decomposition for Multimodal Medical Image Fusion[J]. IEEE Transactions on Instrumentation and Measurement, 2020.
38. Medical software for Processing multi-Parametric images Pipelines.
39. Prostate cancer segmentation based on MRI and PET images.
40. Image segmentation methods for biomedical purposes such as cell segmentation, blood vessel segmentation (eye blood vessels), and segmentation of brain tumors.
41. Medical Image Analysis Breast Cancer Lesion Detection.
42. Medical image enhancement based on nonlinear technique and logarithmic transform coefficient histogram matching.
43. Machine Learning: A Bayesian and Optimization Perspective.
44.

Paul RODRIGUEZ

abdulhaleem

Saras Nagle

Anders Nilsson

which camera do you use?

Paul Safier

Jose Eraso

please I need the images, to be able to develop the example. thank you very much, my email is kmilo0717@hotmail.com

Jesus Ortega

fast, nice and easy

Natalia Poll

I solved this problem! It works

Natalia Poll

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?

Han Wei

kongshengjiang kong

Niki rami

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

masoud naseri

Bowen Fang

Muhammad Atif

abdelilah mbarek

Hairmon Di

xinxin hao

Fakhar Alam

Houchao

jun liu

work very well.

wajih david

I am getting the that error while starting the TransferLearningVideo.m.

Hilmar Strickfaden

Yv Yu

Dimuthu Dissanayake

Enrique Baldo

Muzee

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?

renjith ms

I could ony classify key board
when mouse was shone it was being classified as something else

tanu gupta

cem sincap

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);

my

kalim puthawala

Thanks, Nice explanation!, please consider next time using less toolboxes that we need not to purchase.

Danh Lam

Undefined function or variable 'alexnet'.

Error in DeepLearning_in_11_Lines (line 3)
nnet = alexnet;

Tommy

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

Hans Scharler

jiro

@Anthony, this submission requires the Neural Network Toolbox. You may not have that toolbox installed.

Anthony Slata

I tried to run this code and it returns an error saying that "classify requires 3 parameters". What is the 3rd parameter?

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

WebcamObjectClassification/