buiquangmanhhp1999 / Tensorflow-API-Object-Detection

TensorflowV2 API Object Detection

Repository from Github https://github.combuiquangmanhhp1999/Tensorflow-API-Object-DetectionRepository from Github https://github.combuiquangmanhhp1999/Tensorflow-API-Object-Detection

Tensorflow-API-Object-Detection

Tensorflow API SSD MobileNet V2 Object Detection

1. Install Library

pip install -r requirement.txt
pip install -U cython
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

2. Split Dataset to train, test

# usage: partition_dataset.py [-h] [-i IMAGEDIR] [-o OUTPUTDIR] [-r RATIO] [-x]
python ./scripts/partion_dataset.py -i ./scripts/Dataset/ -x -r 0.1

3. Create Label Map

item {
  id: 1
  name: 'id'
}

4. Create TensorFlow Records

First, run command line

protoc object_detection/protos/*.proto --python_out=.

Then, run above command to create tf train record and test record

# usage: create_tf_record.py [-h] [-x XML_DIR] [-l LABELS_PATH] [-o OUTPUT_PATH] [-i IMAGE_DIR] [-c CSV_PATH]

# create train record
python ./scripts/create_tf_record.py -x ./scripts/TrainValDataset/train/ -l ./scripts/label_map.pbxt -o ./scripts/TrainValDataset/train.record

# create test record
python ./scripts/create_tf_record.py -x ./scripts/TrainValDataset/test/ -l ./scripts/label_map.pbtxt -o ./scripts/TrainValDataset/test.record

5. Train

Run above command to train model

python ./object_detection/model_main_tf2.py --model_dir=./ssd_mobilenet_v2/ --pipeline_config_path=./ssd_mobilenet_v2/pipeline.config 

6. Export the trained model

 python ./object_detection/exporter_main_v2.py --input_type image_tensor --pipeline_config_path ./ssd_mobilenet_v2/pipeline.config --trained_checkpoint_dir ./ssd_mobilenet_v2/ckpt/ --output_directory ./ssd_mobilenet_v2/exported_model/

About

TensorflowV2 API Object Detection


Languages

Language:Python 88.5%Language:Jupyter Notebook 11.3%Language:Dockerfile 0.1%Language:Shell 0.1%