Introduction and Use - Tensorflow Object Detection API Tutorial

Hello and welcome to a miniseries and introduction to the TensorFlow Object Detection API. This API can be used to detect, with bounding boxes, objects in images and/or video using either some of the pre-trained models made available or through models you can train on your own (which the API also makes easier).

To begin, you're going to want to make sure you have TensorFlow and all of the dependencies. For CPU TensorFlow, you can just do pip install tensorflow, but, of course, the GPU version of TensorFlow is much faster at processing so it is ideal. If you need to install GPU TensorFlow:

Installing GPU TensorFlow links:

If you do not have a powerful enough GPU to run the GPU version of TensorFlow, one option is to use PaperSpace. Using that link should give you $10 in credit to get started, giving you ~10-20 hours of use.

Beyond this, the other Python dependencies are covered with:

pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib

Next, we need to clone the github. We can do this with git, or you can just download the repository to .zip:

git clone https://github.com/tensorflow/models.git OR click the green "clone or download" button on the https://github.com/tensorflow/models page, download the .zip, and extract it.

Once you have the models directory (or models-master if you downloaded and extracted the .zip), navigate to that directory in your terminal/cmd.exe. The next steps are slightly different on Ubuntu vs Windows.

On Ubuntu:

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

And...

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

If you get an error on the protoc command on Ubuntu, check the version you are running with protoc --version, if it's not the latest version, you might want to update. As of my writing of this, we're using 3.4.0. In order to update or get protoc, head to the protoc releases page. Download the python version, extract, navigate into the directory and then do:

sudo ./configure
sudo make check
sudo make install

After that, try the protoc command again (again, make sure you are issuing this from the models dir).

On Windows:

// 此处一定要使用 该版本 protoc-3.4.0

Head to the protoc releases page and download the protoc-3.4.0-win32.zip, extract it, and you will find protoc.exe in the bin directory.

You can move this to something more appropriate if you like, or leave it here. I eventually put mine in program files, making a "protoc" directory and dropping it in there.

Now, from within the models (or models-master) directory, you can use the protoccommand like so:

"C:/Program Files/protoc/bin/protoc" object_detection/protos/*.proto --python_out=.

Next, open terminal/cmd.exe from the models/object_detection directory and open the Jupyter Notebook with jupyter notebook. From here, choose the object_detection_tutorial.ipynb. From here, you should be able to cell in the main menu, and choose run all

You should get the following results:

Object Detection machine learning tutorialsObject Detection machine learning tutorials

In the next tutorial, we'll cover how we can label data live from a webcam stream by modifying this sample code slightly.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值