Skip to content

Tensorflow object detection data collection and model generation, for TF2 and export to TFLite.

Notifications You must be signed in to change notification settings

CameronTrumpy/TFODVanilla

Repository files navigation

TensorFlow Object Detection Walkthrough

This set of Notebooks contains code to train and use your own custom object detection model using the TensorFlow Object Detection API. It includes modified files from a course by Nicholas Renotte, plus my additional instructions and tips on how to set up a good work environment for TF. It also includes custom scripts and instructions that were not included in course material.

Setup

Step 0.1 - Environment I set up my project on an SSD with Ubuntu 20.04(LTS), and booted my pc from that SSD when I wanted to work on the project. I suggest a similar approach if you want to leverage the flexibility of Linux, along with the computing power of your CPU+GPU. It may be possible to set up the project in a Linux VM, but I haven't tried.

If you don't know how to dual boot OSes on your machine, you can research it online, or you can attempt at working in Windows. I strongly recommend against this as Windows is weird with package management and PATH variables.

Step 0.2 - Setup CUDA If you are planning to train your model with your GPU, which is much faster than CPU training, you need to set up CUDA on your machine.

As of writing, this GPU support article is a good install guide for CUDA. Take note that the guide(as of writing) is written for Ubuntu 18.04. for me it worked by just changing all of the 18.04s to 20.04s in all of the installation commands.

TF Steps


Step 1. Clone this repository. You may want to do this in a dedicated GIT repos directory(optional).

Optional repo directory setup

cd ~
mkdir GITRepos
cd GITRepos

Clone Repo

git clone https://github.com/CameronTrumpy/TFODVanilla
cd  TFODVanilla



Step 2. Create a new virtual environment.

python3 -m venv tfod

Step 3. Activate your virtual environment. Anytime you are working with this project your environment should be activated.

source tfod/bin/activate

Step 4. Install dependencies and add virtual environment to the Python Kernel, along with jupyter for jupyter notebooks.

python -m pip install --upgrade pip

pip install ipykernel

pip install jupyter

python -m ipykernel install --user --name=tfod

Step 5.0. Open The first notebook. 1. Image Collection.ipynb- ensure you start jupyter, and change the kernel to the virtual environment as shown below.

jupyter notebook


Step 5.1 Refer to the instructions file for how to successfully complete the first notebook. Notebook Guide



Step 6. Begin training process by opening 2. Training and Detection.ipynb, this notebook will walk you through installing Tensorlow Object Detection, making detections, saving and exporting your model. Refer to the Notebook Guide to successfully complete the notebook if issues arise.



Step 7. During this process the Notebook will install TensorFlow Object Detection. You should ideally receive a notification indicating that the API has installed successfully at Step 8 with the last line stating OK.

If not, resolve installation errors by referring to the Error Guide.md in this folder.



Step 8. Once you get to step 6. Train the model, inside of the notebook, you may choose to train the model from within the notebook. I have noticed however that training inside of a separate terminal on a Windows machine you're able to display live loss metrics.


Step 9. You can optionally evaluate your model inside of TensorBoard. Once the model has been trained and you have run the evaluation command under Step 7. Navigate to the evaluation folder for your trained model e.g.

 cd Tensorflow/workspace/models/my_ssd_mobnet/eval

and open Tensorboard with the following command

tensorboard --logdir=. 

TensorBoard will be accessible through your browser and you will be able to see metrics including mAP - mean Average Precision, and Recall.


About

Tensorflow object detection data collection and model generation, for TF2 and export to TFLite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published