Deep Learning with Python
✍ Scribed by William Edison
- Publisher
- William Edison
- Year
- 2020
- Tongue
- English
- Leaves
- 148
- Category
- Library
No coin nor oath required. For personal study only.
✦ Synopsis
Learn to create inventive programs on your Machine Learning&Deep Learning and Python―with no programming experience required. Discover how to configure, write Python scripts, create user-friendly GUIs.Projects include a object detection by find object with camera, tracking motion. Hands-on Deep Learning&Machine Learning and Object, face/yes detection, recognize handwriting, pedstrian detecting.
- Computer vision and application fields
- Setup Python, OpenCV, Numpy Packages for Visual Studio IDE on windows
- Machine Learning and Object Detection with 1k-Means, 2k-NN, SVM and HOG, Cascade Classifier
- Make Classifier for Object Detection Casscade Classify Tool, Collecting Data, Training Object to Classify, Labeling, Training LBG, Detection Object
- Train Object Detection Classifier Using TensorFlow, Installing Anaconda, CUDA, and cuDNN, Setting Anaconda Virtual Environment, Gathering and labeling pictures, Generating training data, Creating a label map and configuring training, Training, Exporting the inference graph, Testing object detection classifier
✦ Table of Contents
1.Computer Vision
1.1 Computer Vision
1.2 Application Fields
2.Introduction and Setup
2.1Setup Visual Studio IDE On Windows
2.2Install Python Packages
2.3Install OpenCV Packages
2.4Install NumPy Packages
3.Machine Learning and Object Detection
3.1k-Means
3.2k-NN
3.3SVM and HOG
3.4Cascade Classifier
4.Make Classify for Object Detection
4.1Install Casscade Classify Tool
4.2Collecting Data
4.3Training Object to Classify
4.4Labeling
4.5Training LBG
4.6Detection Object
5.Train Object Detection Classifier Using TensorFlow
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
Field of Computer Vision
Image Processing
Process of getting better quality video using comp
Print new video after receiving video
Image Enhancement
Image Restoration
Image Compositing
Image Segmentation
Computer Vision(CV)
Get meaningful info. from video
Print data from received video
Object Detection
Object Recognition
Object Tracking
Computer Graphics(CG)
Generating video not exiting
Print new data from received data
Image Processing Case
Improve Image
Image Processing Case
Improve Image
Restore Image
Image Processing Case
Compose Images
Divide Image
Computer Vision Case
Detect Objects
Recognize Objects
Computer Vision Case
Trace Objects
Fields
Mobile
Camera filter, image messenger
Video, Broadcasting
Warping, Morphing, Face Swapping,
Chroma key, Caption
Medical
Ultra Sound, X-Ray, CT, MRI Analysis Diagnose
Sports
Posture analysis, Video Reading
Automobile
Around View, Autonomous Cars
Security, Safety, Traffics
Intruder alarm, trace suspect, protect, figure out
Industry
Process inspection, defect inspection, sense mall-
Robotics
Recognize objects and faces
Mobile
Snap Chat
Mobile
Snow Camera
Movie, Film
Warping
Morphing
Movie, Film
Face Swapping
Chroma key
Movie, Film
Chroma key
Subtitles
Medical diagnosis
Sports
Car
Around View
Autonomous Driving Cars
Security, Traffic
Security, Traffic
Industry
Process Management
Industry
Quality, Defect Inspection
Robotics
Install Visual Studio 2019 IDE
Visual Studio is an integrated development environ
Language Support
Language : Python, C++/C#...
Support Platform : Windows
Developer: Microsoft
Pre Required Visual Studio 2019
Setup Visual Studio 2019 On Windows
Down Load Visual Studio Community 2019
Install the Visual Studio installer
Setup Visual Studio 2019 On Windows
Choose workloads and components
select the Python development workload and choose
Choose individual components (Optional)
Install language packs (Optional)
Select the installation location (Optional)
Greate A New Python Project
Open Visual Studio and create a new project
Open Visual Studio and create a new project
Select the Python Application and create
Visual Studio show the project structure in the so
(1) The name of the project
(2) The solution is container for one or more rel
(3) The source files .py
(4) The Python Environments Python interpreters,
Setup Opencv-contrib-python
Pre-built OpenCV packages for Python
Select the packages for your enviroment
Select the packages for your enviroment
Run pip install opencv-contrib-python
Opencv-contrib-python Installation - PyPi
Check out Installed Version
import cv2
cv2.version
Test Code Show Picture
Installing Numpy
Pre-built Numpy packages for Python
Run pip install numpy
Numpy
http://www.nu
Fundamental package for scientific computing with
Strong N-th array object
Precise broadcasting function
C/C++, Fortran Combined tool
Useful linear algebra, Fourier transform, random n
OpenCV-Python ver 2.3+
Previously it used self internal data structure
Now it uses NumPy as image data structure
Change to cv2 package
import cv2
import numpy as np
NumPy and Image
ndarray
ndim: n dimension (axes)
shape: Size of each dimension, tuple
size : # of all item, Multiple of shape
dtype : data type of item
itemsize : Bite size of each item
data : Buffer having item, Not use in real
Numpy
Producing
Produce as value
array()
Generate as initial value
empty(), zeros(), ones(), full()
Generate as exiting array
empty_like(), zeros_like(), ones_like(), full_like
Generate as consecutive value
arange()
Generate as random number
random.rand(), random.randn()
Generate as value
numpy.array(list [, dtype]) : Generate NumPy array
list: Python list objects with value to be used in
dtype: Data type, if omitted, it is auto decided b
int8, int16, int32, int64 : Integer with sign
uint8, uint16, uint32, uint64 : Integer without si
float16, float32, float64, float128 : Real-number
complex64, complex128, complex256 : Complex number
bool : Boolian
Generate as value
Numpy
Generate as size and initial value
np.empty ( tuple [, dtype])
All factors not initialized, tuple size
np.empty( (2,3))
np.empty( (2,3), dtype=np.int16)
np.zeros( tuple [, dtype])
All factors are 0, tuple size
np.zeros( (3,4))
np.zeros( (2,3,4) , dtype=np.int16)
np.ones ( tuple [, dtype])
All factors are 1, tuple size
np.ones( (3,4) )
np.ones( (2,3,4) , dtype=np.int16)
np.full(shape, fill_value [, dtype])
Generate array initialized with fill_value
Generate as size
Numpy
Generate as exiting array
np.empty_like(array [, dtype] )
Generate non-initialized dtype and same shape arra
zeros_like(array [, dtype])
Generate 0(zero) initialized dtype and same shape
ones_like(array [, dtype])
Generate 1 initialized dtype and same shape array
ones_like(array, fill_value [, dtype])
Generate fill_value initialized dtype and same sha
Generate as exiting array
Generate as Sequence and Random Number
numpy.arange([start=0, ] stop [, step=1, dtype=flo
start : start value
stop : stop value, Number included in the scope ar
step : Increasing value
dtype : data type
numpy.random.rand([d0 [, d1 [..., dn]]]) :
d0, d1..dn : shape, if omitted, return a random nu
Random number b/w 0 and 1
numpy.random.randn([d0 [, d1 [..., dn]]]) :
Mean=0, Distribution=1, Random number following st
Numpy
Generate as Sequence and Random Number
Change Data Type
a.astype(‘typename’) , a.astype(np.dtype)
np.uintXX(), np.intXX(), np.floatXX(), np.complexX
Numpy
Change Dimension
np.reshape(array, newshape [, order])
arr.reshape(newshape [, order])
array : Array the objects to rearrange
newshape : Size of new array, tuple
-1 : The column size is not decided
order : {‘C’, ‘F’, ‘A’} C:C-like, F:Fotran-like,
np.ravel(array)
Change to 1 dimension
arr.T : Transposed array
Change Dimension
Numpy
Broadcasting Calculation
Scaler and Calculation
Array and calculation, two arrays should have same
Matrix
Matrix Addition : +
Matrix Multiply: np.dot(a, b), a.dot(b)
Transposed Matrix: a.T , a.transpose()
Numpy
Indexing/Slicing
1 Dimension
a[0] : Certain Parameter
a[1 : 5] : 1~4 Parameter
a[5: ] : 5 to end
a[:5] : Beginning to 4
a[ : ] : All parameter
2 Dimension
a[2, 3 ] : 2 column 3 row
a[2:4, 3] : 2~3 column 3 row
a[ 2, 1:4] : 2 column 1~3 row
a[2, :] :2 column and all row
a[:, 2] : All column and 2 row
a[1:3, : ] : 1~2 column and all row
Indexing/Slicing
Numpy
Fancy Indexing
Generate data fit to condition or initialize
Condition calculation: > , >=, <, <=, ==, !=
Bool type (True/False)
a[a > 4]
a[a > 4] = 0
Fency Indexing
Merge
numpy.hstack(arrays) : Merge arrays horizontally
numpy.vstack(arrays) : Merge arrays vertically
numpy.concatenate(arrays, axis=0) : Merge arrays a
numpy.stack( arrays, axis=0) : Merge arrays as new
arrays : Merge objects, tuple
Numpy
Merge
Numpy
splitting
np.hsplit(array, indice) = np.split(axis=1)
np.vsplit(array, indice) = np.split(axis=0)
np.split(array, indice, axis=0)
Numpy Search
numpy.where(condition [, t, f]) : Finding items fi
return : Tuple, array filled with index or changed
condition : Condition that will be used in search
t, f : Value or array set according to condition,
t : Value or array fit to condition
f : Value or array unfit to condition
numpy.nonzero(array) : Turnaround index that is no
numpy.all(array [, axis]) : Search true for all ar
array : Array of search subject
axis : Axis to search, if omitted, search all axis
numpy.any(array [, axis]) : Search for true in any
Numpy
Search
Numpy
Search
Numpy
Basic Statistics Function
numpy.sum(array [, axis]) : add array
numpy.mean(array [, axis]) : Average of array
numpy.amin(array [, axis]) : Min. value of array
numpy.min(array [, axis]) : Same as numpy.amin()
numpy.amax(array [, axis]) : Max value of array
numpy.max(array [, axis]) : Same as numpy.amax()
array : Arry of calculation objects
axis : Base axis to calculate, if it is not define
Numpy
Creating Gray Image
n x m
n : height, rows
m : width, columns
value : 0~255 (dtype=np.uint8)
Creating Color Image
n x m x 3
n : height, rows
m : width, columns
3 : color channels, Default = [Blue, Green, Red]
value : 0~255 (dtype=np.uint8)
Numpy Image
AI
In 1956 Dartmouth University in USA, Prof. John Mc
General AI: AI thinking like human
Narrow AI: AI only performing certain function i.e
Machine Learning
Analyze data with algorithms, learn the analyzed d
Various Algorithm
Deep Learning
One algorithm of machine learning
Artificial neural network: it is a network inspire
In 2012, Prof. Andrew NG of Google and Stanford re
Machine Learning
Through preconditioning process of data, transfer
Work analyzing characteristics of various algorith
Of the data set, 90% is for training set and 10% f
Supervised Learning
Learning with data with label (answer)
classification: name to label
Regression: numerical label
Linear regression: Score to study time (0~100)
H(x) = Wx + b, H: hypothesis, W: weight, b:bias
Binary classification: Pass/Fail to study time
Multi-labeled classification: GPA to study time (A
Unsupervised Learning
Learning without label
Clustering: Concern only in which data go to which
Realizing OpenCV
Legacy Routine: Realize even before the standardiz
core Module
k-Means, Mahalanobis
Standardized Interface
ml Module, Run StatModel Abstract Class Inheritanc
Normal Bayes(Normal/Pure size Bayes divider)
Decision trees
Boosting
Random tree
Expected Value - maximize
k-Nearest Neighbor
Mumltilayer Perceptron (MLP, Multilayer perceptron
Suport Vector Machine(SVM)
Objective Detector
Upper level class using learning method
CascadeClassifier, Latent SVM(DPMDetector), Bag of
K-Means Clustering
Clustered algorithm, non-guide learning
Cluster mixed data as wanted
Algorithm
Step1.
Set two center points(C1, C2) randomly.
Step2.
Calculate distance at the two center points.
If test data is close to C1, 0, close to C2, 1.
If center point is C3, C4, mark as 2,3.
Step3
Picture mark 0 data close to C1 as red, and 1 data
K-Means Clustering
Algorithm
Step4.
Average red and blue, set is as new center point a
Repeat step 2 to 4, until each center point is fix
Or, repeat it until it satisfies certain criteria;
Center point is dots with smallest value of distan
K-Means Clustering
cv2.kmeans(data, K, bestLabels, criteria, attempts
data : np.float32, should be saved at 1column
k : # of cluster wanted
bestLabels : Result data, None
criteria : termination criteria, tuple(type, max_i
attempts : # of run to be done through different i
flags : Selecting initial center points,
cv2.KMEASNS_PP_CENTERS
cv2.KMEASNS_RANDOM_CENTERS
cv2.KMEANS_USE_INITIAL_LABELS
Turnaround:
retval : Square of center points and each data dis
bestLabels : Labels, 0, 1, ...
centers : Array of cluster’s center point
Cluster of random number example
K-Means Clustering
Cluster of random number example
K-Means Clustering
사진속 영상 색상 군집화 Example
16 color clustering
k-NN(k-Nearest Neighbour)
If new point is entered into exiting points that i
Categorizing to the closest member
K is setting the scope of closest member
You can give different weight to close member and
knn = cv2.ml.KNearest_create()
knn.train(trainData, cv2.ml.ROW_SAMPLE, responses)
ret, results, neighbours ,dist = knn.findNearest(n
k-NN(k-Nearest Neighbour)
Simple Example
Simple Example
k-NN(k-Nearest Neighbour)
Move Categorizing Example
k-NN(k-Nearest Neighbour)
Move Categorizing Example
Recognize Handwriting
5000 letters of handwritten images
500 letters per number (0 ~ 9)
20 x 20=400 pixels by each letter
5000 X 400 Vector
4500 : train set
500 : test set
k-NN(k-Nearest Neighbour)
Recognize Handwriting Training
k-NN(k-Nearest Neighbour)
Recognize Handwriting Training
Recognize Handwriting <1/3>
k-NN(k-Nearest Neighbour)
Recognize Handwriting <2/3>
Recognize Handwriting
Support Vector Machine
One of the classifications
k-NN needs to calculate all data distance, it take
Distinguish parameters, find lines and recognizing
SVM,NuSVM, LinearSVM (Specialized in linear kernel
Lines that can be categorized into two is called D
Find line first in all SVM parameters because it
No need training data; if it is close to the count
Support Vectors: Blue circle filled and read quadr
Support Planes: Line that passes
Blue Circle: Wx + b > 1
Red Data: Wx + b < -1
W : weight, vector decides orientation
b: bias, Decide location
Decision Boundary :
Crossing center point of two hyperplane
Wx +b = 0
SVM
Example <1/2>
SVM
Example
HOG
Histogram of Oriented Gradient Feature Descriptor
Histogram for edge slope orientation
Suggested to recognize pedestrian
Normalized Histogram
hogDesc = cv2.HOGDescriptor(winSize,blockSize,bloc
windsize : Size of HOG extraction area
blockSize : Size of normalization area
blockStride : Size of normalization overlapping bl
cellSize : Size of HOG calculation
nbins : # of histogram level
hodDesc : HOG specialized narrator
Vector Size :
HOG SVM
MNIST Handwriting Study <1/3>
HOG SVM
MNIST Handwriting Study <2/3>
HOG SVM
MNIST Handwriting Study
Recognize Handwriting <1/3>
HOG SVM
Recognize Handwriting <2/3>
HOG SVM
Recognize Handwriting
Pedstrian Detecting
HOG training object to detect pedestrian
cv2.HOGDescriptor_getDefaultPeopleDetector()
cv2.HOGDescriptor_getDaimlerPeopleDetector()
cv2.HOGDescriptor.setSVMDetector()
cv2.HOGDescriptor.detectMultiScale
Detect Pedestrian
Pedstrian Detecting
Detect Pedestrian
Cascade
Tree base object divider
Effective in recognizing faces
Use Haar Feature while adding or subtracting certa
Offer trainer and detector
Detector: Recognize pre-trained object file
haarcascades.xml
Trainer: New image training
Cascade
classifier = cv2.CascadeClassifier('file.xml')
classifier.detectMultiScale(img, scaleFactor, minN
img : Input image
scaleFactor: Limit image enlarging size 1.3~1.5
Use for scale pyramid; if value is big, chances fo
minNeighbors: # of pixels to maintain
If the number is big, quality gets better, but #
flags : For old API; not used now
minSize, maxSize: Ignore detection if it goes over
Cascade
Face Detection Example
Face Detection Example
Cascade
Face Detection Example
Face Detection Example
Face Recognition
Recognizing your own face
Take your own photo in multiple angles
Train with the pictures take
mode = cv2.face.LBPHFaceRecognizer_create()
model.train(train_data, label_data)
Save the training result in xml
mode.write(‘file.xml’)
Read the saves xml to read faces
mode = cv2.face.LBPHFaceRecognizer_create()
Mode.read(‘file.xml’)
result : model.predict(face)
result : (label, confidence)
label : Label of most similar photo to the registe
confidence : distance (0 : 100%, ∞ : 0%)
Recognize Faces
Take Photo
Input name and ID (in number)
Take 100 photos
Including front angle, take the photos in variety
Various faces
Recognize Faces
Training
Recognize Faces
Result
Face Mosaic
Give auto mosaic effects to photos with human face
Result Example:
Hannibal Mask
Place Hannibal bask from the Silence of The Lambs
Result Example
Face Distortion
Make a camera that distorts human face like Snapch
Example:
Casscade Classify Tool
Official Support
Windows 7 or Above
Created by Amin Ahmadi
Cascade Trainer GUI is a program that can be used
Setup Cascade Trainer GUI
Download Cascade Trainer GUI 3.3.1
Next for setup - Cascade Trainer GUI
Setup Cascade Trainer GUI
Select Components and Next
Create Name
Setup Cascade Trainer GUI
Ready to Install
Installation Completed
Collecting Data
Take Photo
Take 100 photos Including positive images and nega
Including front angle, take the photos in variety
Various pinochle deck
Collecting Data
Take Video
Take video Including positive images and negative
Including front angle, take video in variety of an
Various pinochle deck
Training Casscade Classify
Create two folders inside it
“p” folder: Contain positive images samples the im
“n” folder: Contain negative images is the images
Image classify
Open casscade trainger tool
Training Casscade Classify
Image classify
Press tab Cropper
Select input settings from image in a folder or vi
Training Casscade Classify
Image classify
Press browse input folder path contain image
Press browse out put to folder path to “p” positiv
Training Casscade Classify
Image classify
Click left mouse to chose positive image and press
Continue press next to other positive image
Training Casscade Classify
Image classify
Press browse out put to folder path to “n” negativ
Click left mouse to chose negative image and press
Training Casscade Classify
Image classify
Crop 400 positive image in “p” positive folder
Crop 1000 nagative image in “n” negative folder
Training Casscade Classify
Training classifiers
Press to training tab
Browse folder you have created for the classifier
Training Casscade Classify
Training classifiers
Setting common
Pre-calculation buffer size is the speed of train
Setting Cascade
Training Casscade Classify
Setting common
Sample with make sure not to set it to a very big
Sample height
Setting feature type to HAAR or LBP
HAAR: Classifiers are very accurate but require a
LBP: Classifiers less accurate but train much qui
Setting boost
Training Casscade Classify
Training classifiers
Press start to training classifiers
Classifier folder
Stage#.xml: The files are temporary files that won
Params.xml: Reminder file contains the parameters
“neg.lst”, “pos.lst” and “pos_samples.vec” are tem
“cascade.xml” is the actual cascade classifier.
Training Casscade Classify
Test your classifiers
Press browse button
Browse to path to cascade XML file in the Cascade
Single Image: Image will be used as the scene in
Images in a Folder: A folder containing many imag
Video: A video file will be used for testing the
Setting output
Images Folder: Detected objects will be saved to
Video: A video with the detected objects with a
1.Install Casscade Classify Tool
2.Collecting Data
3.Training Casscade Classify
4.Labeling
5.Training LBG
6.Detection Object
Labeling
Create camera object detection automation
Base_dir: Path creat labeling file
Cascade classifier: Path of classifiercascade.xml
Target_cnt: Number of pinochle deck
Code auto pinochle deck detected example #1
Labeling
Code auto pinochle deck detected example #2
Labeling
Run python scrip code auto pinochle deck detected
Input ID and Name of pinochle deck
Input ID: #1
Name: Jacks
Labeling
Camera open and auto detected pinochle deck with I
File Jacks_1 had been auto great inside D:/ Labeli
400 Image Jacks with variety of angles
1.Install Casscade Classify Tool
2.Collecting Data
3.Training Casscade Classify
4.Labeling
5.Training LBG
6.Detection Object
Training LBG
Source code training LBG
Training LBG
Training LBG
Starting LBG model training
Training LBG
Model trained successfully
Auto created “.xml file” content in labeling file
1.Install Casscade Classify Tool
2.Collecting Data
3.Training Casscade Classify
4.Labeling
5.Training LBG
6.Object Recognize
Object Recognize
Source code for object recognize #1
Object Recognize
Source code for object recognize #2
Object Recognize
Run API
Result object recognize by camera
Train Object Detection Classifier Using TensorFlo
1.
2.
3.
4.
5.
6.
7.
8.
Installing Anaconda
Setup Anaconda on windows
Python 3.7
Download 64-Bit or 32-Bit graphical installer
Run the downloaded executable (.exe)
Click next to setup
Installing Anaconda
Setup Anaconda on windows
Read the licensing terms and click “I Agree”.
Select an install for “Just Me” unless you’re inst
Installing Anaconda
Setup Anaconda on windows
Select a destination folder to install Anaconda an
Adding Anaconda to the PATH environment variable
Installing Anaconda
Setup Anaconda on windows
Installing
Finish
Installing CUDA
Install Cuda Tool Kit
Download Version 8.0
Note: Currently version 9 is not supported by Tens
Setup CUDA Package
Installing CUDA
Install Cuda Tool Kit
Agree software license agreement
Visual studio integration
Installing CUDA
Install Cuda Tool Kit
Instaling
Set environment variables
Go to Start and Search "environment variables"
click the Environment Variables button
Click on the Path system variable and select edit
add the following paths
C:\Program Files\NVIDIA GPU Computing Toolkit\CU
C:\Program Files\NVIDIA GPU Computing Toolkit\CU
C:\Program Files\NVIDIA GPU Computing Toolkit\CU
Installing CUDNN 6.0
Download Cudnn 6.0 for cuda version 8.0 library
go to
Create a user profile if needed
Select CUDNN 6.0 for CUDA tool kit 8.
Extract the zip file contents and place them somew
Add a path to the bin folder. For example, mine is
C:\cuda\bi
Update your GPU Driver
go to
Select your GPU version to download
Install the driver
Train Object Detection Classifier Using TensorFlo
1.
2.
3.
4.
5.
6.
7.
8.
TensorFlow
https://www.tensorflow.org
TensorFlow is machine learning library
Official Support
Native : C/C++
Bindings: Python, Java
Support Platform : Windows, Linux, Mac, iOS, Andro
TensorFlow was developed by the
Free
Environment
Installing TensorFlow CPU
Create a new conda virtual environment
Open a new Anaconda/Command Prompt window
Create a new virtual environment called “tensorflo
Installing TensorFlow CPU
Create a new conda virtual environment
”y” for installed package
Activate the environment
Installing TensorFlow CPU
Create a new conda virtual environment
Install TensorFlow CPU for Python
Install TensorFlow V1.5 in this environment
Installing TensorFlow CPU
Create a new conda virtual environment
Test your installation
Installing TensorFlow GPU
TensorFlow GPU is slightly more involved than that
Need of installing the relevant Graphics and CUDE
Systems prerequisites
Install CUDA Tool Kit
Download Version 8 here:
Currently version 9 is not supported by Tensorflow
Set Your Environment Variables
Go to Start and Search "environment variables"
Click the Environment Variables button
Click on the Path system variable and select edit
Add the following path
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA
Download CUDNN 6.0
Go to
Create a user profile if needed
Select CUDNN 6.0 for CUDA tool kit 8.
Extract the zip file contents and place them somew
Add a path to the bin folder. For example, mine is
C:\cuda\bin
Installing TensorFlow GPU
Update your GPU Driver
Go to
Select your GPU version to download
Install the driver
Install Anaconda python 3.5
Go to
Choose python 3.5 (64bit) and install
Check the "add python to your PATH" option during
Create a new Conda virtual environment
Open a new Anaconda/Command Prompt window
Type the following command:
The above will create a new virtual environment wi
Activate the newly created virtual environment by
Installing TensorFlow GPU
Install TensorFlow GPU for Python
Open a new Anaconda/Command Prompt window and acti
Once open, type the following on the command line:
Wait for the installation to finish
Installing TensorFlow GPU
Test your Installation
Open a new Anaconda/Command Prompt window and acti
Start a new Python interpreter session by running:
Once the interpreter opens up, type:
If the above code shows an error, then check to ma
Then run the following:
The ouput should be
TensorFlow Models Installation
Install Prerequisites:
Downloading the TensorFlow Models-Master
Create a new folder under a path of your choice an
To download the models you can simply download(
You should now have a single folder named models u
Downloading Object Detection API Model tutorial's
Links download: (
TensorFlow Models Installation
Downloading Object Detection API Model tutorial's
Extract all the contents directly into the C:\tens
\object_detection folder should look like:
COCO API installation
Pre-trained classifiers with specific neural netwo
Download the Faster-RCNN-Inception-V2-COCO
Link download:
Extract the faster_rcnn_inception_v2_coco_2018_01_
Adding necessary Environment Variable
Created that points to the \models, \models\resear
Every time the "tensorflow1" virtual environment i
Run commands
Checking python path environment variable
Protobuf Installation/Compilation
The Tensorflow Object Detection API uses Protobufs
This should be done as follows:
Download the latest -win32.zip release (e.g.
Create a folder in C:\Program Files and name it Go
Extract the contents of the downloaded -win32.zip
Add C:\Program Files\Google Protobuf\bin to your P
In a new Anaconda/Command Prompt, cd into TensorFl
Change directories to the \models\research directo
Run the compilation process:
This creates a name_pb2.py file from every name.pr
Protobuf Installation/Compilation
Install the object_detection Python package
Running the following from C:\tensorflow1\models\r
Test your Installation
Open a new Anaconda/Command Prompt window and acti
Cd into C:\tensorflow1\models\research\object_det
This should start a new jupyter notebook server on
Press button Cell and chose Run All
Test your Installation
Test TensorFlow setup to verify it works show the
If not work see the
Appendix: Common Errors
Object_detection/protos/.proto: No such file or di
Run cmd
Change your directory to the research folder you d
Downloaded:
Get the location of the protroc.exe file that you
Get protoc.exe 3.4 and run compilation
Appendix: Common Errors
Numpy Version
TensorFlow V1.5 work on numpy version V1.14.5
Update numpy version to V1.14.5
Train Object Detection Classifier Using TensorFl
1.
2.
3.
4.
5.
6.
7.
8.
Gathering and labeling pictures
Gather Pictures
Gathering and labeling pictures
Gather Pictures
LabelImg Installation
For Windows and Linux you can download the precomp
Links download:
Run labelImg.exe
LabelImg Installation
Point it to your \images\train directory, and then
LabelImg saves a .xml file containing the label da
Generate Training Data
The image .xml data will be used to create .csv fi
This creates a train_labels.csv and test_labels.cs
Label Map: generate_tfrecord.py
Label for training a classifier
Generate the TFRecord files by issuing these comma
Greate Label Map
Label Map: The label map tells the trainer what e
Configure Training
Configure training: Finally, the object detection
Navigate to C:\tensorflow1\models\research\object_
Make the following changes to the faster_rcnn_ince
Line 9. Change num_classes to the number of differ
Line 106. Change fine_tune_checkpoint to:fine_tune
Lines 123 and 125. In the train_input_reader secti
input_path : "C:/tensorflow1/models/research/objec
label_map_path: "C:/tensorflow1/models/research/ob
Line 130. Change num_examples to the number of ima
Lines 135 and 137. In the eval_input_reader sectio
input_path : "C:/tensorflow1/models/research/objec
label_map_path: "C:/tensorflow1/models/research/ob
Save the file after the changes have been made. Th
Run the Training
From the \object_detection directory
Command to begin training:
TensorFlow will initialize the training. The initi
Each step of training reports the loss. It will st
Note: The loss numbers will be different if a diff
Run the Training
You can view the progress of the training job by u
This will create a webpage on your local machine a
Eport Inference Graph
Now that training is complete, the last step is to
This creates a frozen_inference_graph.pb file in t
Use Your New Trained Object Detection Classifier
The object detection classifier is all ready to go
Before running the Python scripts, you need to mod
To test your object detector, move a picture of th
To run any of the scripts, type “idle” in the Anac
If everything is working properly, the object dete
📜 SIMILAR VOLUMES
Unlock the groundbreaking advances of deep learning with this extensively revised new edition of the bestselling original. Learn directly from the creator of Keras and master practical Python deep learning techniques that are easy to apply in the real world. In Deep Learning with Python, Second E
Unlock the groundbreaking advances of deep learning with this extensively revised new edition of the bestselling original. Learn directly from the creator of Keras and master practical Python deep learning techniques that are easy to apply in the real world. In Deep Learning with Python, Second E
Deep Learning with Python introduces the field of deep learning using the Python language and the powerful Keras library. Written by Keras creator and Google AI researcher François Chollet, this book builds your understanding through intuitive explanations and practical examples.
<div><p><b>Summary</b></p> <p><i>Deep Learning with Python</i> introduces the field of deep learning using the Python language and the powerful Keras library. Written by Keras creator and Google AI researcher François Chollet, this book builds your understanding through intuitive explanations and pr