Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
49 views

Object Detection

Uploaded by

Mouad Bentahr
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Object Detection

Uploaded by

Mouad Bentahr
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Tensorflow Custom Object Detection Course

Step 1 : Tensorflow Installation


Learner have to go with any one of the following Tensorflow CPU or GPU installation.
CPU means: You only have processor in your system. Eg. Intel processor.
GPU means: You only have NVIDIA graphic card along with system’s processor.
(To check you have NVIDIA GPU or not, Right click on your desktop and check if you have
NVIDIA control panel as below)

If you don’t have above option “NVIDIA Control Panel” upon right clicking on desktop,
you only have to follow (a) Tensorflow CPU Installation whereas if you have above
option, go with (b) Tensorflow GPU installation
Note: click on download button wherever its mention for respective installation.

www.extrinsictechnology.com
a. Tensorflow CPU installation

Download Anaconda

conda create -n tfcpu


conda activate tf
conda install python=3.7.0
pip install Cython contextlib2 pillow lxml jupyter matplotlib pandas
opencv-python numpy==1.16.1 flask werkzeug==0.16.0
pip install tensorflow==1.13.1

Check tensorflow is installed properly or not.


Python (3.7.0) (no error should populate after installation)
>>import tensorflow as tf
>>
---------------------------------------------OR-------------------------------------------------

b. Tensorflow GPU Installation

1. Download visual studio 2017 from below link and install only with .NET
installation which will help us to install compatible C++ library.

VS1027 Pro Download


Note: Our course won’t have any connection related to Visual studio. We
are just installing it for MS C++ libraries.
2. Download CUDA toolkit 10 or 9
What is CUDA toolkit?
CUDA® is a parallel computing platform and programming model developed by NVIDIA
for general computing on graphical processing units (GPUs). With CUDA, developers are
able to dramatically speed up computing applications by harnessing the power of GPUs.

www.extrinsictechnology.com
Check CUDA enabled GPUs
https://en.wikipedia.org/wiki/CUDA
Install any one from below depending on your graphic card
a. CUDA 9 with CUDNN 7.3.1

CUDA 9 CUDNN 7.3.1

Install CUDA 9 and copy CUDNN files in NVIDIA GPU computing folder
BIN
Include
X64
----------------------------------------OR------------------------------------------------------
b. CUDA 10 with CUDNN

CUDA 10 CUDNN 7.4.2


Install CUDA 10 and copy CUDNN files in NVIDIA GPU computing folder
BIN, Include, X64
3. Install Miniconda/ANACONDA

Download Anaconda

conda create -n tfgpu


conda activate tfgpu
conda install python=3.7.0
pip install Cython contextlib2 pillow lxml jupyter matplotlib pandas
opencv-python numpy==1.16.1 flask werkzeug==0.16.0
pip install tensorflow-gpu==1.13.1
(Restart the system)

www.extrinsictechnology.com
Check tensorflow is installed properly or not.
Python (3.7.0) (no error should populate after installation)
>>import tensorflow as tf
All in One Download Link
>>
here
Step 2: Tensorflow Framework Installation

Download Tensorflow
Framework
Download Protos

a. Create tensorflow folder at local disk directory


b. Copy and paste folder “models” and “protos” which is downloaded from
above buttons

c. Activate your conda env


Conda activate tfgpu
Navigate to the CD C:/tensorflow/Models/Research>>
(Type below commands one by one and hit ENTER)
"C:\tensorflow\protoc\bin\protoc.exe" object_detection/protos/*.proto --python_out=.
python setup.py install

Set PYTHONPATH=C:\tensorflow\models\research\slim;C:\tensorflow\models\research

www.extrinsictechnology.com
Step 3: Dataset Preparation and Annotation
1. Prepare dataset – before feeding into machine learning model
2. Dataset : combination of different form of same data
Download some free image dataset you can try for learning purpose.

Rice Disease Dataset Fruits Classification

Malaria Dataset Flower Dataset

Yoga Pose Dataset Simpsons Cartoon DS

I am using animal classification


https://www.kaggle.com/ashishsaxena2209/animal-image-datasetdog-cat-and-panda
------------------------------------------------------------------------------------------------------------------------
Image annotation toolkit installation

Download LABEL_IMG

Use below commands to install labelling/annotation tool


pip install PyQt5
pyrcc5 -o libs/resources.py resources.qrc
python labelImg.py

1. Install Image labelling tool


2. Prepare the image dataset
3. Decide classifier and perform annotation

My labelled dataset Dog and Panda

Labelled dataset
DOG and PANDA

www.extrinsictechnology.com
Step 4: Convert labelled dataset into TF-record
(File generated before model training)

1. Download sublime text Download

2. Download python programs for conversions Download

 Now its turn to distribute your labelled dataset into two folder
Folder “train” should consist of 90% of entire dataset
Folder “test” should consist of 10% of entire dataset

Use commands
set PYTHONPATH=C:\tensorflow\models\research\slim;C:\tensorflow\models\research
1. XML to CSV
Python xml_to_csv.py
Use above command twice by changing folder name will result in below two files.
>> test.csv
>>train.csv
Paste above csv files in respective folder

2. CSV to TF-RECORD
 Move test and train folder to the tensorflow/models/research/object_detection
 Also move generate_ftrecord.py file to the same folder
 Mention your classifier name (line 39,41)
 “dog” “panda”
 Navigate tensorflow/models/research/object_detection
 Generate test.record and train.record

www.extrinsictechnology.com
set PYTHONPATH=C:\tensorflow\models\research\slim;C:\tensorflow\models\research
Test.record
python generate_tfrecord.py --csv_input=C:/tensorflow/models/research/object_detection/test/test_labels.csv --
output_path=C:/tensorflow/models/research/object_detection/test/test.record

Train.record
python generate_tfrecord.py --csv_input=C:/tensorflow/models/research/object_detection/train/train_labels.csv --
output_path=C:/tensorflow/models/research/object_detection/train/train.record

www.extrinsictechnology.com
Step 5: Train the model

1. Download SSD model file Download

2. Download Labelmap.pbtxt
Download

3. Download SSD Config File Download

Navigate to the ./object_detection/legacy folder


 Create “data” folder ------- paste train.record and test.record in it
 Create training folder
 Edit labelmap.pbtxt with your classifier name (eg. Dog,cat etc) and copy-paste
labelmap.pbtxt to “data” and “training” folder
 Paste ssd config file in training folder
 EDIT SSD config file with batch size, training step, etc
 Copy downloaded SSD model file (120MB) and paste into legacy

www.extrinsictechnology.com
set PYTHONPATH=C:\tensorflow\models\research\slim;C:\tensorflow\models\research
Run below commands to start training (I will suggest to copy first in notepad and then paste to
anaconda prompt)
python train.py --logtostderr --train_dir=training/ --
pipeline_config_path=training/ssd_mobilenet_v1_coco.config

Step 6: GENERATE MODEL GRAPH AND DEPLOYMENT


Copy export_inference_graph.py from object detection folder and paste into legacy dir.

Use below command by editing “model name” and “your_number”

python export_inference_graph.py --input_type image_tensor --pipeline_config_path


training/ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix training/model.ckpt-your_number --
output_directory model_name

Check how model is trained with the help of tensorboard (run below command in legacy folder)

tensorboard --logdir ./ --host=127.0.0.1

if tensorboard error occurred.


pip install tb-nightly

Deployment
Webserver Code Download

Commands
Set flask_env=development
Flask run

Webcam Code Download

Video Feed Code Download


Android Code Download

Entire project – All required files download link

All in One Download Link


here

www.extrinsictechnology.com
Thank you ML enthusiastic for learning this course.
Good Luck for your future!

For more help you can reach out


Instagram: https://www.instagram.com/tf.aakash
Email: aakash.tensorflow@gmail.com
Linkedin: https://www.linkedin.com/in/aakashjadhav16197/
YouTube : https://www.youtube.com/c/extrinsictechnology
Whatsapp:
https://chat.whatsapp.com/BUlWF9NLgMY3JsSAMr1ZMt
Website: www.extrinsictechnology.com
Facebook: https://m.facebook.com/extrinsicTech

www.extrinsictechnology.com

You might also like