This project demonstrates transfer learning using Tensorflow. The underlying concepts provide a solid foundation for training machine learning models.
-
Create a virtual environment with Python 3.7.3, no default packages, and activate it.
conda create --name myenv --no-default-packages python=3.7 conda activate myenv
-
Install the required packages.
# from the repository's root directory: pip install -r requirements.txt
-
Install
ipykernel
:python -m ipykernel install --user --name=myenv
-
Collect target images in
./data/raw/
. -
Label images using
labelImg
.a. From terminal run:
labelImg
b. Using
labelImg
, navigate to./data/raw/
and label images.
-
Setup:
python cli.py --setup --image-format < > --pretrained-model-url < > --pretrained-model-name < >
E.g.
python cli.py --setup --image-format jpg --pretrained-model-url http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.tar.gz --pretrained-model-name ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8
-
Train:
python cli.py --train --batch-size < > --epochs < > --train-test-split < > --pretrained-model-ckpt < >
E.g.
python cli.py --train --batch-size 4 --epochs 1000 --train-test-split 0.7 --pretrained-model-ckpt 0
-
Smoke test:
python cli.py --validate --trained-model-ckpt < >
E.g.
python cli.py --validate --trained-model-ckpt 1
From the repository's root directory, start a Jupyter Notebook session and select the kernel initialized during setup.
-
Step through
./notebooks/setup.ipynb
to set up the project. -
Step through
./notebooks/train.ipynb
to train an object detection model. -
Step through
./notebooks/validate.ipynb
to smoke test the trained image-object detection model.