ammarsyatbi / Object-Detection-Tensorflow-API

Have you ever look at a tree and wonder , how many leaves does it have ? Well, wonder no more...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object-Detection-Tensorflow-API

Have you ever look at a tree and wonder , how many leaves does it have ? Well, wonder no more...

I only cover the training and testing part, from what I found, tensorflow object detection API documention is not very friendly with windows user, hopefully this can help you guys.

For tensor flow installation please refer here or sentdex tutorial

You can refer Tensorflow Object Detection API here

As you can see I only uploaded the object_detection folder, so you can replace yours with mine if you clone the whole model.

Steps simplified

  1. Dataset preparation (label images using labelImg)
  2. Convert xml to csv
  3. Generate tf record
  4. Download pre-trained model and put it in object_detection folder ( make sure the path is correct) / you can just extract model.ckpt
  5. Configure model parameter (config file)

Cmd for windows user

Run in Daun folder:

XML to CSV python xml_to_csv.py

Testing (after training has finished): Replace the '11293' with the last summary step saved.

python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_mobilenet_v1_coco_11_06_2017.config --trained_checkpoint_prefix training/"model.ckpt-11293"  --output_directory daun_graph

Generate TF RECORD/*

python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record
python generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record

Run in object_detection folder: Training It would be easier if you just set environment variables SET PYTHONPATH=%PYTHONPATH%:'YOUR_PATH_TO_MODEL/models/research/slim/nets':'YOUR_PATH_TO_MODEL/models/research'/slim

python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_coco_11_06_2017.config

python -m tensorboard.main --logdir=training/

I've already tweak the code object_detection_tutorial.ipynb to match model graph and count detected daun. If you add more image to test, please change the image name and array accordingly.

Things to improve:

  1. Dataset, I only had 60 images which I capture myself with Huawei Nova 2i camera and reduce the size with faststone (to overcome OOM).
  2. Model, haven't 'play' with parameters and other models provided.
  3. Training time, only train for 4 hours.
  4. I trained with resized images and test with original images which is 5 times bigger, still wondering how the accuracy would goes if I tested images with the same size or train with high resolution image and test with both size.

Results

About

Have you ever look at a tree and wonder , how many leaves does it have ? Well, wonder no more...


Languages

Language:Jupyter Notebook 75.8%Language:Python 24.2%Language:Shell 0.0%