A YOLOv3 implementation on TensorFlow core API
This is the thesis work of my bachelor degree at VAMK.
Topic: Deploying YOLOv3 on Movidius Raspberry Pi
- The model was written in TensorFlow Core API, data manipulation uses NumPy and OpenCV.
- High level programming interfaces
Yolow
offers quick and easy to load any (custom) Yolov3(-tiny) models. - Allows to load Darknet trained models and predict on YOLOv3 model. (I'd be nice if someone would like to help me build the training pipeline, otherwise just do training in Darknet and load the trained model to YOLOw using
WeightLoader
in load.py) - Easy to use
Imager
module to handle image pre-processing, post-processing and visualisation. - High-level Interface
YolowNCS
for running on Intel NCS (required installation of OpenVINO and converted models, please refer to OpenVINO workflow) - Integratable to your applications.
- Code was written as modular as possible.
- Training pipeline.
- Python >=3.6.8
- TensorFlow/TensorFlow-GPU >=1.12
- OPENVINO toolkit version >=2018.0.5.456
- NumPy
- OpenCV2
any of these libraries above can be easily installed with the following command: pip install package_name
except for TensorFlow-GPU as you have to also install Nvidia CUDA + cuDNN which is a very pessimistic hassle. Being committed to avoid this in every way, I use Anaconda for ease of package and working environment management, which I will use for this instruction.
If you have never try to install Tensorflow-GPU in the prior way, I would recommend trying it first to have a taste to be able to appreciate the simplicity of the latter. ;)
- download and install Anaconda from its Website. from this point I will be using my personal default of naming, you may change it however you like
- Open Anaconda Prompt (or add the path of Anaconda Executable to sytem variables to use within CMD) and create a vitural environment named
tf-gpu
:conda create --name tf-gpu
- activate it
conda activate tf-gpu
- Install TensorFlow-GPU (leave out the "-GPU" if you are installing Tensorflow non GPU version):
conda install -c anaconda tensorflow-gpu
- Install OpenCV2:
conda install -c conda-forge opencv
- To detect on images, put them to path
data/images
and run the following command in prompt/conda prompt:
python detect_images.py -c data/config/<name_of_config_file>.cfg
- To detect live on camera, run the following command in prompt/conda prompt:
python live.py -c data/config/<name_of_config_file>.cfg
- OpenVINO
- picamera (optionally if you intend to run on rapberry pi equipped with Pi Camera module)
*This instruction is in Windows but the procedures are the same for other OSes please follow up and refer to the installation instruction from Intel.
-
Install OpenVINO
-
if:
-
you have set anaconda to system variables
-
and used my naming for the virtual environment
-
install openvino to C:\ drive.
now run
generate_yolow_full_ir.bat
orgenerate_yolow_tiny_ir.bat
in a command prompt (you may want to check it out and change it to suit your needs). -
-
else:
-
Activate your virtual environment (skip if you dont use it)
-
run the file C:\Intel\computer_vision_sdk\bin\setupvars.bat to source open-vino SDK for Python (or just run
activate_openvino_running_env.bat
) -
run the following command to generate the intermediate representations (IR):
...\YOLOw> python ...\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo_tf.py --input_model .\frozen_yolow.pb --tensorflow_use_custom_operations_config .\yolow_ir_config.json --batch 1 --data_type FP16 --output_dir .\ir\
-
*Please also output the IR to the ir\ directory since the app will read from it by default.
- Start live demo on the NCS:
- Single NCS device
python live_ncs.py -c data/config/<name_of_config_file>.cfg
- NCS device)
python live_multi_ncs.py -c data/config/<name_of_config_file>.cfg -n 2
- Single NCS device