Wednesday, July 26, 2017

TensorFlow Object Detection API for Ubuntu

The default example for Tensorflow object deteciton uses a low accuracy model (59%).

https://techcrunch.com/2017/06/16/object-detection-api/

https://github.com/tensorflow/models/blob/master/object_detection/g3doc/installation.md

https://www.pythonanywhere.com/forums/topic/3678/

http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs

pip install ipykernel # install Jupyter
pip install matplotlib


https://www.tensorflow.org/install/install_linux


git clone https://github.com/tensorflow/models.git

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

export TENSORFLOW_MODELS_DIR=~/tensorflow_repo/models
export PYTHONPATH=$PYTHONPATH:$TENSORFLOW_MODELS_DIR:$TENSORFLOW_MODELS_DIR/slim

python object_detection/builders/model_builder_test.py

https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/




cd object_detection/

pip install jupyter


jupyter notebook


Select object_detection_tutorial.ipynb
Select the "Set Kernel" button




Position the mouse over the notebook entry to execute and press Shift-Enter for each section in the notebook.



Generate images from videos and read the images into the program, and write the images out:

# Four frames per second
ffmpeg -i rm_mc_2017. -r 4 output_%04d.png

# Modify the directory you read from (changes the image file extension if you are not using png)
# Change the code in the DETECTION section:

PATH_TO_TEST_IMAGES_DIR = ''
#TEST_IMAGE_PATHS = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, '{}.jpg'.format(i)) for i in range(1, 3) ]
import glob
TEST_IMAGE_PATHS = glob.glob(PATH_TO_TEST_IMAGES_DIR + "*png")

# Write the images out

if export_dir:
  export_path = os.path.join(export_dir, 'export-{}.png'.format(tag))
  vis_utils.save_image_array_as_png(image, export_path)




No comments:

Post a Comment