Skip to content

Implementatoin of object detection using Tensorflow 2.1.0 | this can be use in a car for object detection

License

Notifications You must be signed in to change notification settings

bm777/object_detection

Repository files navigation

Average Time Elapsed for process on each frame: 71.6ms

YoloV3 Implementation in Tensorflow 2.x

See on YouTube: 4K YoloV3 Object detection using Tensorflow 2.1

This repo provide a clean implementation of YoloV3 in Tensorflow 2.x using all the best practices.

Instance Detection Sample

Key Features

  • TensorFlow 2.1
  • yolov3 with pre-trained Weights
  • yolov3-tiny with pre-trained Weights
  • Inference example
  • Transfer learning example
  • Eager mode training with tf.GradientTape
  • Graph mode training with model.fit
  • Functional model with tf.keras.layers
  • Input pipeline using tf.data
  • Tensorflow Serving
  • Vectorized transformations
  • GPU accelerated
  • Fully integrated with absl-py from abseil.io
  • Clean implementation
  • Following the best practices
  • MIT License

Usage

Installation

Pip

# without GPU
pip install -r requirements.txt
#with GPU
pip install -r requirements-gpu.txt

Nvidia Driver (For GPU)

# Ubuntu 18.04
sudo apt-add-repository -r ppa:graphics-drivers/ppa
sudo apt install nvidia-driver-440
# Windows/Other
https://www.nvidia.com/Download/index.aspx

Convert pre-trainned Darknet weights

# yolov3
wget https://pjreddie.com/media/files/yolov3.weights -O data/yolov3.weights
python convert.py --weights ./data/yolov3.weights --output ./checkpoints/yolov3.tf

Detection

# WebCam
python object_detected.py --video 0

# Video file
python object_detected.py --video path_to_file.mp4

# Vidoe file with output
python object_detected.py --video path_to_file.mp4 --output ./output.avi

Training

soon

Implementation Details

Loading pre-trained Darknet weights

very hard with pure functional API because the layer ordering is different in tf.keras and darknet. The clean solution here is creating sub-models in keras. Keras is not able to save nested model in h5 format properly, TF Checkpoint is recommended since its offically supported by TensorFlow.

Command Line Args Reference

convert.py:
  --output: path to output
    (default: './checkpoints/yolov3.tf')
  --weights: path to weights file
    (default: './data/yolov3.weights')
  --num_classes: number of classes in the model
    (default: '80')
    (an integer)


detect_video.py:
  --classes: path to classes file
    (default: './data/coco.names')
  --video: path to input video (use 0 for cam)
    (default: './data/video.mp4')
  --output: path to output video (remember to set right codec for given format. e.g. XVID for .avi)
    (default: None)
  --output_format: codec used in VideoWriter when saving video to file
    (default: 'XVID')
  --weights: path to weights file
    (default: './checkpoints/yolov3.tf')
  --num_classes: number of classes in the model
    (default: '80')
    (an integer)

Change Log

May 25, 2020

  • Updated to Tensorflow to v2.1.0 Release

References

It is pretty much impossible to implement this from the yolov3 paper alone.

About

Implementatoin of object detection using Tensorflow 2.1.0 | this can be use in a car for object detection

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages