aykhara / tensorflow-sushi-detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sushi Detection model with Tensorflow

This is just an example for demo.
Last updated: 3/28/2019 with TensorFlow v1.12

Before you start....

Setting Up DLVM on Azure (Ubuntu)

Please following the Quickstarts.

Tensorflow Object Detection

Basically following the installation.

1. Clone the repo - Tensorflow models

https://github.com/tensorflow/models.git
Any SSH and telnet clients are fine!

2. Install Python, tensorflow-gpu, cuDNN, CUDA - specific version

Here is the version list.

$python --version
Should be "Python 3.5.5 :: Anaconda custom (64-bit)" pre-installed on DLVM.

You can also check nvidia driver version.
$cat /proc/driver/nvidia/version

$pip install tensorflow-gpu==1.12.0
$cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2
Will show like "#define CUDNN_MAJOR 7 define CUDNN_MINOR 2 define CUDNN_PATCHLEVEL 1" cuDNN version 7.0 should be pre-installed.
$>nvcc --version
Will show like "Cuda compilation tools, release 9.0, V9.0.176" CUDA version 9.0 should be pre-installed.
$nvidia-smi
Check GPU Card info.

3. Install libraries

$pip install --user Cython
$pip install --user contextlib2
$pip install --user pillow
$pip install --user lxml
$pip install --user jupyter
$pip install --user matplotlib

4. Install COCO API

From models/research
$git clone https://github.com/cocodataset/cocoapi.git
$cd cocoapi/PythonAPI
$make
$cp -r pycocotools <path_to_tensorflow>/models/research/

5. Protobuf Compilation

From tensorflow/models/research/
$wget -O protobuf.zip https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
$unzip protobuf.zip

6. Add Libraries to PYTHONPATH

From tensorflow/models/research/
$export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

7. Testing the Installation

From tensorflow/models/research/
$python object_detection/builders/model_builder_test.py

If showing "OK" that means you successfully completed the installation!

8. Access to Jupyter Notebook

$jupyter notebook --ip=0.0.0.0 --port=8888
Copy the URL like "http://:8888/?token=*********"

Then go to Azure portal and add inbound port rule "8888"

Go to browser and paste "http://(DNS name - copy from Azure Portal):8888/?token=***********"

Now ready to code with tensorflow!


A. Annotate your own dataset

Annotate dataset

VoTT 1.5

Export to Tensorflow Pascal VOC format

You will get the four below.
・Annotations folder
・ImageSets folder
・JPEGImages folder
・pascal_label_map.pbtxt file

B. Train and Test data preparation

Convert XML to CSV

$python xml_to_csv.py
You need to split the csv file into two: train.csv and test.csv before the next step.

Generate tf-record file (Train)

$python generate_tfrecord.py --csv_input=train_labels.csv --output_path=train.record --label_map_path=pascal_label_map.pbtxt

Generate tf-record file (Test)

$python generate_tfrecord.py --csv_input=test_labels.csv --output_path=test.record --label_map_path=pascal_label_map.pbtxt

C. Train and Evaluate model

Train model

$python train.py --logtostderr --pipeline_config_path=sushi_resnet_101.config --train_dir=checkpoints_sushi

Evaluate model

$python eval.py --logtostderr --pipeline_config_path=sushi_resnet_101.config --checkpoint_dir=checkpoints_sushi --eval_dir=checkpoint_sushi

Tensorboard

$tensorboard --logdir=checkpoints_sushi --port 6008

About


Languages

Language:Python 100.0%