Create and fine-tune an object detection model beyond those on the papers. The goal of this project is to physically deploy such a model on a PC with a camera and scientific imaging system.
- Visual Studio Community 2019
- Anaconda (latest version, installation for Everyone (requires Administrator)); Open Anaconda PowerShell to create a dedicated virtual environment (Do NOT run as Administrator):
conda create -n your_env_name --clone = base
- Latest release of Protocol Buffers from https://github.com/protocolbuffers/protobuf/releases/tag/v3.17.3. Add the path to the binary exectuable protoc.exe to the user environmental variable PATH.
- opencv: This is required to import cv2 in Python. In virtual environment, do
conda install opencv-python
- cocoapi: In virtual environment, compile from source link[5] with
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
(The compilation depends on Visual Studio Community 2019; An error converning setup.py will occur if Visual Studio is not installed)
- Activate the virtual environment with
conda activate your_env_name
;Create a new directory your_directory. All the following instructions must be performed within the virtual environment. - Inside your_directory, clone TensorFlow pre-built models
git clone https://github.com/tensorflow/models.git
- Execute the following command in PowerShell to build .proto files
# From within your_directory/models/research/
Get-ChildItem object_detection/protos/*.proto | foreach {protoc "object_detection/protos/$($_.Name)" --python_out=.}
- Install TensorFlow pre-built models as python loadable modules
# From within your_directory/models/research/
cp object_detection/packages/tf2/setup.py .
python -m pip install --use-feature=2020-resolver .
All models can be obtained from Tensorflow model zoo (link [4]). Usage examples in the file colab_webcam.py, mobilenet_webcam.py, resnet50_webcam.py
- CenterNet HourGlass104 1024x1024 (197ms)
- CenterNet MobileNetV2 FPN 512x512 (6ms)
- CenterNet Resnet50 V2 512x512 (27ms)
- Instructions on fixing the errors with pycocotool package: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tensorflow-object-detection-api-installation
- Examples in the link above (using TF 2.X)
- https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/inference_tf2_colab.ipynb
- https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md
- https://github.com/philferriere/cocoapi.git